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

Side by Side Diff: chrome/test/automation/extension_proxy.cc

Issue 10115018: Convert the infobars interactive_ui_test to a browser_test. Remove the ExtensionProxy class which… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 months 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/automation/extension_proxy.h"
6
7 #include "base/string_number_conversions.h"
8 #include "chrome/common/automation_messages.h"
9 #include "chrome/test/automation/automation_proxy.h"
10 #include "chrome/test/automation/browser_proxy.h"
11
12 ExtensionProxy::ExtensionProxy(AutomationMessageSender* sender,
13 AutomationHandleTracker* tracker,
14 int handle)
15 : AutomationResourceProxy(tracker, sender, handle) {
16 }
17
18 bool ExtensionProxy::Uninstall() {
19 if (!is_valid())
20 return false;
21
22 bool success = false;
23 if (!sender_->Send(new AutomationMsg_UninstallExtension(handle_, &success)))
24 return false;
25 return success;
26 }
27
28 bool ExtensionProxy::Enable() {
29 if (!is_valid())
30 return false;
31
32 bool success = false;
33 if (!sender_->Send(new AutomationMsg_EnableExtension(handle_, &success)))
34 return false;
35 return success;
36 }
37
38 bool ExtensionProxy::Disable() {
39 if (!is_valid())
40 return false;
41
42 bool success = false;
43 if (!sender_->Send(new AutomationMsg_DisableExtension(handle_, &success)))
44 return false;
45 return success;
46 }
47
48 bool ExtensionProxy::ExecuteActionInActiveTabAsync(BrowserProxy* browser) {
49 if (!is_valid())
50 return false;
51
52 bool success = false;
53 if (!sender_->Send(new AutomationMsg_ExecuteExtensionActionInActiveTabAsync(
54 handle_, browser->handle(), &success)))
55 return false;
56 return success;
57 }
58
59 bool ExtensionProxy::MoveBrowserAction(int index) {
60 if (!is_valid())
61 return false;
62 bool success = false;
63 if (!sender_->Send(
64 new AutomationMsg_MoveExtensionBrowserAction(handle_, index, &success)))
65 return false;
66 return success;
67 }
68
69 bool ExtensionProxy::GetId(std::string* id) {
70 DCHECK(id);
71 return GetProperty(AUTOMATION_MSG_EXTENSION_ID, id);
72 }
73
74 bool ExtensionProxy::GetName(std::string* name) {
75 DCHECK(name);
76 return GetProperty(AUTOMATION_MSG_EXTENSION_NAME, name);
77 }
78
79 bool ExtensionProxy::GetVersion(std::string* version) {
80 DCHECK(version);
81 return GetProperty(AUTOMATION_MSG_EXTENSION_VERSION, version);
82 }
83
84 bool ExtensionProxy::GetBrowserActionIndex(int* index) {
85 DCHECK(index);
86 std::string index_string;
87 if (!GetProperty(AUTOMATION_MSG_EXTENSION_BROWSER_ACTION_INDEX,
88 &index_string))
89 return false;
90 // Do not modify |index| until we are sure we can get the value, just to be
91 // nice to the caller.
92 int converted_index;
93 if (!base::StringToInt(index_string, &converted_index)) {
94 LOG(ERROR) << "Received index string could not be converted to int: "
95 << index_string;
96 return false;
97 }
98 *index = converted_index;
99 return true;
100 }
101
102 bool ExtensionProxy::GetProperty(AutomationMsg_ExtensionProperty type,
103 std::string* value) {
104 DCHECK(value);
105 if (!is_valid())
106 return false;
107
108 bool success = false;
109 if (!sender_->Send(new AutomationMsg_GetExtensionProperty(handle_, type,
110 &success, value)))
111 return false;
112 return success;
113 }
OLDNEW
« no previous file with comments | « chrome/test/automation/extension_proxy.h ('k') | chrome/test/automation/extension_proxy_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698