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/automation_extension.h" | 5 #include "chrome/test/chromedriver/chrome/automation_extension.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/test/chromedriver/chrome/status.h" | 9 #include "chrome/test/chromedriver/chrome/status.h" |
10 #include "chrome/test/chromedriver/chrome/web_view.h" | 10 #include "chrome/test/chromedriver/chrome/web_view.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 update_info.SetString("state", "maximized"); | 45 update_info.SetString("state", "maximized"); |
46 return UpdateWindow(update_info); | 46 return UpdateWindow(update_info); |
47 } | 47 } |
48 | 48 |
49 Status AutomationExtension::GetWindowInfo(int* x, | 49 Status AutomationExtension::GetWindowInfo(int* x, |
50 int* y, | 50 int* y, |
51 int* width, | 51 int* width, |
52 int* height) { | 52 int* height) { |
53 base::ListValue args; | 53 base::ListValue args; |
54 scoped_ptr<base::Value> result; | 54 scoped_ptr<base::Value> result; |
55 Status status = web_view_->CallAsyncFunction( | 55 Status status = web_view_->CallAsyncFunction(std::string(), |
56 "", "getWindowInfo", args, base::TimeDelta::FromSeconds(10), &result); | 56 "getWindowInfo", |
| 57 args, |
| 58 base::TimeDelta::FromSeconds(10), |
| 59 &result); |
57 if (status.IsError()) | 60 if (status.IsError()) |
58 return status; | 61 return status; |
59 | 62 |
60 int temp_x, temp_y, temp_width, temp_height; | 63 int temp_x, temp_y, temp_width, temp_height; |
61 base::DictionaryValue* dict; | 64 base::DictionaryValue* dict; |
62 if (!result->GetAsDictionary(&dict) || | 65 if (!result->GetAsDictionary(&dict) || |
63 !dict->GetInteger("left", &temp_x) || | 66 !dict->GetInteger("left", &temp_x) || |
64 !dict->GetInteger("top", &temp_y) || | 67 !dict->GetInteger("top", &temp_y) || |
65 !dict->GetInteger("width", &temp_width) || | 68 !dict->GetInteger("width", &temp_width) || |
66 !dict->GetInteger("height", &temp_height)) { | 69 !dict->GetInteger("height", &temp_height)) { |
67 return Status(kUnknownError, "received invalid window info"); | 70 return Status(kUnknownError, "received invalid window info"); |
68 } | 71 } |
69 *x = temp_x; | 72 *x = temp_x; |
70 *y = temp_y; | 73 *y = temp_y; |
71 *width = temp_width; | 74 *width = temp_width; |
72 *height = temp_height; | 75 *height = temp_height; |
73 return Status(kOk); | 76 return Status(kOk); |
74 } | 77 } |
75 | 78 |
76 Status AutomationExtension::UpdateWindow( | 79 Status AutomationExtension::UpdateWindow( |
77 const base::DictionaryValue& update_info) { | 80 const base::DictionaryValue& update_info) { |
78 base::ListValue args; | 81 base::ListValue args; |
79 args.Append(update_info.DeepCopy()); | 82 args.Append(update_info.DeepCopy()); |
80 scoped_ptr<base::Value> result; | 83 scoped_ptr<base::Value> result; |
81 return web_view_->CallAsyncFunction( | 84 return web_view_->CallAsyncFunction(std::string(), |
82 "", "updateWindow", args, base::TimeDelta::FromSeconds(10), &result); | 85 "updateWindow", |
| 86 args, |
| 87 base::TimeDelta::FromSeconds(10), |
| 88 &result); |
83 } | 89 } |
OLD | NEW |