OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webdriver/commands/chrome_commands.h" | 5 #include "chrome/test/webdriver/commands/chrome_commands.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/stringprintf.h" |
11 #include "chrome/test/automation/value_conversion_util.h" | 12 #include "chrome/test/automation/value_conversion_util.h" |
12 #include "chrome/test/webdriver/commands/response.h" | 13 #include "chrome/test/webdriver/commands/response.h" |
13 #include "chrome/test/webdriver/webdriver_error.h" | 14 #include "chrome/test/webdriver/webdriver_error.h" |
14 #include "chrome/test/webdriver/webdriver_session.h" | 15 #include "chrome/test/webdriver/webdriver_session.h" |
15 | 16 |
16 namespace webdriver { | 17 namespace webdriver { |
17 | 18 |
18 ExtensionsCommand::ExtensionsCommand( | 19 ExtensionsCommand::ExtensionsCommand( |
19 const std::vector<std::string>& path_segments, | 20 const std::vector<std::string>& path_segments, |
20 const base::DictionaryValue* const parameters) | 21 const base::DictionaryValue* const parameters) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 std::string extension_id; | 54 std::string extension_id; |
54 Error* error = session_->InstallExtension( | 55 Error* error = session_->InstallExtension( |
55 FilePath(path_string), &extension_id); | 56 FilePath(path_string), &extension_id); |
56 if (error) { | 57 if (error) { |
57 response->SetError(error); | 58 response->SetError(error); |
58 return; | 59 return; |
59 } | 60 } |
60 response->SetValue(CreateValueFrom(extension_id)); | 61 response->SetValue(CreateValueFrom(extension_id)); |
61 } | 62 } |
62 | 63 |
| 64 ViewsCommand::ViewsCommand( |
| 65 const std::vector<std::string>& path_segments, |
| 66 const base::DictionaryValue* const parameters) |
| 67 : WebDriverCommand(path_segments, parameters) {} |
| 68 |
| 69 ViewsCommand::~ViewsCommand() {} |
| 70 |
| 71 bool ViewsCommand::DoesGet() { |
| 72 return true; |
| 73 } |
| 74 |
| 75 bool ViewsCommand::DoesPost() { |
| 76 return true; |
| 77 } |
| 78 |
| 79 void ViewsCommand::ExecuteGet(Response* const response) { |
| 80 std::vector<WebViewInfo> views; |
| 81 Error* error = session_->GetViews(&views); |
| 82 if (error) { |
| 83 response->SetError(error); |
| 84 return; |
| 85 } |
| 86 base::ListValue* views_list = new base::ListValue(); |
| 87 for (size_t i = 0; i < views.size(); ++i) { |
| 88 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 89 AutomationId& id = views[i].view_id.id.view_id; |
| 90 dict->SetString("handle", base::StringPrintf( |
| 91 "%d|%s", id.type(), id.id().c_str())); |
| 92 dict->SetInteger("type", id.type()); |
| 93 if (!views[i].extension_id.empty()) |
| 94 dict->SetString("extension_id", views[i].extension_id); |
| 95 views_list->Append(dict); |
| 96 } |
| 97 response->SetValue(views_list); |
| 98 } |
| 99 |
| 100 void ViewsCommand::ExecutePost(Response* const response) { |
| 101 /* |
| 102 Error* error = session_->SwitchToView(views, false / restrict_to_tabs /); |
| 103 if (error) { |
| 104 response->SetError(error); |
| 105 return; |
| 106 } |
| 107 */ |
| 108 } |
| 109 |
63 } // namespace webdriver | 110 } // namespace webdriver |
OLD | NEW |