OLD | NEW |
| (Empty) |
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/shell_content_client.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/strings/string_piece.h" | |
9 #include "base/utf_string_conversions.h" | |
10 #include "content/public/common/content_switches.h" | |
11 #include "content/shell/shell_switches.h" | |
12 #include "grit/shell_resources.h" | |
13 #include "grit/webkit_resources.h" | |
14 #include "grit/webkit_strings.h" | |
15 #include "ui/base/l10n/l10n_util.h" | |
16 #include "ui/base/resource/resource_bundle.h" | |
17 #include "webkit/user_agent/user_agent_util.h" | |
18 | |
19 namespace content { | |
20 | |
21 ShellContentClient::~ShellContentClient() { | |
22 } | |
23 | |
24 std::string ShellContentClient::GetUserAgent() const { | |
25 std::string product = "Chrome/" CONTENT_SHELL_VERSION; | |
26 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
27 if (command_line->HasSwitch(switches::kUseMobileUserAgent)) | |
28 product += " Mobile"; | |
29 return webkit_glue::BuildUserAgentFromProduct(product); | |
30 } | |
31 | |
32 string16 ShellContentClient::GetLocalizedString(int message_id) const { | |
33 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | |
34 switch (message_id) { | |
35 case IDS_FORM_VALIDATION_VALUE_MISSING: | |
36 case IDS_FORM_VALIDATION_VALUE_MISSING_CHECKBOX: | |
37 case IDS_FORM_VALIDATION_VALUE_MISSING_FILE: | |
38 case IDS_FORM_VALIDATION_VALUE_MISSING_MULTIPLE_FILE: | |
39 case IDS_FORM_VALIDATION_VALUE_MISSING_RADIO: | |
40 case IDS_FORM_VALIDATION_VALUE_MISSING_SELECT: | |
41 return ASCIIToUTF16("value missing"); | |
42 case IDS_FORM_VALIDATION_TYPE_MISMATCH: | |
43 case IDS_FORM_VALIDATION_TYPE_MISMATCH_EMAIL: | |
44 case IDS_FORM_VALIDATION_TYPE_MISMATCH_MULTIPLE_EMAIL: | |
45 case IDS_FORM_VALIDATION_TYPE_MISMATCH_URL: | |
46 return ASCIIToUTF16("type mismatch"); | |
47 case IDS_FORM_VALIDATION_PATTERN_MISMATCH: | |
48 return ASCIIToUTF16("pattern mismatch"); | |
49 case IDS_FORM_VALIDATION_TOO_LONG: | |
50 return ASCIIToUTF16("too long"); | |
51 case IDS_FORM_VALIDATION_RANGE_UNDERFLOW: | |
52 return ASCIIToUTF16("range underflow"); | |
53 case IDS_FORM_VALIDATION_RANGE_OVERFLOW: | |
54 return ASCIIToUTF16("range overflow"); | |
55 case IDS_FORM_VALIDATION_STEP_MISMATCH: | |
56 return ASCIIToUTF16("step mismatch"); | |
57 case IDS_FORM_OTHER_DATE_LABEL: | |
58 return ASCIIToUTF16("<<OtherDateLabel>>"); | |
59 case IDS_FORM_OTHER_MONTH_LABEL: | |
60 return ASCIIToUTF16("<<OtherMonthLabel>>"); | |
61 case IDS_FORM_OTHER_TIME_LABEL: | |
62 return ASCIIToUTF16("<<OtherTimeLabel>>"); | |
63 case IDS_FORM_OTHER_WEEK_LABEL: | |
64 return ASCIIToUTF16("<<OtherWeekLabel>>"); | |
65 case IDS_FORM_CALENDAR_CLEAR: | |
66 return ASCIIToUTF16("<<CalendarClear>>"); | |
67 case IDS_FORM_CALENDAR_TODAY: | |
68 return ASCIIToUTF16("<<CalendarToday>>"); | |
69 case IDS_FORM_THIS_MONTH_LABEL: | |
70 return ASCIIToUTF16("<<ThisMonthLabel>>"); | |
71 case IDS_FORM_THIS_WEEK_LABEL: | |
72 return ASCIIToUTF16("<<ThisWeekLabel>>"); | |
73 } | |
74 } | |
75 return l10n_util::GetStringUTF16(message_id); | |
76 } | |
77 | |
78 base::StringPiece ShellContentClient::GetDataResource( | |
79 int resource_id, | |
80 ui::ScaleFactor scale_factor) const { | |
81 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | |
82 switch (resource_id) { | |
83 case IDR_BROKENIMAGE: | |
84 #if defined(OS_MACOSX) | |
85 resource_id = IDR_CONTENT_SHELL_MISSING_IMAGE_PNG; | |
86 #else | |
87 resource_id = IDR_CONTENT_SHELL_MISSING_IMAGE_GIF; | |
88 #endif | |
89 break; | |
90 | |
91 case IDR_TEXTAREA_RESIZER: | |
92 resource_id = IDR_CONTENT_SHELL_TEXT_AREA_RESIZE_CORNER_PNG; | |
93 break; | |
94 } | |
95 } | |
96 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( | |
97 resource_id, scale_factor); | |
98 } | |
99 | |
100 base::RefCountedStaticMemory* ShellContentClient::GetDataResourceBytes( | |
101 int resource_id) const { | |
102 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); | |
103 } | |
104 | |
105 gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) const { | |
106 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); | |
107 } | |
108 | |
109 } // namespace content | |
OLD | NEW |