Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/webkitclient_impl.h" | 5 #include "webkit/glue/webkitclient_impl.h" |
| 6 | 6 |
| 7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
| 8 #include <malloc.h> | 8 #include <malloc.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 case WebLocalizedString::AXCheckedCheckBoxActionVerb: | 149 case WebLocalizedString::AXCheckedCheckBoxActionVerb: |
| 150 return IDS_AX_CHECKED_CHECK_BOX_ACTION_VERB; | 150 return IDS_AX_CHECKED_CHECK_BOX_ACTION_VERB; |
| 151 case WebLocalizedString::AXUncheckedCheckBoxActionVerb: | 151 case WebLocalizedString::AXUncheckedCheckBoxActionVerb: |
| 152 return IDS_AX_UNCHECKED_CHECK_BOX_ACTION_VERB; | 152 return IDS_AX_UNCHECKED_CHECK_BOX_ACTION_VERB; |
| 153 case WebLocalizedString::AXLinkActionVerb: | 153 case WebLocalizedString::AXLinkActionVerb: |
| 154 return IDS_AX_LINK_ACTION_VERB; | 154 return IDS_AX_LINK_ACTION_VERB; |
| 155 case WebLocalizedString::KeygenMenuHighGradeKeySize: | 155 case WebLocalizedString::KeygenMenuHighGradeKeySize: |
| 156 return IDS_KEYGEN_HIGH_GRADE_KEY; | 156 return IDS_KEYGEN_HIGH_GRADE_KEY; |
| 157 case WebLocalizedString::KeygenMenuMediumGradeKeySize: | 157 case WebLocalizedString::KeygenMenuMediumGradeKeySize: |
| 158 return IDS_KEYGEN_MED_GRADE_KEY; | 158 return IDS_KEYGEN_MED_GRADE_KEY; |
| 159 // TODO(tkent): Remove default: when we merge the next | 159 case WebLocalizedString::ValidationValueMissing: |
| 160 // WebLocalizedString.h change. | 160 return IDS_FORM_VALIDATION_VALUE_MISSING; |
| 161 default: | 161 case WebLocalizedString::ValidationTypeMismatch: |
| 162 break; | 162 return IDS_FORM_VALIDATION_TYPE_MISMATCH; |
| 163 case WebLocalizedString::ValidationTypeMismatchForEmail: | |
| 164 return IDS_FORM_VALIDATION_TYPE_MISMATCH_EMAIL; | |
| 165 case WebLocalizedString::ValidationTypeMismatchForMultipleEmail: | |
| 166 return IDS_FORM_VALIDATION_TYPE_MISMATCH_MULTIPLE_EMAIL; | |
| 167 case WebLocalizedString::ValidationTypeMismatchForURL: | |
| 168 return IDS_FORM_VALIDATION_TYPE_MISMATCH_URL; | |
| 169 case WebLocalizedString::ValidationPatternMismatch: | |
| 170 return IDS_FORM_VALIDATION_PATTERN_MISMATCH; | |
| 171 case WebLocalizedString::ValidationTooLong: | |
| 172 return IDS_FORM_VALIDATION_TOO_LONG; | |
| 173 case WebLocalizedString::ValidationRangeUnderflow: | |
| 174 return IDS_FORM_VALIDATION_RANGE_UNDERFLOW; | |
| 175 case WebLocalizedString::ValidationRangeOverflow: | |
| 176 return IDS_FORM_VALIDATION_RANGE_OVERFLOW; | |
| 177 case WebLocalizedString::ValidationStepMismatch: | |
| 178 return IDS_FORM_VALIDATION_STEP_MISMATCH; | |
| 163 } | 179 } |
| 164 return -1; | 180 return -1; |
| 165 } | 181 } |
| 166 | 182 |
| 167 WebKitClientImpl::WebKitClientImpl() | 183 WebKitClientImpl::WebKitClientImpl() |
| 168 : main_loop_(MessageLoop::current()), | 184 : main_loop_(MessageLoop::current()), |
| 169 shared_timer_func_(NULL), | 185 shared_timer_func_(NULL), |
| 170 shared_timer_fire_time_(0.0), | 186 shared_timer_fire_time_(0.0), |
| 171 shared_timer_suspended_(0) { | 187 shared_timer_suspended_(0) { |
| 172 } | 188 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 | 319 |
| 304 WebString WebKitClientImpl::queryLocalizedString( | 320 WebString WebKitClientImpl::queryLocalizedString( |
| 305 WebLocalizedString::Name name) { | 321 WebLocalizedString::Name name) { |
| 306 int message_id = ToMessageID(name); | 322 int message_id = ToMessageID(name); |
| 307 if (message_id < 0) | 323 if (message_id < 0) |
| 308 return WebString(); | 324 return WebString(); |
| 309 return GetLocalizedString(message_id); | 325 return GetLocalizedString(message_id); |
| 310 } | 326 } |
| 311 | 327 |
| 312 WebString WebKitClientImpl::queryLocalizedString( | 328 WebString WebKitClientImpl::queryLocalizedString( |
| 313 WebLocalizedString::Name name, int numeric_value) { | 329 WebLocalizedString::Name name, int numeric_value) { |
|
tony
2010/11/16 18:11:41
Can this method just convert numeric_value to a st
tkent
2010/11/22 10:19:06
It's a good idea.
We should have
- queryLocalized
| |
| 314 int message_id = ToMessageID(name); | 330 int message_id = ToMessageID(name); |
| 315 if (message_id < 0) | 331 if (message_id < 0) |
| 316 return WebString(); | 332 return WebString(); |
| 317 return ReplaceStringPlaceholders(GetLocalizedString(message_id), | 333 return ReplaceStringPlaceholders(GetLocalizedString(message_id), |
| 318 base::IntToString16(numeric_value), | 334 base::IntToString16(numeric_value), |
| 319 NULL); | 335 NULL); |
| 320 } | 336 } |
| 321 | 337 |
| 338 WebString WebKitClientImpl::queryLocalizedString( | |
| 339 WebLocalizedString::Name name, int value1, int value2) { | |
|
tony
2010/11/16 18:11:41
Can this method just call the WebString, WebString
tkent
2010/11/22 10:19:06
Removed this function.
| |
| 340 int message_id = ToMessageID(name); | |
| 341 if (message_id < 0) | |
| 342 return WebString(); | |
| 343 std::vector<string16> values; | |
| 344 values.reserve(2); | |
| 345 values.push_back(base::IntToString16(value1)); | |
| 346 values.push_back(base::IntToString16(value2)); | |
| 347 return ReplaceStringPlaceholders( | |
| 348 GetLocalizedString(message_id), values, NULL); | |
| 349 } | |
| 350 | |
| 351 WebString WebKitClientImpl::queryLocalizedString( | |
| 352 WebLocalizedString::Name name, const WebString& value) { | |
| 353 int message_id = ToMessageID(name); | |
| 354 if (message_id < 0) | |
| 355 return WebString(); | |
| 356 return ReplaceStringPlaceholders(GetLocalizedString(message_id), value, NULL); | |
| 357 } | |
| 358 | |
| 359 WebString WebKitClientImpl::queryLocalizedString( | |
| 360 WebLocalizedString::Name name, | |
| 361 const WebString& value1, | |
| 362 const WebString& value2) { | |
| 363 int message_id = ToMessageID(name); | |
| 364 if (message_id < 0) | |
| 365 return WebString(); | |
| 366 std::vector<string16> values; | |
| 367 values.reserve(2); | |
| 368 values.push_back(value1); | |
| 369 values.push_back(value2); | |
| 370 return ReplaceStringPlaceholders( | |
| 371 GetLocalizedString(message_id), values, NULL); | |
| 372 } | |
| 373 | |
| 322 double WebKitClientImpl::currentTime() { | 374 double WebKitClientImpl::currentTime() { |
| 323 return base::Time::Now().ToDoubleT(); | 375 return base::Time::Now().ToDoubleT(); |
| 324 } | 376 } |
| 325 | 377 |
| 326 void WebKitClientImpl::setSharedTimerFiredFunction(void (*func)()) { | 378 void WebKitClientImpl::setSharedTimerFiredFunction(void (*func)()) { |
| 327 shared_timer_func_ = func; | 379 shared_timer_func_ = func; |
| 328 } | 380 } |
| 329 | 381 |
| 330 void WebKitClientImpl::setSharedTimerFireTime(double fire_time) { | 382 void WebKitClientImpl::setSharedTimerFireTime(double fire_time) { |
| 331 shared_timer_fire_time_ = fire_time; | 383 shared_timer_fire_time_ = fire_time; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 ++shared_timer_suspended_; | 511 ++shared_timer_suspended_; |
| 460 } | 512 } |
| 461 | 513 |
| 462 void WebKitClientImpl::ResumeSharedTimer() { | 514 void WebKitClientImpl::ResumeSharedTimer() { |
| 463 // The shared timer may have fired or been adjusted while we were suspended. | 515 // The shared timer may have fired or been adjusted while we were suspended. |
| 464 if (--shared_timer_suspended_ == 0 && !shared_timer_.IsRunning()) | 516 if (--shared_timer_suspended_ == 0 && !shared_timer_.IsRunning()) |
| 465 setSharedTimerFireTime(shared_timer_fire_time_); | 517 setSharedTimerFireTime(shared_timer_fire_time_); |
| 466 } | 518 } |
| 467 | 519 |
| 468 } // namespace webkit_glue | 520 } // namespace webkit_glue |
| OLD | NEW |