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 "content/app/resources/grit/content_resources.h"
11 #include "content/app/strings/grit/content_strings.h"
12 #include "content/public/common/content_switches.h"
13 #include "content/public/common/user_agent.h"
14 #include "content/shell/common/shell_switches.h"
15 #include "grit/shell_resources.h"
16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h"
21 std::string
GetShellUserAgent() {
22 std::string product
= "Chrome/" CONTENT_SHELL_VERSION
;
23 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
24 if (command_line
->HasSwitch(switches::kUseMobileUserAgent
))
26 return BuildUserAgentFromProduct(product
);
29 ShellContentClient::~ShellContentClient() {
32 std::string
ShellContentClient::GetUserAgent() const {
33 return GetShellUserAgent();
36 base::string16
ShellContentClient::GetLocalizedString(int message_id
) const {
37 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
38 switches::kRunLayoutTest
)) {
40 case IDS_FORM_OTHER_DATE_LABEL
:
41 return base::ASCIIToUTF16("<<OtherDateLabel>>");
42 case IDS_FORM_OTHER_MONTH_LABEL
:
43 return base::ASCIIToUTF16("<<OtherMonthLabel>>");
44 case IDS_FORM_OTHER_TIME_LABEL
:
45 return base::ASCIIToUTF16("<<OtherTimeLabel>>");
46 case IDS_FORM_OTHER_WEEK_LABEL
:
47 return base::ASCIIToUTF16("<<OtherWeekLabel>>");
48 case IDS_FORM_CALENDAR_CLEAR
:
49 return base::ASCIIToUTF16("<<CalendarClear>>");
50 case IDS_FORM_CALENDAR_TODAY
:
51 return base::ASCIIToUTF16("<<CalendarToday>>");
52 case IDS_FORM_THIS_MONTH_LABEL
:
53 return base::ASCIIToUTF16("<<ThisMonthLabel>>");
54 case IDS_FORM_THIS_WEEK_LABEL
:
55 return base::ASCIIToUTF16("<<ThisWeekLabel>>");
58 return l10n_util::GetStringUTF16(message_id
);
61 base::StringPiece
ShellContentClient::GetDataResource(
63 ui::ScaleFactor scale_factor
) const {
64 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
65 switches::kRunLayoutTest
)) {
66 switch (resource_id
) {
68 #if defined(OS_MACOSX)
69 resource_id
= IDR_CONTENT_SHELL_MISSING_IMAGE_PNG
;
71 resource_id
= IDR_CONTENT_SHELL_MISSING_IMAGE_GIF
;
75 case IDR_TEXTAREA_RESIZER
:
76 resource_id
= IDR_CONTENT_SHELL_TEXT_AREA_RESIZE_CORNER_PNG
;
80 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
81 resource_id
, scale_factor
);
84 base::RefCountedStaticMemory
* ShellContentClient::GetDataResourceBytes(
85 int resource_id
) const {
86 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id
);
89 gfx::Image
& ShellContentClient::GetNativeImageNamed(int resource_id
) const {
90 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id
);
93 } // namespace content