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

Side by Side Diff: chrome/browser/automation/automation_provider_json.h

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 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
« no previous file with comments | « no previous file | chrome/browser/automation/automation_provider_json.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // Support utilities for the JSON automation interface used by PyAuto. 5 // Support utilities for the JSON automation interface used by PyAuto.
6 6
7 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_JSON_H_ 7 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_JSON_H_
8 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_JSON_H_ 8 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_JSON_H_
9 #pragma once 9 #pragma once
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 14
15 class AutomationProvider; 15 class AutomationProvider;
16 class Browser; 16 class Browser;
17 class Extension;
18 class Profile;
19 class RenderViewHost;
17 class TabContents; 20 class TabContents;
21 class TabContentsWrapper;
18 22
19 namespace base { 23 namespace base {
20 class DictionaryValue; 24 class DictionaryValue;
21 class Value; 25 class Value;
22 } 26 }
23 27
24 namespace IPC { 28 namespace IPC {
25 class Message; 29 class Message;
26 } 30 }
27 31
(...skipping 13 matching lines...) Expand all
41 void SendSuccess(const base::Value* value); 45 void SendSuccess(const base::Value* value);
42 46
43 // Send an error reply along with error message |error_message|. 47 // Send an error reply along with error message |error_message|.
44 void SendError(const std::string& error_message); 48 void SendError(const std::string& error_message);
45 49
46 private: 50 private:
47 AutomationProvider* provider_; 51 AutomationProvider* provider_;
48 IPC::Message* message_; 52 IPC::Message* message_;
49 }; 53 };
50 54
55 // A unique ID that automation clients can use to refer to browser entities.
56 // The ID contains its type so that:
57 // 1) supplying an ID of the wrong type can be detected
58 // 2) the client does not have to explicitly supply the type in case multiple
59 // ID types can be accepted (e.g., can use a tab ID or extension popup ID for
60 // executing javascript).
61 class AutomationId {
62 public:
63 // This order should be preserved.
64 enum Type {
65 kInvalidType = -1,
66 kTypeTab = 0,
67 kTypeExtensionPopup
68 };
69
70 static bool FromValue(
71 base::Value* value, AutomationId* id, std::string* error);
72
73 AutomationId();
74 AutomationId(Type type, const std::string& id);
75
76 base::Value* ToValue() const;
77
78 bool is_valid() const;
79 Type type() const;
80 const std::string& id() const;
81
82 private:
83 Type type_;
84 std::string id_;
85 };
86
51 // Gets the browser specified by the given dictionary |args|. |args| should 87 // Gets the browser specified by the given dictionary |args|. |args| should
52 // contain a key 'windex' which refers to the index of the browser. Returns 88 // contain a key 'windex' which refers to the index of the browser. Returns
53 // true on success and sets |browser|. Otherwise, |error| will be set. 89 // true on success and sets |browser|. Otherwise, |error| will be set.
54 bool GetBrowserFromJSONArgs(base::DictionaryValue* args, 90 bool GetBrowserFromJSONArgs(base::DictionaryValue* args,
55 Browser** browser, 91 Browser** browser,
56 std::string* error) WARN_UNUSED_RESULT; 92 std::string* error) WARN_UNUSED_RESULT;
57 93
58 // Gets the tab specified by the given dictionary |args|. |args| should 94 // Gets the tab specified by the given dictionary |args|. |args| should
59 // contain a key 'windex' which refers to the index of the parent browser, 95 // contain a key 'windex' which refers to the index of the parent browser,
60 // and a key 'tab_index' which refers to the index of the tab in that browser. 96 // and a key 'tab_index' which refers to the index of the tab in that browser.
61 // Returns true on success and sets |tab|. Otherwise, |error| will be set. 97 // Returns true on success and sets |tab|. Otherwise, |error| will be set.
62 bool GetTabFromJSONArgs(base::DictionaryValue* args, 98 bool GetTabFromJSONArgs(base::DictionaryValue* args,
63 TabContents** tab, 99 TabContents** tab,
64 std::string* error) WARN_UNUSED_RESULT; 100 std::string* error) WARN_UNUSED_RESULT;
65 101
66 // Gets the browser and tab specified by the given dictionary |args|. |args| 102 // Gets the browser and tab specified by the given dictionary |args|. |args|
67 // should contain a key 'windex' which refers to the index of the browser and 103 // should contain a key 'windex' which refers to the index of the browser and
68 // a key 'tab_index' which refers to the index of the tab in that browser. 104 // a key 'tab_index' which refers to the index of the tab in that browser.
69 // Returns true on success and sets |browser| and |tab|. Otherwise, |error| 105 // Returns true on success and sets |browser| and |tab|. Otherwise, |error|
70 // will be set. 106 // will be set.
71 bool GetBrowserAndTabFromJSONArgs(base::DictionaryValue* args, 107 bool GetBrowserAndTabFromJSONArgs(base::DictionaryValue* args,
72 Browser** browser, 108 Browser** browser,
73 TabContents** tab, 109 TabContents** tab,
74 std::string* error) WARN_UNUSED_RESULT; 110 std::string* error) WARN_UNUSED_RESULT;
75 111
112 bool GetAutomationIdFromJSONArgs(
113 base::DictionaryValue* args,
114 AutomationId* id,
115 std::string* error) WARN_UNUSED_RESULT;
116
117 bool GetRenderViewFromJSONArgs(
118 base::DictionaryValue* args,
119 Profile* profile,
120 RenderViewHost** rvh,
121 std::string* error) WARN_UNUSED_RESULT;
122
76 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_JSON_H_ 123 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_JSON_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/automation/automation_provider_json.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698