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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 result.append(delegate->dumpHistoryForWindow(windowList.at(i))); | 281 result.append(delegate->dumpHistoryForWindow(windowList.at(i))); |
282 return result; | 282 return result; |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
286 WebTestProxyBase::WebTestProxyBase() | 286 WebTestProxyBase::WebTestProxyBase() |
287 : test_interfaces_(NULL), | 287 : test_interfaces_(NULL), |
288 delegate_(NULL), | 288 delegate_(NULL), |
289 web_widget_(NULL), | 289 web_widget_(NULL), |
290 spellcheck_(new SpellCheckClient(this)), | 290 spellcheck_(new SpellCheckClient(this)), |
291 chooser_count_(0) { | 291 chooser_count_(0), |
| 292 accept_languages_("en-US") { |
292 Reset(); | 293 Reset(); |
293 } | 294 } |
294 | 295 |
295 WebTestProxyBase::~WebTestProxyBase() { test_interfaces_->windowClosed(this); } | 296 WebTestProxyBase::~WebTestProxyBase() { test_interfaces_->windowClosed(this); } |
296 | 297 |
297 void WebTestProxyBase::SetInterfaces(WebTestInterfaces* interfaces) { | 298 void WebTestProxyBase::SetInterfaces(WebTestInterfaces* interfaces) { |
298 test_interfaces_ = interfaces->testInterfaces(); | 299 test_interfaces_ = interfaces->testInterfaces(); |
299 test_interfaces_->windowOpened(this); | 300 test_interfaces_->windowOpened(this); |
300 } | 301 } |
301 | 302 |
(...skipping 109 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 |