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/session_commands.h" | 5 #include "chrome/test/chromedriver/session_commands.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 if (chrome->GetAsDesktop()) { | 92 if (chrome->GetAsDesktop()) { |
| 93 chrome_caps->SetString( | 93 chrome_caps->SetString( |
| 94 "userDataDir", | 94 "userDataDir", |
| 95 chrome->GetAsDesktop()->command().GetSwitchValueNative( | 95 chrome->GetAsDesktop()->command().GetSwitchValueNative( |
| 96 "user-data-dir")); | 96 "user-data-dir")); |
| 97 } | 97 } |
| 98 caps->Set("chrome", chrome_caps.release()); | 98 caps->Set("chrome", chrome_caps.release()); |
| 99 return caps.Pass(); | 99 return caps.Pass(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 Status InitDeviceMetricsOverride( | |
| 103 Session* session, | |
| 104 DeviceMetrics* device_metrics) | |
| 105 { | |
| 106 WebView* web_view; | |
| 107 session->chrome->GetWebViewById(session->window, &web_view); | |
| 108 Status status = web_view->OverrideDeviceMetrics(*device_metrics); | |
| 109 if (status.IsOk()) | |
| 110 session->overridden_device_metrics.reset(new DeviceMetrics(*device_metrics)) ; | |
| 111 return status; | |
| 112 } | |
| 102 | 113 |
| 103 Status InitSessionHelper( | 114 Status InitSessionHelper( |
| 104 const InitSessionParams& bound_params, | 115 const InitSessionParams& bound_params, |
| 105 Session* session, | 116 Session* session, |
| 106 const base::DictionaryValue& params, | 117 const base::DictionaryValue& params, |
| 107 scoped_ptr<base::Value>* value) { | 118 scoped_ptr<base::Value>* value) { |
| 108 session->driver_log.reset( | 119 session->driver_log.reset( |
| 109 new WebDriverLog(WebDriverLog::kDriverType, Log::kAll)); | 120 new WebDriverLog(WebDriverLog::kDriverType, Log::kAll)); |
| 110 const base::DictionaryValue* desired_caps; | 121 const base::DictionaryValue* desired_caps; |
| 111 if (!params.GetDictionary("desiredCapabilities", &desired_caps)) | 122 if (!params.GetDictionary("desiredCapabilities", &desired_caps)) |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 142 return status; | 153 return status; |
| 143 | 154 |
| 144 std::list<std::string> web_view_ids; | 155 std::list<std::string> web_view_ids; |
| 145 status = session->chrome->GetWebViewIds(&web_view_ids); | 156 status = session->chrome->GetWebViewIds(&web_view_ids); |
| 146 if (status.IsError() || web_view_ids.empty()) { | 157 if (status.IsError() || web_view_ids.empty()) { |
| 147 return status.IsError() ? status : | 158 return status.IsError() ? status : |
| 148 Status(kUnknownError, "unable to discover open window in chrome"); | 159 Status(kUnknownError, "unable to discover open window in chrome"); |
| 149 } | 160 } |
| 150 | 161 |
| 151 session->window = web_view_ids.front(); | 162 session->window = web_view_ids.front(); |
| 163 | |
| 164 if (capabilities.device_metrics.width != 0) { | |
|
stgao
2014/05/03 00:15:20
Instead of creating an instance of struct |device_
sam.rawlins
2014/05/06 23:51:46
Done.
| |
| 165 InitDeviceMetricsOverride(session, &capabilities.device_metrics); | |
| 166 } | |
| 167 | |
| 152 session->detach = capabilities.detach; | 168 session->detach = capabilities.detach; |
| 153 session->force_devtools_screenshot = capabilities.force_devtools_screenshot; | 169 session->force_devtools_screenshot = capabilities.force_devtools_screenshot; |
| 154 session->capabilities = CreateCapabilities(session->chrome.get()); | 170 session->capabilities = CreateCapabilities(session->chrome.get()); |
| 155 value->reset(session->capabilities->DeepCopy()); | 171 value->reset(session->capabilities->DeepCopy()); |
| 156 return Status(kOk); | 172 return Status(kOk); |
| 157 } | 173 } |
| 158 | 174 |
| 159 } // namespace | 175 } // namespace |
| 160 | 176 |
| 161 Status ExecuteInitSession( | 177 Status ExecuteInitSession( |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 644 Status ExecuteSetAutoReporting( | 660 Status ExecuteSetAutoReporting( |
| 645 Session* session, | 661 Session* session, |
| 646 const base::DictionaryValue& params, | 662 const base::DictionaryValue& params, |
| 647 scoped_ptr<base::Value>* value) { | 663 scoped_ptr<base::Value>* value) { |
| 648 bool enabled; | 664 bool enabled; |
| 649 if (!params.GetBoolean("enabled", &enabled)) | 665 if (!params.GetBoolean("enabled", &enabled)) |
| 650 return Status(kUnknownError, "missing parameter 'enabled'"); | 666 return Status(kUnknownError, "missing parameter 'enabled'"); |
| 651 session->auto_reporting_enabled = enabled; | 667 session->auto_reporting_enabled = enabled; |
| 652 return Status(kOk); | 668 return Status(kOk); |
| 653 } | 669 } |
| OLD | NEW |