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

Unified Diff: chrome/test/webdriver/webdriver_automation.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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/webdriver/webdriver_automation.cc
diff --git a/chrome/test/webdriver/webdriver_automation.cc b/chrome/test/webdriver/webdriver_automation.cc
index 9d218372a6866442e09f49c86c03154178602e21..4e4b8c4ac8ad8bb2f6a2e638152f8fb26a7563c8 100644
--- a/chrome/test/webdriver/webdriver_automation.cc
+++ b/chrome/test/webdriver/webdriver_automation.cc
@@ -687,11 +687,62 @@ void Automation::WaitForAllTabsToStopLoading(Error** error) {
*error = new Error(kUnknownError, error_msg);
}
-void Automation::InstallExtension(const FilePath& path, Error** error) {
+void Automation::InstallExtensionDeprecated(
+ const FilePath& path, Error** error) {
if (!launcher_->automation()->InstallExtension(path, false).get())
*error = new Error(kUnknownError, "Failed to install extension");
}
+void Automation::GetInstalledExtensions(
+ std::vector<std::string>* extension_ids, Error** error) {
+ *error = CheckNewExtensionInterfaceSupported();
+ if (*error)
+ return;
+
+ std::string error_msg;
+ base::ListValue extensions_list;
+ if (!SendGetExtensionsInfoJSONRequest(
+ automation(), &extensions_list, &error_msg)) {
+ *error = new Error(kUnknownError, error_msg);
+ return;
+ }
+
+ for (size_t i = 0; i < extensions_list.GetSize(); i++) {
+ DictionaryValue* extension_dict;
+ if (!extensions_list.GetDictionary(i, &extension_dict)) {
+ *error = new Error(kUnknownError, "Invalid extension dictionary");
+ return;
+ }
+ bool is_component;
+ if (!extension_dict->GetBoolean("is_component_extension", &is_component)) {
+ *error = new Error(kUnknownError,
+ "Missing or invalid 'is_component_extension'");
+ return;
+ }
+ if (is_component)
+ continue;
+
+ std::string extension_id;
+ if (!extension_dict->GetString("id", &extension_id)) {
+ *error = new Error(kUnknownError, "Missing or invalid 'id'");
+ return;
+ }
+ extension_ids->push_back(extension_id);
+ }
+}
+
+void Automation::InstallExtension(
+ const FilePath& path, std::string* extension_id, Error** error) {
+ *error = CheckNewExtensionInterfaceSupported();
+ if (*error)
+ return;
+
+ std::string error_msg;
+ if (!SendInstallExtensionJSONRequest(
+ automation(), path, extension_id, &error_msg))
+ *error = new Error(kUnknownError, error_msg);
+}
+
AutomationProxy* Automation::automation() const {
return launcher_->automation();
}
@@ -755,4 +806,10 @@ Error* Automation::CheckAdvancedInteractionsSupported() {
return CheckVersion(750, 0, message);
}
+Error* Automation::CheckNewExtensionInterfaceSupported() {
+ const char* message =
+ "Extension interface is not supported for this version of Chrome";
+ return CheckVersion(947, 0, message);
+}
+
} // namespace webdriver

Powered by Google App Engine
This is Rietveld 408576698