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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/webdriver/webdriver_automation.h" 5 #include "chrome/test/webdriver/webdriver_automation.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 if (!SendGetChromeDriverAutomationVersion(automation(), version, &error_msg)) 680 if (!SendGetChromeDriverAutomationVersion(automation(), version, &error_msg))
681 *error = new Error(kUnknownError, error_msg); 681 *error = new Error(kUnknownError, error_msg);
682 } 682 }
683 683
684 void Automation::WaitForAllTabsToStopLoading(Error** error) { 684 void Automation::WaitForAllTabsToStopLoading(Error** error) {
685 std::string error_msg; 685 std::string error_msg;
686 if (!SendWaitForAllTabsToStopLoadingJSONRequest(automation(), &error_msg)) 686 if (!SendWaitForAllTabsToStopLoadingJSONRequest(automation(), &error_msg))
687 *error = new Error(kUnknownError, error_msg); 687 *error = new Error(kUnknownError, error_msg);
688 } 688 }
689 689
690 void Automation::InstallExtension(const FilePath& path, Error** error) { 690 void Automation::InstallExtensionDeprecated(
691 const FilePath& path, Error** error) {
691 if (!launcher_->automation()->InstallExtension(path, false).get()) 692 if (!launcher_->automation()->InstallExtension(path, false).get())
692 *error = new Error(kUnknownError, "Failed to install extension"); 693 *error = new Error(kUnknownError, "Failed to install extension");
693 } 694 }
694 695
696 void Automation::GetInstalledExtensions(
697 std::vector<std::string>* extension_ids, Error** error) {
698 *error = CheckNewExtensionInterfaceSupported();
699 if (*error)
700 return;
701
702 std::string error_msg;
703 base::ListValue extensions_list;
704 if (!SendGetExtensionsInfoJSONRequest(
705 automation(), &extensions_list, &error_msg)) {
706 *error = new Error(kUnknownError, error_msg);
707 return;
708 }
709
710 for (size_t i = 0; i < extensions_list.GetSize(); i++) {
711 DictionaryValue* extension_dict;
712 if (!extensions_list.GetDictionary(i, &extension_dict)) {
713 *error = new Error(kUnknownError, "Invalid extension dictionary");
714 return;
715 }
716 bool is_component;
717 if (!extension_dict->GetBoolean("is_component_extension", &is_component)) {
718 *error = new Error(kUnknownError,
719 "Missing or invalid 'is_component_extension'");
720 return;
721 }
722 if (is_component)
723 continue;
724
725 std::string extension_id;
726 if (!extension_dict->GetString("id", &extension_id)) {
727 *error = new Error(kUnknownError, "Missing or invalid 'id'");
728 return;
729 }
730 extension_ids->push_back(extension_id);
731 }
732 }
733
734 void Automation::InstallExtension(
735 const FilePath& path, std::string* extension_id, Error** error) {
736 *error = CheckNewExtensionInterfaceSupported();
737 if (*error)
738 return;
739
740 std::string error_msg;
741 if (!SendInstallExtensionJSONRequest(
742 automation(), path, extension_id, &error_msg))
743 *error = new Error(kUnknownError, error_msg);
744 }
745
695 AutomationProxy* Automation::automation() const { 746 AutomationProxy* Automation::automation() const {
696 return launcher_->automation(); 747 return launcher_->automation();
697 } 748 }
698 749
699 Error* Automation::GetIndicesForTab( 750 Error* Automation::GetIndicesForTab(
700 int tab_id, int* browser_index, int* tab_index) { 751 int tab_id, int* browser_index, int* tab_index) {
701 std::string error_msg; 752 std::string error_msg;
702 if (!SendGetIndicesFromTabIdJSONRequest( 753 if (!SendGetIndicesFromTabIdJSONRequest(
703 automation(), tab_id, browser_index, tab_index, &error_msg)) { 754 automation(), tab_id, browser_index, tab_index, &error_msg)) {
704 return new Error(kUnknownError, error_msg); 755 return new Error(kUnknownError, error_msg);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 return CheckVersion( 799 return CheckVersion(
749 768, 0, "Alerts are not supported for this version of Chrome"); 800 768, 0, "Alerts are not supported for this version of Chrome");
750 } 801 }
751 802
752 Error* Automation::CheckAdvancedInteractionsSupported() { 803 Error* Automation::CheckAdvancedInteractionsSupported() {
753 const char* message = 804 const char* message =
754 "Advanced user interactions are not supported for this version of Chrome"; 805 "Advanced user interactions are not supported for this version of Chrome";
755 return CheckVersion(750, 0, message); 806 return CheckVersion(750, 0, message);
756 } 807 }
757 808
809 Error* Automation::CheckNewExtensionInterfaceSupported() {
810 const char* message =
811 "Extension interface is not supported for this version of Chrome";
812 return CheckVersion(947, 0, message);
813 }
814
758 } // namespace webdriver 815 } // namespace webdriver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698