| 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_ = ""; |
| 320 } | 321 } |
| 321 | 322 |
| 322 WebSpellCheckClient* WebTestProxyBase::GetSpellCheckClient() const { | 323 WebSpellCheckClient* WebTestProxyBase::GetSpellCheckClient() const { |
| 323 return spellcheck_.get(); | 324 return spellcheck_.get(); |
| 324 } | 325 } |
| 325 | 326 |
| 326 WebColorChooser* WebTestProxyBase::CreateColorChooser( | 327 WebColorChooser* WebTestProxyBase::CreateColorChooser( |
| 327 WebColorChooserClient* client, const blink::WebColor& color, | 328 WebColorChooserClient* client, const blink::WebColor& color, |
| 328 const blink::WebVector<blink::WebColorSuggestion>& suggestions) { | 329 const blink::WebVector<blink::WebColorSuggestion>& suggestions) { |
| 329 // This instance is deleted by WebCore::ColorInputType | 330 // This instance is deleted by WebCore::ColorInputType |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 void WebTestProxyBase::didCompositeAndReadback(const SkBitmap& bitmap) { | 412 void WebTestProxyBase::didCompositeAndReadback(const SkBitmap& bitmap) { |
| 412 TRACE_EVENT2("shell", "WebTestProxyBase::didCompositeAndReadback", "x", | 413 TRACE_EVENT2("shell", "WebTestProxyBase::didCompositeAndReadback", "x", |
| 413 bitmap.info().fWidth, "y", bitmap.info().fHeight); | 414 bitmap.info().fWidth, "y", bitmap.info().fHeight); |
| 414 SkCanvas canvas(bitmap); | 415 SkCanvas canvas(bitmap); |
| 415 DrawSelectionRect(&canvas); | 416 DrawSelectionRect(&canvas); |
| 416 DCHECK(!composite_and_readback_callbacks_.empty()); | 417 DCHECK(!composite_and_readback_callbacks_.empty()); |
| 417 composite_and_readback_callbacks_.front().Run(bitmap); | 418 composite_and_readback_callbacks_.front().Run(bitmap); |
| 418 composite_and_readback_callbacks_.pop_front(); | 419 composite_and_readback_callbacks_.pop_front(); |
| 419 } | 420 } |
| 420 | 421 |
| 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 |
| 421 void WebTestProxyBase::CapturePixelsForPrinting( | 430 void WebTestProxyBase::CapturePixelsForPrinting( |
| 422 const base::Callback<void(const SkBitmap&)>& callback) { | 431 const base::Callback<void(const SkBitmap&)>& callback) { |
| 423 web_widget_->layout(); | 432 web_widget_->layout(); |
| 424 | 433 |
| 425 WebSize pageSizeInPixels = web_widget_->size(); | 434 WebSize pageSizeInPixels = web_widget_->size(); |
| 426 WebFrame* webFrame = GetWebView()->mainFrame(); | 435 WebFrame* webFrame = GetWebView()->mainFrame(); |
| 427 | 436 |
| 428 int pageCount = webFrame->printBegin(pageSizeInPixels); | 437 int pageCount = webFrame->printBegin(pageSizeInPixels); |
| 429 int totalHeight = pageCount * (pageSizeInPixels.height + 1) - 1; | 438 int totalHeight = pageCount * (pageSizeInPixels.height + 1) - 1; |
| 430 | 439 |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 eventName.utf8().data() + "\n"); | 1115 eventName.utf8().data() + "\n"); |
| 1107 } | 1116 } |
| 1108 } | 1117 } |
| 1109 | 1118 |
| 1110 void WebTestProxyBase::ResetInputMethod() { | 1119 void WebTestProxyBase::ResetInputMethod() { |
| 1111 // If a composition text exists, then we need to let the browser process | 1120 // If a composition text exists, then we need to let the browser process |
| 1112 // to cancel the input method's ongoing composition session. | 1121 // to cancel the input method's ongoing composition session. |
| 1113 if (web_widget_) web_widget_->confirmComposition(); | 1122 if (web_widget_) web_widget_->confirmComposition(); |
| 1114 } | 1123 } |
| 1115 | 1124 |
| 1125 blink::WebString WebTestProxyBase::acceptLanguages() { |
| 1126 return WebString::fromUTF8(accept_languages_); |
| 1127 } |
| 1128 |
| 1116 } // namespace content | 1129 } // namespace content |
| OLD | NEW |