| 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/browser_info.h" | 16 #include "chrome/test/chromedriver/chrome/browser_info.h" |
| 17 #include "chrome/test/chromedriver/chrome/debugger_tracker.h" | 17 #include "chrome/test/chromedriver/chrome/debugger_tracker.h" |
| 18 #include "chrome/test/chromedriver/chrome/devtools_client_impl.h" | 18 #include "chrome/test/chromedriver/chrome/devtools_client_impl.h" |
| 19 #include "chrome/test/chromedriver/chrome/dom_tracker.h" | 19 #include "chrome/test/chromedriver/chrome/dom_tracker.h" |
| 20 #include "chrome/test/chromedriver/chrome/frame_tracker.h" | 20 #include "chrome/test/chromedriver/chrome/frame_tracker.h" |
| 21 #include "chrome/test/chromedriver/chrome/geolocation_override_manager.h" | 21 #include "chrome/test/chromedriver/chrome/geolocation_override_manager.h" |
| 22 #include "chrome/test/chromedriver/chrome/heap_snapshot_taker.h" | 22 #include "chrome/test/chromedriver/chrome/heap_snapshot_taker.h" |
| 23 #include "chrome/test/chromedriver/chrome/javascript_dialog_manager.h" | 23 #include "chrome/test/chromedriver/chrome/javascript_dialog_manager.h" |
| 24 #include "chrome/test/chromedriver/chrome/js.h" | 24 #include "chrome/test/chromedriver/chrome/js.h" |
| 25 #include "chrome/test/chromedriver/chrome/mobile_emulation_override_manager.h" | 25 #include "chrome/test/chromedriver/chrome/mobile_emulation_override_manager.h" |
| 26 #include "chrome/test/chromedriver/chrome/navigation_tracker.h" | 26 #include "chrome/test/chromedriver/chrome/navigation_tracker.h" |
| 27 #include "chrome/test/chromedriver/chrome/network_conditions_override_manager.h" |
| 27 #include "chrome/test/chromedriver/chrome/status.h" | 28 #include "chrome/test/chromedriver/chrome/status.h" |
| 28 #include "chrome/test/chromedriver/chrome/ui_events.h" | 29 #include "chrome/test/chromedriver/chrome/ui_events.h" |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 Status GetContextIdForFrame(FrameTracker* tracker, | 33 Status GetContextIdForFrame(FrameTracker* tracker, |
| 33 const std::string& frame, | 34 const std::string& frame, |
| 34 int* context_id) { | 35 int* context_id) { |
| 35 if (frame.empty()) { | 36 if (frame.empty()) { |
| 36 *context_id = 0; | 37 *context_id = 0; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 : id_(id), | 121 : id_(id), |
| 121 browser_info_(browser_info), | 122 browser_info_(browser_info), |
| 122 dom_tracker_(new DomTracker(client.get())), | 123 dom_tracker_(new DomTracker(client.get())), |
| 123 frame_tracker_(new FrameTracker(client.get())), | 124 frame_tracker_(new FrameTracker(client.get())), |
| 124 navigation_tracker_(new NavigationTracker(client.get(), browser_info)), | 125 navigation_tracker_(new NavigationTracker(client.get(), browser_info)), |
| 125 dialog_manager_(new JavaScriptDialogManager(client.get())), | 126 dialog_manager_(new JavaScriptDialogManager(client.get())), |
| 126 mobile_emulation_override_manager_( | 127 mobile_emulation_override_manager_( |
| 127 new MobileEmulationOverrideManager(client.get(), device_metrics)), | 128 new MobileEmulationOverrideManager(client.get(), device_metrics)), |
| 128 geolocation_override_manager_( | 129 geolocation_override_manager_( |
| 129 new GeolocationOverrideManager(client.get())), | 130 new GeolocationOverrideManager(client.get())), |
| 131 network_conditions_override_manager_( |
| 132 new NetworkConditionsOverrideManager(client.get())), |
| 130 heap_snapshot_taker_(new HeapSnapshotTaker(client.get())), | 133 heap_snapshot_taker_(new HeapSnapshotTaker(client.get())), |
| 131 debugger_(new DebuggerTracker(client.get())), | 134 debugger_(new DebuggerTracker(client.get())), |
| 132 client_(client.release()) {} | 135 client_(client.release()) {} |
| 133 | 136 |
| 134 WebViewImpl::~WebViewImpl() {} | 137 WebViewImpl::~WebViewImpl() {} |
| 135 | 138 |
| 136 std::string WebViewImpl::GetId() { | 139 std::string WebViewImpl::GetId() { |
| 137 return id_; | 140 return id_; |
| 138 } | 141 } |
| 139 | 142 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 } | 406 } |
| 404 | 407 |
| 405 JavaScriptDialogManager* WebViewImpl::GetJavaScriptDialogManager() { | 408 JavaScriptDialogManager* WebViewImpl::GetJavaScriptDialogManager() { |
| 406 return dialog_manager_.get(); | 409 return dialog_manager_.get(); |
| 407 } | 410 } |
| 408 | 411 |
| 409 Status WebViewImpl::OverrideGeolocation(const Geoposition& geoposition) { | 412 Status WebViewImpl::OverrideGeolocation(const Geoposition& geoposition) { |
| 410 return geolocation_override_manager_->OverrideGeolocation(geoposition); | 413 return geolocation_override_manager_->OverrideGeolocation(geoposition); |
| 411 } | 414 } |
| 412 | 415 |
| 416 Status WebViewImpl::OverrideNetworkConditions( |
| 417 const NetworkConditions& network_conditions) { |
| 418 return network_conditions_override_manager_->OverrideNetworkConditions( |
| 419 network_conditions); |
| 420 } |
| 421 |
| 413 Status WebViewImpl::CaptureScreenshot(std::string* screenshot) { | 422 Status WebViewImpl::CaptureScreenshot(std::string* screenshot) { |
| 414 base::DictionaryValue params; | 423 base::DictionaryValue params; |
| 415 scoped_ptr<base::DictionaryValue> result; | 424 scoped_ptr<base::DictionaryValue> result; |
| 416 Status status = client_->SendCommandAndGetResult( | 425 Status status = client_->SendCommandAndGetResult( |
| 417 "Page.captureScreenshot", params, &result); | 426 "Page.captureScreenshot", params, &result); |
| 418 if (status.IsError()) | 427 if (status.IsError()) |
| 419 return status; | 428 return status; |
| 420 if (!result->GetString("data", screenshot)) | 429 if (!result->GetString("data", screenshot)) |
| 421 return Status(kUnknownError, "expected string 'data' in response"); | 430 return Status(kUnknownError, "expected string 'data' in response"); |
| 422 return Status(kOk); | 431 return Status(kOk); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 if (status.IsError()) | 770 if (status.IsError()) |
| 762 return status; | 771 return status; |
| 763 | 772 |
| 764 if (!cmd_result->GetInteger("nodeId", node_id)) | 773 if (!cmd_result->GetInteger("nodeId", node_id)) |
| 765 return Status(kUnknownError, "DOM.requestNode missing int 'nodeId'"); | 774 return Status(kUnknownError, "DOM.requestNode missing int 'nodeId'"); |
| 766 *found_node = true; | 775 *found_node = true; |
| 767 return Status(kOk); | 776 return Status(kOk); |
| 768 } | 777 } |
| 769 | 778 |
| 770 } // namespace internal | 779 } // namespace internal |
| OLD | NEW |