Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: chrome/test/webdriver/commands/chrome_commands.cc

Issue 8649004: Allow chromedriver to install an extension and get all installed extension IDs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/test/webdriver/commands/chrome_commands.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/file_path.h"
11 #include "chrome/test/automation/value_conversion_util.h"
12 #include "chrome/test/webdriver/commands/response.h"
13 #include "chrome/test/webdriver/webdriver_error.h"
14 #include "chrome/test/webdriver/webdriver_session.h"
15
16 namespace webdriver {
17
18 ExtensionsCommand::ExtensionsCommand(
19 const std::vector<std::string>& path_segments,
20 const base::DictionaryValue* const parameters)
21 : WebDriverCommand(path_segments, parameters) {}
22
23 ExtensionsCommand::~ExtensionsCommand() {}
24
25 bool ExtensionsCommand::DoesGet() {
26 return true;
27 }
28
29 bool ExtensionsCommand::DoesPost() {
30 return true;
31 }
32
33 void ExtensionsCommand::ExecuteGet(Response* const response) {
34 std::vector<std::string> extension_ids;
35 Error* error = session_->GetInstalledExtensions(&extension_ids);
36 if (error) {
37 response->SetError(error);
38 return;
39 }
40 base::ListValue* extensions = new base::ListValue();
41 for (size_t i = 0; i < extension_ids.size(); ++i) {
dennis_jeffrey 2011/11/22 23:32:16 nit: can remove the curly braces here
kkania 2011/11/23 17:31:23 Done.
42 extensions->Append(CreateValueFrom(extension_ids[i]));
43 }
44 response->SetValue(extensions);
45 }
46
47 void ExtensionsCommand::ExecutePost(Response* const response) {
48 FilePath::StringType path_string;
49 if (!GetStringParameter("path", &path_string)) {
50 response->SetError(new Error(kUnknownError, "'path' missing or invalid"));
51 return;
52 }
53
54 std::string extension_id;
55 Error* error = session_->InstallExtension(
56 FilePath(path_string), &extension_id);
57 if (error) {
58 response->SetError(error);
59 return;
60 }
61 response->SetValue(CreateValueFrom(extension_id));
62 }
63
64 } // namespace webdriver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698