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

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc

Issue 916243002: Enable keyboard shortcuts for chrome://extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applied Feedback Created 5 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/ui/webui/extensions/extension_settings_browsertest.h" 5 #include "chrome/browser/ui/webui/extensions/extension_settings_browsertest.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 void ExtensionSettingsUIBrowserTest::InstallGoodExtension() { 55 void ExtensionSettingsUIBrowserTest::InstallGoodExtension() {
56 base::FilePath test_data_dir; 56 base::FilePath test_data_dir;
57 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)) { 57 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)) {
58 ADD_FAILURE(); 58 ADD_FAILURE();
59 return; 59 return;
60 } 60 }
61 base::FilePath extensions_data_dir = test_data_dir.AppendASCII("extensions"); 61 base::FilePath extensions_data_dir = test_data_dir.AppendASCII("extensions");
62 InstallExtension(extensions_data_dir.AppendASCII("good.crx")); 62 InstallExtension(extensions_data_dir.AppendASCII("good.crx"));
63 } 63 }
64 64
65 void ExtensionSettingsUIBrowserTest::InstallErrorsExtension() {
66 base::FilePath test_data_dir;
67 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)) {
68 ADD_FAILURE();
69 return;
70 }
71 base::FilePath extensions_data_dir = test_data_dir.AppendASCII("extensions");
72 extensions_data_dir = extensions_data_dir.AppendASCII("error_console");
73 InstallUnpackedExtension(
74 extensions_data_dir.AppendASCII("runtime_and_manifest_errors"));
75 }
76
65 void ExtensionSettingsUIBrowserTest::AddManagedPolicyProvider() { 77 void ExtensionSettingsUIBrowserTest::AddManagedPolicyProvider() {
66 auto* extension_service = extensions::ExtensionSystem::Get(GetProfile()); 78 auto* extension_service = extensions::ExtensionSystem::Get(GetProfile());
67 extension_service->management_policy()->RegisterProvider(&policy_provider_); 79 extension_service->management_policy()->RegisterProvider(&policy_provider_);
68 } 80 }
69 81
70 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { 82 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt {
71 public: 83 public:
72 explicit MockAutoConfirmExtensionInstallPrompt( 84 explicit MockAutoConfirmExtensionInstallPrompt(
73 content::WebContents* web_contents) 85 content::WebContents* web_contents)
74 : ExtensionInstallPrompt(web_contents) {} 86 : ExtensionInstallPrompt(web_contents) {}
75 87
76 // Proceed without confirmation prompt. 88 // Proceed without confirmation prompt.
77 void ConfirmInstall(Delegate* delegate, 89 void ConfirmInstall(Delegate* delegate,
78 const Extension* extension, 90 const Extension* extension,
79 const ShowDialogCallback& show_dialog_callback) override { 91 const ShowDialogCallback& show_dialog_callback) override {
80 delegate->InstallUIProceed(); 92 delegate->InstallUIProceed();
81 } 93 }
82 }; 94 };
83 95
96 void ExtensionSettingsUIBrowserTest::InstallUnpackedExtension(
97 const base::FilePath& path) {
98 ExtensionService* service =
99 extensions::ExtensionSystem::Get(this->GetProfile())->extension_service();
Dan Beam 2015/02/21 00:26:10 this->GetProfile() should be just GetProfile()
hcarmona 2015/02/23 22:25:08 Done. Too used to JS
100 extensions::UnpackedInstaller::Create(service)->Load(path);
101 }
102
84 const Extension* ExtensionSettingsUIBrowserTest::InstallExtension( 103 const Extension* ExtensionSettingsUIBrowserTest::InstallExtension(
85 const base::FilePath& path) { 104 const base::FilePath& path) {
86 Profile* profile = this->GetProfile(); 105 Profile* profile = this->GetProfile();
87 ExtensionService* service = 106 ExtensionService* service =
88 extensions::ExtensionSystem::Get(profile)->extension_service(); 107 extensions::ExtensionSystem::Get(profile)->extension_service();
89 extensions::ExtensionRegistry* registry = 108 extensions::ExtensionRegistry* registry =
90 extensions::ExtensionRegistry::Get(profile); 109 extensions::ExtensionRegistry::Get(profile);
91 service->set_show_extensions_prompts(false); 110 service->set_show_extensions_prompts(false);
92 size_t num_before = registry->enabled_extensions().size(); 111 size_t num_before = registry->enabled_extensions().size();
93 { 112 {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 iter != errors->end(); ++iter) 154 iter != errors->end(); ++iter)
136 VLOG(1) << *iter; 155 VLOG(1) << *iter;
137 156
138 return NULL; 157 return NULL;
139 } 158 }
140 159
141 if (!observer_->WaitForExtensionViewsToLoad()) 160 if (!observer_->WaitForExtensionViewsToLoad())
142 return NULL; 161 return NULL;
143 return service->GetExtensionById(last_loaded_extension_id(), false); 162 return service->GetExtensionById(last_loaded_extension_id(), false);
144 } 163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698