OLD | NEW |
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/browser/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 public: | 207 public: |
208 explicit MockAutoConfirmExtensionInstallUI(Profile* profile) : | 208 explicit MockAutoConfirmExtensionInstallUI(Profile* profile) : |
209 ExtensionInstallUI(profile) {} | 209 ExtensionInstallUI(profile) {} |
210 | 210 |
211 // Proceed without confirmation prompt. | 211 // Proceed without confirmation prompt. |
212 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 212 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { |
213 delegate->InstallUIProceed(); | 213 delegate->InstallUIProceed(); |
214 } | 214 } |
215 }; | 215 }; |
216 | 216 |
| 217 bool ExtensionBrowserTest::InstallExtensionFromWebstore(const FilePath& path, |
| 218 int expected_change) { |
| 219 return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_NONE, |
| 220 expected_change, browser()->profile(), |
| 221 true); |
| 222 } |
| 223 |
217 bool ExtensionBrowserTest::InstallOrUpdateExtension(const std::string& id, | 224 bool ExtensionBrowserTest::InstallOrUpdateExtension(const std::string& id, |
218 const FilePath& path, | 225 const FilePath& path, |
219 InstallUIType ui_type, | 226 InstallUIType ui_type, |
220 int expected_change) { | 227 int expected_change) { |
221 return InstallOrUpdateExtension(id, path, ui_type, expected_change, | 228 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
222 browser()->profile()); | 229 browser()->profile(), false); |
223 } | 230 } |
224 | 231 |
225 bool ExtensionBrowserTest::InstallOrUpdateExtension(const std::string& id, | 232 bool ExtensionBrowserTest::InstallOrUpdateExtension(const std::string& id, |
226 const FilePath& path, | 233 const FilePath& path, |
227 InstallUIType ui_type, | 234 InstallUIType ui_type, |
228 int expected_change, | 235 int expected_change, |
229 Profile* profile) { | 236 Profile* profile, |
| 237 bool from_webstore) { |
230 ExtensionService* service = profile->GetExtensionService(); | 238 ExtensionService* service = profile->GetExtensionService(); |
231 service->set_show_extensions_prompts(false); | 239 service->set_show_extensions_prompts(false); |
232 size_t num_before = service->extensions()->size(); | 240 size_t num_before = service->extensions()->size(); |
233 | 241 |
234 { | 242 { |
235 NotificationRegistrar registrar; | 243 NotificationRegistrar registrar; |
236 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 244 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
237 NotificationService::AllSources()); | 245 NotificationService::AllSources()); |
238 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 246 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
239 NotificationService::AllSources()); | 247 NotificationService::AllSources()); |
(...skipping 13 matching lines...) Expand all Loading... |
253 FilePath crx_path = path; | 261 FilePath crx_path = path; |
254 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { | 262 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { |
255 crx_path = PackExtension(path); | 263 crx_path = PackExtension(path); |
256 } | 264 } |
257 if (crx_path.empty()) | 265 if (crx_path.empty()) |
258 return false; | 266 return false; |
259 | 267 |
260 scoped_refptr<CrxInstaller> installer( | 268 scoped_refptr<CrxInstaller> installer( |
261 service->MakeCrxInstaller(install_ui)); | 269 service->MakeCrxInstaller(install_ui)); |
262 installer->set_expected_id(id); | 270 installer->set_expected_id(id); |
| 271 installer->set_is_gallery_install(from_webstore); |
263 installer->InstallCrx(crx_path); | 272 installer->InstallCrx(crx_path); |
264 | 273 |
265 ui_test_utils::RunMessageLoop(); | 274 ui_test_utils::RunMessageLoop(); |
266 } | 275 } |
267 | 276 |
268 size_t num_after = service->extensions()->size(); | 277 size_t num_after = service->extensions()->size(); |
269 if (num_after != (num_before + expected_change)) { | 278 if (num_after != (num_before + expected_change)) { |
270 VLOG(1) << "Num extensions before: " << base::IntToString(num_before) | 279 VLOG(1) << "Num extensions before: " << base::IntToString(num_before) |
271 << " num after: " << base::IntToString(num_after) | 280 << " num after: " << base::IntToString(num_after) |
272 << " Installed extensions follow:"; | 281 << " Installed extensions follow:"; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 MessageLoopForUI::current()->Quit(); | 474 MessageLoopForUI::current()->Quit(); |
466 } | 475 } |
467 break; | 476 break; |
468 } | 477 } |
469 | 478 |
470 default: | 479 default: |
471 NOTREACHED(); | 480 NOTREACHED(); |
472 break; | 481 break; |
473 } | 482 } |
474 } | 483 } |
OLD | NEW |