Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/test/chromedriver/chrome/web_view_impl.h" | 5 #include "chrome/test/chromedriver/chrome/web_view_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/test/chromedriver/chrome/debugger_tracker.h" | 16 #include "chrome/test/chromedriver/chrome/debugger_tracker.h" |
| 17 #include "chrome/test/chromedriver/chrome/device_metrics_override_manager.h" | |
| 17 #include "chrome/test/chromedriver/chrome/devtools_client_impl.h" | 18 #include "chrome/test/chromedriver/chrome/devtools_client_impl.h" |
| 18 #include "chrome/test/chromedriver/chrome/dom_tracker.h" | 19 #include "chrome/test/chromedriver/chrome/dom_tracker.h" |
| 19 #include "chrome/test/chromedriver/chrome/frame_tracker.h" | 20 #include "chrome/test/chromedriver/chrome/frame_tracker.h" |
| 20 #include "chrome/test/chromedriver/chrome/geolocation_override_manager.h" | 21 #include "chrome/test/chromedriver/chrome/geolocation_override_manager.h" |
| 21 #include "chrome/test/chromedriver/chrome/heap_snapshot_taker.h" | 22 #include "chrome/test/chromedriver/chrome/heap_snapshot_taker.h" |
| 22 #include "chrome/test/chromedriver/chrome/javascript_dialog_manager.h" | 23 #include "chrome/test/chromedriver/chrome/javascript_dialog_manager.h" |
| 23 #include "chrome/test/chromedriver/chrome/js.h" | 24 #include "chrome/test/chromedriver/chrome/js.h" |
| 24 #include "chrome/test/chromedriver/chrome/navigation_tracker.h" | 25 #include "chrome/test/chromedriver/chrome/navigation_tracker.h" |
| 25 #include "chrome/test/chromedriver/chrome/status.h" | 26 #include "chrome/test/chromedriver/chrome/status.h" |
| 26 #include "chrome/test/chromedriver/chrome/ui_events.h" | 27 #include "chrome/test/chromedriver/chrome/ui_events.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 const BrowserInfo* browser_info, | 117 const BrowserInfo* browser_info, |
| 117 scoped_ptr<DevToolsClient> client) | 118 scoped_ptr<DevToolsClient> client) |
| 118 : id_(id), | 119 : id_(id), |
| 119 browser_info_(browser_info), | 120 browser_info_(browser_info), |
| 120 dom_tracker_(new DomTracker(client.get())), | 121 dom_tracker_(new DomTracker(client.get())), |
| 121 frame_tracker_(new FrameTracker(client.get())), | 122 frame_tracker_(new FrameTracker(client.get())), |
| 122 navigation_tracker_(new NavigationTracker(client.get(), browser_info)), | 123 navigation_tracker_(new NavigationTracker(client.get(), browser_info)), |
| 123 dialog_manager_(new JavaScriptDialogManager(client.get())), | 124 dialog_manager_(new JavaScriptDialogManager(client.get())), |
| 124 geolocation_override_manager_( | 125 geolocation_override_manager_( |
| 125 new GeolocationOverrideManager(client.get())), | 126 new GeolocationOverrideManager(client.get())), |
| 127 device_metrics_override_manager_( | |
| 128 new DeviceMetricsOverrideManager(client.get())), | |
| 126 heap_snapshot_taker_(new HeapSnapshotTaker(client.get())), | 129 heap_snapshot_taker_(new HeapSnapshotTaker(client.get())), |
| 127 debugger_(new DebuggerTracker(client.get())), | 130 debugger_(new DebuggerTracker(client.get())), |
| 128 client_(client.release()) {} | 131 client_(client.release()) {} |
| 129 | 132 |
| 130 WebViewImpl::~WebViewImpl() {} | 133 WebViewImpl::~WebViewImpl() {} |
| 131 | 134 |
| 132 std::string WebViewImpl::GetId() { | 135 std::string WebViewImpl::GetId() { |
| 133 return id_; | 136 return id_; |
| 134 } | 137 } |
| 135 | 138 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 } | 362 } |
| 360 | 363 |
| 361 JavaScriptDialogManager* WebViewImpl::GetJavaScriptDialogManager() { | 364 JavaScriptDialogManager* WebViewImpl::GetJavaScriptDialogManager() { |
| 362 return dialog_manager_.get(); | 365 return dialog_manager_.get(); |
| 363 } | 366 } |
| 364 | 367 |
| 365 Status WebViewImpl::OverrideGeolocation(const Geoposition& geoposition) { | 368 Status WebViewImpl::OverrideGeolocation(const Geoposition& geoposition) { |
| 366 return geolocation_override_manager_->OverrideGeolocation(geoposition); | 369 return geolocation_override_manager_->OverrideGeolocation(geoposition); |
| 367 } | 370 } |
| 368 | 371 |
| 372 Status WebViewImpl::OverrideDeviceMetrics(const DeviceMetrics& device_metrics) { | |
| 373 return device_metrics_override_manager_->OverrideDeviceMetrics(device_metrics) ; | |
|
stgao
2014/04/30 03:32:55
Over 80 chars.
| |
| 374 } | |
| 375 | |
| 369 Status WebViewImpl::CaptureScreenshot(std::string* screenshot) { | 376 Status WebViewImpl::CaptureScreenshot(std::string* screenshot) { |
| 370 base::DictionaryValue params; | 377 base::DictionaryValue params; |
| 371 scoped_ptr<base::DictionaryValue> result; | 378 scoped_ptr<base::DictionaryValue> result; |
| 372 Status status = client_->SendCommandAndGetResult( | 379 Status status = client_->SendCommandAndGetResult( |
| 373 "Page.captureScreenshot", params, &result); | 380 "Page.captureScreenshot", params, &result); |
| 374 if (status.IsError()) | 381 if (status.IsError()) |
| 375 return status; | 382 return status; |
| 376 if (!result->GetString("data", screenshot)) | 383 if (!result->GetString("data", screenshot)) |
| 377 return Status(kUnknownError, "expected string 'data' in response"); | 384 return Status(kUnknownError, "expected string 'data' in response"); |
| 378 return Status(kOk); | 385 return Status(kOk); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 651 if (status.IsError()) | 658 if (status.IsError()) |
| 652 return status; | 659 return status; |
| 653 | 660 |
| 654 if (!cmd_result->GetInteger("nodeId", node_id)) | 661 if (!cmd_result->GetInteger("nodeId", node_id)) |
| 655 return Status(kUnknownError, "DOM.requestNode missing int 'nodeId'"); | 662 return Status(kUnknownError, "DOM.requestNode missing int 'nodeId'"); |
| 656 *found_node = true; | 663 *found_node = true; |
| 657 return Status(kOk); | 664 return Status(kOk); |
| 658 } | 665 } |
| 659 | 666 |
| 660 } // namespace internal | 667 } // namespace internal |
| OLD | NEW |