Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(749)

Side by Side Diff: webkit/glue/webkitclient_impl.cc

Issue 149760: Introduce WebLocalizedString and queryLocalizedString methods... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webkitclient_impl.h ('k') | webkit/tools/test_shell/test_shell_webkit_init.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "webkit/glue/webkitclient_impl.h" 5 #include "webkit/glue/webkitclient_impl.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/stats_counters.h" 8 #include "base/stats_counters.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/trace_event.h" 10 #include "base/trace_event.h"
11 #include "grit/webkit_resources.h" 11 #include "grit/webkit_resources.h"
12 #include "grit/webkit_strings.h"
12 #include "webkit/api/public/WebData.h" 13 #include "webkit/api/public/WebData.h"
13 #include "webkit/api/public/WebPluginListBuilder.h" 14 #include "webkit/api/public/WebPluginListBuilder.h"
14 #include "webkit/api/public/WebString.h" 15 #include "webkit/api/public/WebString.h"
15 #include "webkit/glue/webkit_glue.h" 16 #include "webkit/glue/webkit_glue.h"
16 #include "webkit/glue/webplugininfo.h" 17 #include "webkit/glue/webplugininfo.h"
17 #include "webkit/glue/weburlloader_impl.h" 18 #include "webkit/glue/weburlloader_impl.h"
18 19
19 using WebKit::WebData; 20 using WebKit::WebData;
21 using WebKit::WebLocalizedString;
20 using WebKit::WebPluginListBuilder; 22 using WebKit::WebPluginListBuilder;
23 using WebKit::WebString;
21 using WebKit::WebThemeEngine; 24 using WebKit::WebThemeEngine;
22 using WebKit::WebURLLoader; 25 using WebKit::WebURLLoader;
23 26
24 namespace webkit_glue { 27 namespace webkit_glue {
25 28
29 static int ToMessageID(WebLocalizedString::Name name) {
30 switch (name) {
31 case WebLocalizedString::SubmitButtonDefaultLabel:
32 return IDS_FORM_SUBMIT_LABEL;
33 case WebLocalizedString::InputElementAltText:
34 return IDS_FORM_INPUT_ALT;
35 case WebLocalizedString::ResetButtonDefaultLabel:
36 return IDS_FORM_RESET_LABEL;
37 case WebLocalizedString::FileButtonChooseFileLabel:
38 return IDS_FORM_FILE_BUTTON_LABEL;
39 case WebLocalizedString::FileButtonNoFileSelectedLabel:
40 return IDS_FORM_FILE_NO_FILE_LABEL;
41 case WebLocalizedString::MultipleFileUploadText:
42 return IDS_FORM_FILE_MULTIPLE_UPLOAD;
43 case WebLocalizedString::SearchableIndexIntroduction:
44 return IDS_SEARCHABLE_INDEX_INTRO;
45 case WebLocalizedString::SearchMenuNoRecentSearchesText:
46 return IDS_RECENT_SEARCHES_NONE;
47 case WebLocalizedString::SearchMenuRecentSearchesText:
48 return IDS_RECENT_SEARCHES;
49 case WebLocalizedString::SearchMenuClearRecentSearchesText:
50 return IDS_RECENT_SEARCHES_CLEAR;
51 case WebLocalizedString::AXWebAreaText:
52 return IDS_AX_ROLE_WEB_AREA;
53 case WebLocalizedString::AXLinkText:
54 return IDS_AX_ROLE_LINK;
55 case WebLocalizedString::AXListMarkerText:
56 return IDS_AX_ROLE_LIST_MARKER;
57 case WebLocalizedString::AXImageMapText:
58 return IDS_AX_ROLE_IMAGE_MAP;
59 case WebLocalizedString::AXHeadingText:
60 return IDS_AX_ROLE_HEADING;
61 case WebLocalizedString::AXButtonActionVerb:
62 return IDS_AX_BUTTON_ACTION_VERB;
63 case WebLocalizedString::AXRadioButtonActionVerb:
64 return IDS_AX_RADIO_BUTTON_ACTION_VERB;
65 case WebLocalizedString::AXTextFieldActionVerb:
66 return IDS_AX_TEXT_FIELD_ACTION_VERB;
67 case WebLocalizedString::AXCheckedCheckBoxActionVerb:
68 return IDS_AX_CHECKED_CHECK_BOX_ACTION_VERB;
69 case WebLocalizedString::AXUncheckedCheckBoxActionVerb:
70 return IDS_AX_UNCHECKED_CHECK_BOX_ACTION_VERB;
71 case WebLocalizedString::AXLinkActionVerb:
72 return IDS_AX_LINK_ACTION_VERB;
73 case WebLocalizedString::KeygenMenuHighGradeKeySize:
74 return IDS_KEYGEN_HIGH_GRADE_KEY;
75 case WebLocalizedString::KeygenMenuMediumGradeKeySize:
76 return IDS_KEYGEN_MED_GRADE_KEY;
77 }
78 return -1;
79 }
80
26 WebKitClientImpl::WebKitClientImpl() 81 WebKitClientImpl::WebKitClientImpl()
27 : main_loop_(MessageLoop::current()), 82 : main_loop_(MessageLoop::current()),
28 shared_timer_func_(NULL) { 83 shared_timer_func_(NULL) {
29 } 84 }
30 85
31 WebThemeEngine* WebKitClientImpl::themeEngine() { 86 WebThemeEngine* WebKitClientImpl::themeEngine() {
32 #if defined(OS_WIN) 87 #if defined(OS_WIN)
33 return &theme_engine_; 88 return &theme_engine_;
34 #else 89 #else
35 return NULL; 90 return NULL;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { 173 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) {
119 if (!strcmp(name, resources[i].name)) { 174 if (!strcmp(name, resources[i].name)) {
120 StringPiece resource = GetDataResource(resources[i].id); 175 StringPiece resource = GetDataResource(resources[i].id);
121 return WebData(resource.data(), resource.size()); 176 return WebData(resource.data(), resource.size());
122 } 177 }
123 } 178 }
124 NOTREACHED() << "Unknown image resource " << name; 179 NOTREACHED() << "Unknown image resource " << name;
125 return WebData(); 180 return WebData();
126 } 181 }
127 182
183 WebString WebKitClientImpl::queryLocalizedString(
184 WebLocalizedString::Name name) {
185 int message_id = ToMessageID(name);
186 if (message_id < 0)
187 return WebString();
188 return GetLocalizedString(message_id);
189 }
190
191 WebString WebKitClientImpl::queryLocalizedString(
192 WebLocalizedString::Name name, int numeric_value) {
193 int message_id = ToMessageID(name);
194 if (message_id < 0)
195 return WebString();
196 return ReplaceStringPlaceholders(GetLocalizedString(message_id),
197 IntToString16(numeric_value),
198 NULL);
199 }
200
128 double WebKitClientImpl::currentTime() { 201 double WebKitClientImpl::currentTime() {
129 return base::Time::Now().ToDoubleT(); 202 return base::Time::Now().ToDoubleT();
130 } 203 }
131 204
132 void WebKitClientImpl::setSharedTimerFiredFunction(void (*func)()) { 205 void WebKitClientImpl::setSharedTimerFiredFunction(void (*func)()) {
133 shared_timer_func_ = func; 206 shared_timer_func_ = func;
134 } 207 }
135 208
136 void WebKitClientImpl::setSharedTimerFireTime(double fire_time) { 209 void WebKitClientImpl::setSharedTimerFireTime(double fire_time) {
137 int interval = static_cast<int>((fire_time - currentTime()) * 1000); 210 int interval = static_cast<int>((fire_time - currentTime()) * 1000);
138 if (interval < 0) 211 if (interval < 0)
139 interval = 0; 212 interval = 0;
140 213
141 shared_timer_.Stop(); 214 shared_timer_.Stop();
142 shared_timer_.Start(base::TimeDelta::FromMilliseconds(interval), this, 215 shared_timer_.Start(base::TimeDelta::FromMilliseconds(interval), this,
143 &WebKitClientImpl::DoTimeout); 216 &WebKitClientImpl::DoTimeout);
144 } 217 }
145 218
146 void WebKitClientImpl::stopSharedTimer() { 219 void WebKitClientImpl::stopSharedTimer() {
147 shared_timer_.Stop(); 220 shared_timer_.Stop();
148 } 221 }
149 222
150 void WebKitClientImpl::callOnMainThread(void (*func)()) { 223 void WebKitClientImpl::callOnMainThread(void (*func)()) {
151 main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func)); 224 main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func));
152 } 225 }
153 226
154 } // namespace webkit_glue 227 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webkitclient_impl.h ('k') | webkit/tools/test_shell/test_shell_webkit_init.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698