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

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

Issue 1527043002: [Extensions] Don't use ExtensionInstallPrompt subclasses for auto-confirmation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years 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
« no previous file with comments | « chrome/browser/extensions/webstore_inline_installer_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 extensions::FeatureSwitch::error_console(), true)); 107 extensions::FeatureSwitch::error_console(), true));
108 } 108 }
109 109
110 void ExtensionSettingsUIBrowserTest::ShrinkWebContentsView() { 110 void ExtensionSettingsUIBrowserTest::ShrinkWebContentsView() {
111 content::WebContents* web_contents = 111 content::WebContents* web_contents =
112 browser()->tab_strip_model()->GetActiveWebContents(); 112 browser()->tab_strip_model()->GetActiveWebContents();
113 CHECK(web_contents); 113 CHECK(web_contents);
114 ResizeWebContents(web_contents, gfx::Size(400, 400)); 114 ResizeWebContents(web_contents, gfx::Size(400, 400));
115 } 115 }
116 116
117 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt {
118 public:
119 explicit MockAutoConfirmExtensionInstallPrompt(
120 content::WebContents* web_contents)
121 : ExtensionInstallPrompt(web_contents) {}
122
123 // Proceed without confirmation prompt.
124 void ShowDialog(Delegate* delegate,
125 const Extension* extension,
126 const SkBitmap* icon,
127 const ShowDialogCallback& show_dialog_callback) override {
128 delegate->InstallUIProceed();
129 }
130 };
131
132 const Extension* ExtensionSettingsUIBrowserTest::InstallUnpackedExtension( 117 const Extension* ExtensionSettingsUIBrowserTest::InstallUnpackedExtension(
133 const base::FilePath& path) { 118 const base::FilePath& path) {
134 if (path.empty()) 119 if (path.empty())
135 return nullptr; 120 return nullptr;
136 121
137 Profile* profile = GetProfile(); 122 Profile* profile = GetProfile();
138 ExtensionService* service = 123 ExtensionService* service =
139 extensions::ExtensionSystem::Get(profile)->extension_service(); 124 extensions::ExtensionSystem::Get(profile)->extension_service();
140 service->set_show_extensions_prompts(false); 125 service->set_show_extensions_prompts(false);
141 extensions::ExtensionRegistry* registry = 126 extensions::ExtensionRegistry* registry =
(...skipping 12 matching lines...) Expand all
154 const Extension* ExtensionSettingsUIBrowserTest::InstallExtension( 139 const Extension* ExtensionSettingsUIBrowserTest::InstallExtension(
155 const base::FilePath& path) { 140 const base::FilePath& path) {
156 Profile* profile = GetProfile(); 141 Profile* profile = GetProfile();
157 ExtensionService* service = 142 ExtensionService* service =
158 extensions::ExtensionSystem::Get(profile)->extension_service(); 143 extensions::ExtensionSystem::Get(profile)->extension_service();
159 extensions::ExtensionRegistry* registry = 144 extensions::ExtensionRegistry* registry =
160 extensions::ExtensionRegistry::Get(profile); 145 extensions::ExtensionRegistry::Get(profile);
161 service->set_show_extensions_prompts(false); 146 service->set_show_extensions_prompts(false);
162 size_t num_before = registry->enabled_extensions().size(); 147 size_t num_before = registry->enabled_extensions().size();
163 { 148 {
164 scoped_ptr<ExtensionInstallPrompt> install_ui; 149 extensions::ScopedTestDialogAutoConfirm auto_confirm(
165 install_ui.reset(new MockAutoConfirmExtensionInstallPrompt( 150 extensions::ScopedTestDialogAutoConfirm::ACCEPT);
166 browser()->tab_strip_model()->GetActiveWebContents())); 151 scoped_ptr<ExtensionInstallPrompt> install_ui(
152 new ExtensionInstallPrompt(
153 browser()->tab_strip_model()->GetActiveWebContents()));
167 154
168 base::FilePath crx_path = path; 155 base::FilePath crx_path = path;
169 DCHECK(crx_path.Extension() == FILE_PATH_LITERAL(".crx")); 156 DCHECK(crx_path.Extension() == FILE_PATH_LITERAL(".crx"));
170 if (crx_path.empty()) 157 if (crx_path.empty())
171 return nullptr; 158 return nullptr;
172 159
173 scoped_refptr<extensions::CrxInstaller> installer( 160 scoped_refptr<extensions::CrxInstaller> installer(
174 extensions::CrxInstaller::Create(service, install_ui.Pass())); 161 extensions::CrxInstaller::Create(service, install_ui.Pass()));
175 installer->set_expected_id(std::string()); 162 installer->set_expected_id(std::string());
176 installer->set_is_gallery_install(false); 163 installer->set_is_gallery_install(false);
(...skipping 28 matching lines...) Expand all
205 iter != errors->end(); ++iter) 192 iter != errors->end(); ++iter)
206 VLOG(1) << *iter; 193 VLOG(1) << *iter;
207 194
208 return nullptr; 195 return nullptr;
209 } 196 }
210 197
211 if (!observer_->WaitForExtensionViewsToLoad()) 198 if (!observer_->WaitForExtensionViewsToLoad())
212 return nullptr; 199 return nullptr;
213 return service->GetExtensionById(last_loaded_extension_id(), false); 200 return service->GetExtensionById(last_loaded_extension_id(), false);
214 } 201 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/webstore_inline_installer_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698