OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/test_runner/web_test_proxy.h" | 5 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
6 | 6 |
7 #include <cctype> | 7 #include <cctype> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 // TestRunner does not support popup widgets. So |web_widget|_ is always a | 310 // TestRunner does not support popup widgets. So |web_widget|_ is always a |
311 // WebView. | 311 // WebView. |
312 return static_cast<WebView*>(web_widget_); | 312 return static_cast<WebView*>(web_widget_); |
313 } | 313 } |
314 | 314 |
315 void WebTestProxyBase::Reset() { | 315 void WebTestProxyBase::Reset() { |
316 animate_scheduled_ = false; | 316 animate_scheduled_ = false; |
317 resource_identifier_map_.clear(); | 317 resource_identifier_map_.clear(); |
318 log_console_output_ = true; | 318 log_console_output_ = true; |
319 if (m_midiClient.get()) m_midiClient->resetMock(); | 319 if (m_midiClient.get()) m_midiClient->resetMock(); |
320 accept_languages_ = "en-US"; | |
321 } | 320 } |
322 | 321 |
323 WebSpellCheckClient* WebTestProxyBase::GetSpellCheckClient() const { | 322 WebSpellCheckClient* WebTestProxyBase::GetSpellCheckClient() const { |
324 return spellcheck_.get(); | 323 return spellcheck_.get(); |
325 } | 324 } |
326 | 325 |
327 WebColorChooser* WebTestProxyBase::CreateColorChooser( | 326 WebColorChooser* WebTestProxyBase::CreateColorChooser( |
328 WebColorChooserClient* client, const blink::WebColor& color, | 327 WebColorChooserClient* client, const blink::WebColor& color, |
329 const blink::WebVector<blink::WebColorSuggestion>& suggestions) { | 328 const blink::WebVector<blink::WebColorSuggestion>& suggestions) { |
330 // This instance is deleted by WebCore::ColorInputType | 329 // This instance is deleted by WebCore::ColorInputType |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 void WebTestProxyBase::didCompositeAndReadback(const SkBitmap& bitmap) { | 411 void WebTestProxyBase::didCompositeAndReadback(const SkBitmap& bitmap) { |
413 TRACE_EVENT2("shell", "WebTestProxyBase::didCompositeAndReadback", "x", | 412 TRACE_EVENT2("shell", "WebTestProxyBase::didCompositeAndReadback", "x", |
414 bitmap.info().fWidth, "y", bitmap.info().fHeight); | 413 bitmap.info().fWidth, "y", bitmap.info().fHeight); |
415 SkCanvas canvas(bitmap); | 414 SkCanvas canvas(bitmap); |
416 DrawSelectionRect(&canvas); | 415 DrawSelectionRect(&canvas); |
417 DCHECK(!composite_and_readback_callbacks_.empty()); | 416 DCHECK(!composite_and_readback_callbacks_.empty()); |
418 composite_and_readback_callbacks_.front().Run(bitmap); | 417 composite_and_readback_callbacks_.front().Run(bitmap); |
419 composite_and_readback_callbacks_.pop_front(); | 418 composite_and_readback_callbacks_.pop_front(); |
420 } | 419 } |
421 | 420 |
422 void WebTestProxyBase::SetAcceptLanguages(const std::string& accept_languages) { | |
423 bool notify = accept_languages_ != accept_languages; | |
424 accept_languages_ = accept_languages; | |
425 | |
426 if (notify) | |
427 GetWebView()->acceptLanguagesChanged(); | |
428 } | |
429 | |
430 void WebTestProxyBase::CapturePixelsForPrinting( | 421 void WebTestProxyBase::CapturePixelsForPrinting( |
431 const base::Callback<void(const SkBitmap&)>& callback) { | 422 const base::Callback<void(const SkBitmap&)>& callback) { |
432 web_widget_->layout(); | 423 web_widget_->layout(); |
433 | 424 |
434 WebSize pageSizeInPixels = web_widget_->size(); | 425 WebSize pageSizeInPixels = web_widget_->size(); |
435 WebFrame* webFrame = GetWebView()->mainFrame(); | 426 WebFrame* webFrame = GetWebView()->mainFrame(); |
436 | 427 |
437 int pageCount = webFrame->printBegin(pageSizeInPixels); | 428 int pageCount = webFrame->printBegin(pageSizeInPixels); |
438 int totalHeight = pageCount * (pageSizeInPixels.height + 1) - 1; | 429 int totalHeight = pageCount * (pageSizeInPixels.height + 1) - 1; |
439 | 430 |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 eventName.utf8().data() + "\n"); | 1106 eventName.utf8().data() + "\n"); |
1116 } | 1107 } |
1117 } | 1108 } |
1118 | 1109 |
1119 void WebTestProxyBase::ResetInputMethod() { | 1110 void WebTestProxyBase::ResetInputMethod() { |
1120 // If a composition text exists, then we need to let the browser process | 1111 // If a composition text exists, then we need to let the browser process |
1121 // to cancel the input method's ongoing composition session. | 1112 // to cancel the input method's ongoing composition session. |
1122 if (web_widget_) web_widget_->confirmComposition(); | 1113 if (web_widget_) web_widget_->confirmComposition(); |
1123 } | 1114 } |
1124 | 1115 |
1125 blink::WebString WebTestProxyBase::acceptLanguages() { | |
1126 return WebString::fromUTF8(accept_languages_); | |
1127 } | |
1128 | |
1129 } // namespace content | 1116 } // namespace content |
OLD | NEW |