1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "content/shell/common/shell_content_client.h" 6 7 #include "base/command_line.h" 8 #include "base/strings/string_piece.h" 9 #include "base/strings/utf_string_conversions.h" 10 #include "base/values.h" 11 #include "build/build_config.h" 12 #include "content/app/resources/grit/content_resources.h" 13 #include "content/public/common/content_switches.h" 14 #include "content/shell/common/shell_switches.h" 15 #include "content/shell/grit/shell_resources.h" 16 #include "third_party/blink/public/strings/grit/blink_strings.h" 17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/resource/resource_bundle.h" 19 20 namespace content { 21 ShellContentClient()22ShellContentClient::ShellContentClient() {} 23 ~ShellContentClient()24ShellContentClient::~ShellContentClient() {} 25 GetLocalizedString(int message_id)26base::string16 ShellContentClient::GetLocalizedString(int message_id) { 27 if (switches::IsRunWebTestsSwitchPresent()) { 28 switch (message_id) { 29 case IDS_FORM_OTHER_DATE_LABEL: 30 return base::ASCIIToUTF16("<<OtherDateLabel>>"); 31 case IDS_FORM_OTHER_MONTH_LABEL: 32 return base::ASCIIToUTF16("<<OtherMonthLabel>>"); 33 case IDS_FORM_OTHER_WEEK_LABEL: 34 return base::ASCIIToUTF16("<<OtherWeekLabel>>"); 35 case IDS_FORM_CALENDAR_CLEAR: 36 return base::ASCIIToUTF16("<<CalendarClear>>"); 37 case IDS_FORM_CALENDAR_TODAY: 38 return base::ASCIIToUTF16("<<CalendarToday>>"); 39 case IDS_FORM_THIS_MONTH_LABEL: 40 return base::ASCIIToUTF16("<<ThisMonthLabel>>"); 41 case IDS_FORM_THIS_WEEK_LABEL: 42 return base::ASCIIToUTF16("<<ThisWeekLabel>>"); 43 } 44 } 45 return l10n_util::GetStringUTF16(message_id); 46 } 47 GetDataResource(int resource_id,ui::ScaleFactor scale_factor)48base::StringPiece ShellContentClient::GetDataResource( 49 int resource_id, 50 ui::ScaleFactor scale_factor) { 51 return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( 52 resource_id, scale_factor); 53 } 54 GetDataResourceBytes(int resource_id)55base::RefCountedMemory* ShellContentClient::GetDataResourceBytes( 56 int resource_id) { 57 return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 58 resource_id); 59 } 60 GetNativeImageNamed(int resource_id)61gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) { 62 return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( 63 resource_id); 64 } 65 GetOriginTrialPolicy()66blink::OriginTrialPolicy* ShellContentClient::GetOriginTrialPolicy() { 67 return &origin_trial_policy_; 68 } 69 AddAdditionalSchemes(Schemes * schemes)70void ShellContentClient::AddAdditionalSchemes(Schemes* schemes) { 71 #if defined(OS_ANDROID) 72 schemes->local_schemes.push_back(url::kContentScheme); 73 #endif 74 } 75 76 } // namespace content 77