Add ICU message format support
[chromium-blink-merge.git] / content / shell / common / shell_content_client.cc
blob2e420895e28bb983ca93e6fcce028d1650d491ef
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.
5 #include "content/shell/common/shell_content_client.h"
7 #include "base/command_line.h"
8 #include "base/strings/string_piece.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "blink/public/resources/grit/blink_image_resources.h"
11 #include "content/app/resources/grit/content_resources.h"
12 #include "content/app/strings/grit/content_strings.h"
13 #include "content/public/common/content_switches.h"
14 #include "content/public/common/user_agent.h"
15 #include "content/shell/common/shell_switches.h"
16 #include "grit/shell_resources.h"
17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/resource/resource_bundle.h"
20 namespace content {
22 std::string GetShellUserAgent() {
23 std::string product = "Chrome/" CONTENT_SHELL_VERSION;
24 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
25 if (command_line->HasSwitch(switches::kUseMobileUserAgent))
26 product += " Mobile";
27 return BuildUserAgentFromProduct(product);
30 ShellContentClient::~ShellContentClient() {
33 std::string ShellContentClient::GetUserAgent() const {
34 return GetShellUserAgent();
37 base::string16 ShellContentClient::GetLocalizedString(int message_id) const {
38 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
39 switches::kRunLayoutTest)) {
40 switch (message_id) {
41 case IDS_FORM_OTHER_DATE_LABEL:
42 return base::ASCIIToUTF16("<<OtherDateLabel>>");
43 case IDS_FORM_OTHER_MONTH_LABEL:
44 return base::ASCIIToUTF16("<<OtherMonthLabel>>");
45 case IDS_FORM_OTHER_TIME_LABEL:
46 return base::ASCIIToUTF16("<<OtherTimeLabel>>");
47 case IDS_FORM_OTHER_WEEK_LABEL:
48 return base::ASCIIToUTF16("<<OtherWeekLabel>>");
49 case IDS_FORM_CALENDAR_CLEAR:
50 return base::ASCIIToUTF16("<<CalendarClear>>");
51 case IDS_FORM_CALENDAR_TODAY:
52 return base::ASCIIToUTF16("<<CalendarToday>>");
53 case IDS_FORM_THIS_MONTH_LABEL:
54 return base::ASCIIToUTF16("<<ThisMonthLabel>>");
55 case IDS_FORM_THIS_WEEK_LABEL:
56 return base::ASCIIToUTF16("<<ThisWeekLabel>>");
59 return l10n_util::GetStringUTF16(message_id);
62 base::StringPiece ShellContentClient::GetDataResource(
63 int resource_id,
64 ui::ScaleFactor scale_factor) const {
65 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
66 switches::kRunLayoutTest)) {
67 switch (resource_id) {
68 case IDR_BROKENIMAGE:
69 #if defined(OS_MACOSX)
70 resource_id = IDR_CONTENT_SHELL_MISSING_IMAGE_PNG;
71 #else
72 resource_id = IDR_CONTENT_SHELL_MISSING_IMAGE_GIF;
73 #endif
74 break;
76 case IDR_TEXTAREA_RESIZER:
77 resource_id = IDR_CONTENT_SHELL_TEXT_AREA_RESIZE_CORNER_PNG;
78 break;
81 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
82 resource_id, scale_factor);
85 base::RefCountedStaticMemory* ShellContentClient::GetDataResourceBytes(
86 int resource_id) const {
87 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id);
90 gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) const {
91 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
94 } // namespace content