OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/shell/common/shell_content_client.h" | 5 #include "content/shell/common/shell_content_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/app/resources/grit/content_resources.h" | 10 #include "content/app/resources/grit/content_resources.h" |
11 #include "content/app/strings/grit/content_strings.h" | 11 #include "content/app/strings/grit/content_strings.h" |
12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
13 #include "content/public/common/user_agent.h" | 13 #include "content/public/common/user_agent.h" |
14 #include "content/shell/common/shell_switches.h" | 14 #include "content/shell/common/shell_switches.h" |
15 #include "grit/shell_resources.h" | 15 #include "grit/shell_resources.h" |
16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 std::string GetShellUserAgent() { | 21 std::string GetShellUserAgent() { |
22 std::string product = "Chrome/" CONTENT_SHELL_VERSION; | 22 std::string product = "Chrome/" CONTENT_SHELL_VERSION; |
23 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 23 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
24 if (command_line->HasSwitch(switches::kUseMobileUserAgent)) | 24 if (command_line->HasSwitch(switches::kUseMobileUserAgent)) |
25 product += " Mobile"; | 25 product += " Mobile"; |
26 return BuildUserAgentFromProduct(product); | 26 return BuildUserAgentFromProduct(product); |
27 } | 27 } |
28 | 28 |
29 ShellContentClient::~ShellContentClient() { | 29 ShellContentClient::~ShellContentClient() { |
30 } | 30 } |
31 | 31 |
32 std::string ShellContentClient::GetUserAgent() const { | 32 std::string ShellContentClient::GetUserAgent() const { |
33 return GetShellUserAgent(); | 33 return GetShellUserAgent(); |
34 } | 34 } |
35 | 35 |
36 base::string16 ShellContentClient::GetLocalizedString(int message_id) const { | 36 base::string16 ShellContentClient::GetLocalizedString(int message_id) const { |
37 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | 37 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 38 switches::kDumpRenderTree)) { |
38 switch (message_id) { | 39 switch (message_id) { |
39 case IDS_FORM_OTHER_DATE_LABEL: | 40 case IDS_FORM_OTHER_DATE_LABEL: |
40 return base::ASCIIToUTF16("<<OtherDateLabel>>"); | 41 return base::ASCIIToUTF16("<<OtherDateLabel>>"); |
41 case IDS_FORM_OTHER_MONTH_LABEL: | 42 case IDS_FORM_OTHER_MONTH_LABEL: |
42 return base::ASCIIToUTF16("<<OtherMonthLabel>>"); | 43 return base::ASCIIToUTF16("<<OtherMonthLabel>>"); |
43 case IDS_FORM_OTHER_TIME_LABEL: | 44 case IDS_FORM_OTHER_TIME_LABEL: |
44 return base::ASCIIToUTF16("<<OtherTimeLabel>>"); | 45 return base::ASCIIToUTF16("<<OtherTimeLabel>>"); |
45 case IDS_FORM_OTHER_WEEK_LABEL: | 46 case IDS_FORM_OTHER_WEEK_LABEL: |
46 return base::ASCIIToUTF16("<<OtherWeekLabel>>"); | 47 return base::ASCIIToUTF16("<<OtherWeekLabel>>"); |
47 case IDS_FORM_CALENDAR_CLEAR: | 48 case IDS_FORM_CALENDAR_CLEAR: |
48 return base::ASCIIToUTF16("<<CalendarClear>>"); | 49 return base::ASCIIToUTF16("<<CalendarClear>>"); |
49 case IDS_FORM_CALENDAR_TODAY: | 50 case IDS_FORM_CALENDAR_TODAY: |
50 return base::ASCIIToUTF16("<<CalendarToday>>"); | 51 return base::ASCIIToUTF16("<<CalendarToday>>"); |
51 case IDS_FORM_THIS_MONTH_LABEL: | 52 case IDS_FORM_THIS_MONTH_LABEL: |
52 return base::ASCIIToUTF16("<<ThisMonthLabel>>"); | 53 return base::ASCIIToUTF16("<<ThisMonthLabel>>"); |
53 case IDS_FORM_THIS_WEEK_LABEL: | 54 case IDS_FORM_THIS_WEEK_LABEL: |
54 return base::ASCIIToUTF16("<<ThisWeekLabel>>"); | 55 return base::ASCIIToUTF16("<<ThisWeekLabel>>"); |
55 } | 56 } |
56 } | 57 } |
57 return l10n_util::GetStringUTF16(message_id); | 58 return l10n_util::GetStringUTF16(message_id); |
58 } | 59 } |
59 | 60 |
60 base::StringPiece ShellContentClient::GetDataResource( | 61 base::StringPiece ShellContentClient::GetDataResource( |
61 int resource_id, | 62 int resource_id, |
62 ui::ScaleFactor scale_factor) const { | 63 ui::ScaleFactor scale_factor) const { |
63 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | 64 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 65 switches::kDumpRenderTree)) { |
64 switch (resource_id) { | 66 switch (resource_id) { |
65 case IDR_BROKENIMAGE: | 67 case IDR_BROKENIMAGE: |
66 #if defined(OS_MACOSX) | 68 #if defined(OS_MACOSX) |
67 resource_id = IDR_CONTENT_SHELL_MISSING_IMAGE_PNG; | 69 resource_id = IDR_CONTENT_SHELL_MISSING_IMAGE_PNG; |
68 #else | 70 #else |
69 resource_id = IDR_CONTENT_SHELL_MISSING_IMAGE_GIF; | 71 resource_id = IDR_CONTENT_SHELL_MISSING_IMAGE_GIF; |
70 #endif | 72 #endif |
71 break; | 73 break; |
72 | 74 |
73 case IDR_TEXTAREA_RESIZER: | 75 case IDR_TEXTAREA_RESIZER: |
74 resource_id = IDR_CONTENT_SHELL_TEXT_AREA_RESIZE_CORNER_PNG; | 76 resource_id = IDR_CONTENT_SHELL_TEXT_AREA_RESIZE_CORNER_PNG; |
75 break; | 77 break; |
76 } | 78 } |
77 } | 79 } |
78 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( | 80 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( |
79 resource_id, scale_factor); | 81 resource_id, scale_factor); |
80 } | 82 } |
81 | 83 |
82 base::RefCountedStaticMemory* ShellContentClient::GetDataResourceBytes( | 84 base::RefCountedStaticMemory* ShellContentClient::GetDataResourceBytes( |
83 int resource_id) const { | 85 int resource_id) const { |
84 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); | 86 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); |
85 } | 87 } |
86 | 88 |
87 gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) const { | 89 gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) const { |
88 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); | 90 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); |
89 } | 91 } |
90 | 92 |
91 } // namespace content | 93 } // namespace content |
OLD | NEW |