| OLD | NEW |
| 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 #include "chrome/test/automation/extension_proxy.h" | 5 #include "chrome/test/automation/extension_proxy.h" |
| 6 | 6 |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "chrome/common/automation_messages.h" | 8 #include "chrome/common/automation_messages.h" |
| 9 #include "chrome/test/automation/automation_proxy.h" | 9 #include "chrome/test/automation/automation_proxy.h" |
| 10 #include "chrome/test/automation/browser_proxy.h" | 10 #include "chrome/test/automation/browser_proxy.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 ExtensionProxy::ExtensionProxy(AutomationMessageSender* sender, | 13 ExtensionProxy::ExtensionProxy(AutomationMessageSender* sender, |
| 14 AutomationHandleTracker* tracker, | 14 AutomationHandleTracker* tracker, |
| 15 int handle) | 15 int handle) |
| 16 : AutomationResourceProxy(tracker, sender, handle) { | 16 : AutomationResourceProxy(tracker, sender, handle) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 bool ExtensionProxy::Uninstall() { | 19 bool ExtensionProxy::Uninstall() { |
| 20 if (!is_valid()) | 20 if (!is_valid()) |
| 21 return false; | 21 return false; |
| 22 | 22 |
| 23 bool success = false; | 23 bool success = false; |
| 24 if (!sender_->Send(new AutomationMsg_UninstallExtension(0, handle_, | 24 if (!sender_->Send(new AutomationMsg_UninstallExtension(handle_, &success))) |
| 25 &success))) | |
| 26 return false; | 25 return false; |
| 27 return success; | 26 return success; |
| 28 } | 27 } |
| 29 | 28 |
| 30 bool ExtensionProxy::Enable() { | 29 bool ExtensionProxy::Enable() { |
| 31 if (!is_valid()) | 30 if (!is_valid()) |
| 32 return false; | 31 return false; |
| 33 | 32 |
| 34 bool success = false; | 33 bool success = false; |
| 35 if (!sender_->Send(new AutomationMsg_EnableExtension(0, handle_, | 34 if (!sender_->Send(new AutomationMsg_EnableExtension(handle_, &success))) |
| 36 &success))) | |
| 37 return false; | 35 return false; |
| 38 return success; | 36 return success; |
| 39 } | 37 } |
| 40 | 38 |
| 41 bool ExtensionProxy::Disable() { | 39 bool ExtensionProxy::Disable() { |
| 42 if (!is_valid()) | 40 if (!is_valid()) |
| 43 return false; | 41 return false; |
| 44 | 42 |
| 45 bool success = false; | 43 bool success = false; |
| 46 if (!sender_->Send(new AutomationMsg_DisableExtension(0, handle_, | 44 if (!sender_->Send(new AutomationMsg_DisableExtension(handle_, &success))) |
| 47 &success))) | |
| 48 return false; | 45 return false; |
| 49 return success; | 46 return success; |
| 50 } | 47 } |
| 51 | 48 |
| 52 bool ExtensionProxy::ExecuteActionInActiveTabAsync(BrowserProxy* browser) { | 49 bool ExtensionProxy::ExecuteActionInActiveTabAsync(BrowserProxy* browser) { |
| 53 if (!is_valid()) | 50 if (!is_valid()) |
| 54 return false; | 51 return false; |
| 55 | 52 |
| 56 bool success = false; | 53 bool success = false; |
| 57 if (!sender_->Send(new AutomationMsg_ExecuteExtensionActionInActiveTabAsync( | 54 if (!sender_->Send(new AutomationMsg_ExecuteExtensionActionInActiveTabAsync( |
| 58 0, handle_, browser->handle(), &success))) | 55 handle_, browser->handle(), &success))) |
| 59 return false; | 56 return false; |
| 60 return success; | 57 return success; |
| 61 } | 58 } |
| 62 | 59 |
| 63 bool ExtensionProxy::MoveBrowserAction(int index) { | 60 bool ExtensionProxy::MoveBrowserAction(int index) { |
| 64 if (!is_valid()) | 61 if (!is_valid()) |
| 65 return false; | 62 return false; |
| 66 bool success = false; | 63 bool success = false; |
| 67 if (!sender_->Send( | 64 if (!sender_->Send( |
| 68 new AutomationMsg_MoveExtensionBrowserAction(0, handle_, index, | 65 new AutomationMsg_MoveExtensionBrowserAction(handle_, index, &success))) |
| 69 &success))) | |
| 70 return false; | 66 return false; |
| 71 return success; | 67 return success; |
| 72 } | 68 } |
| 73 | 69 |
| 74 bool ExtensionProxy::GetId(std::string* id) { | 70 bool ExtensionProxy::GetId(std::string* id) { |
| 75 DCHECK(id); | 71 DCHECK(id); |
| 76 return GetProperty(AUTOMATION_MSG_EXTENSION_ID, id); | 72 return GetProperty(AUTOMATION_MSG_EXTENSION_ID, id); |
| 77 } | 73 } |
| 78 | 74 |
| 79 bool ExtensionProxy::GetName(std::string* name) { | 75 bool ExtensionProxy::GetName(std::string* name) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 ASSERT_EQ(expected_index, index); | 124 ASSERT_EQ(expected_index, index); |
| 129 } | 125 } |
| 130 | 126 |
| 131 bool ExtensionProxy::GetProperty(AutomationMsg_ExtensionProperty type, | 127 bool ExtensionProxy::GetProperty(AutomationMsg_ExtensionProperty type, |
| 132 std::string* value) { | 128 std::string* value) { |
| 133 DCHECK(value); | 129 DCHECK(value); |
| 134 if (!is_valid()) | 130 if (!is_valid()) |
| 135 return false; | 131 return false; |
| 136 | 132 |
| 137 bool success = false; | 133 bool success = false; |
| 138 if (!sender_->Send(new AutomationMsg_GetExtensionProperty(0, handle_, type, | 134 if (!sender_->Send(new AutomationMsg_GetExtensionProperty(handle_, type, |
| 139 &success, value))) | 135 &success, value))) |
| 140 return false; | 136 return false; |
| 141 return success; | 137 return success; |
| 142 } | 138 } |
| OLD | NEW |