OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 MockAbortExtensionInstallPrompt() : ExtensionInstallPrompt(NULL) {} | 234 MockAbortExtensionInstallPrompt() : ExtensionInstallPrompt(NULL) {} |
235 | 235 |
236 // Simulate a user abort on an extension installation. | 236 // Simulate a user abort on an extension installation. |
237 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 237 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { |
238 delegate->InstallUIAbort(true); | 238 delegate->InstallUIAbort(true); |
239 MessageLoopForUI::current()->Quit(); | 239 MessageLoopForUI::current()->Quit(); |
240 } | 240 } |
241 | 241 |
242 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 242 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} |
243 | 243 |
244 virtual void OnInstallFailure(const CrxInstallerError& error) {} | 244 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) {} |
245 }; | 245 }; |
246 | 246 |
247 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { | 247 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { |
248 public: | 248 public: |
249 explicit MockAutoConfirmExtensionInstallPrompt(Browser* browser) : | 249 explicit MockAutoConfirmExtensionInstallPrompt(Browser* browser) : |
250 ExtensionInstallPrompt(browser) {} | 250 ExtensionInstallPrompt(browser) {} |
251 | 251 |
252 // Proceed without confirmation prompt. | 252 // Proceed without confirmation prompt. |
253 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 253 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { |
254 delegate->InstallUIProceed(); | 254 delegate->InstallUIProceed(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 293 |
294 // TODO(tessamac): Update callers to always pass an unpacked extension | 294 // TODO(tessamac): Update callers to always pass an unpacked extension |
295 // and then always pack the extension here. | 295 // and then always pack the extension here. |
296 FilePath crx_path = path; | 296 FilePath crx_path = path; |
297 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { | 297 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { |
298 crx_path = PackExtension(path); | 298 crx_path = PackExtension(path); |
299 } | 299 } |
300 if (crx_path.empty()) | 300 if (crx_path.empty()) |
301 return NULL; | 301 return NULL; |
302 | 302 |
303 scoped_refptr<CrxInstaller> installer( | 303 scoped_refptr<extensions::CrxInstaller> installer( |
304 CrxInstaller::Create(service, install_ui)); | 304 extensions::CrxInstaller::Create(service, install_ui)); |
305 installer->set_expected_id(id); | 305 installer->set_expected_id(id); |
306 installer->set_is_gallery_install(from_webstore); | 306 installer->set_is_gallery_install(from_webstore); |
307 if (!from_webstore) { | 307 if (!from_webstore) { |
308 installer->set_off_store_install_allow_reason( | 308 installer->set_off_store_install_allow_reason( |
309 CrxInstaller::OffStoreInstallAllowedInTest); | 309 extensions::CrxInstaller::OffStoreInstallAllowedInTest); |
310 } | 310 } |
311 | 311 |
312 content::NotificationRegistrar registrar; | 312 content::NotificationRegistrar registrar; |
313 registrar.Add(this, chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 313 registrar.Add(this, chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
314 content::Source<CrxInstaller>(installer.get())); | 314 content::Source<extensions::CrxInstaller>(installer.get())); |
315 | 315 |
316 installer->InstallCrx(crx_path); | 316 installer->InstallCrx(crx_path); |
317 | 317 |
318 ui_test_utils::RunMessageLoop(); | 318 ui_test_utils::RunMessageLoop(); |
319 } | 319 } |
320 | 320 |
321 size_t num_after = service->extensions()->size(); | 321 size_t num_after = service->extensions()->size(); |
322 EXPECT_EQ(num_before + expected_change, num_after); | 322 EXPECT_EQ(num_before + expected_change, num_after); |
323 if (num_before + expected_change != num_after) { | 323 if (num_before + expected_change != num_after) { |
324 VLOG(1) << "Num extensions before: " << base::IntToString(num_before) | 324 VLOG(1) << "Num extensions before: " << base::IntToString(num_before) |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 case content::NOTIFICATION_LOAD_STOP: | 620 case content::NOTIFICATION_LOAD_STOP: |
621 VLOG(1) << "Got LOAD_STOP notification."; | 621 VLOG(1) << "Got LOAD_STOP notification."; |
622 MessageLoopForUI::current()->Quit(); | 622 MessageLoopForUI::current()->Quit(); |
623 break; | 623 break; |
624 | 624 |
625 default: | 625 default: |
626 NOTREACHED(); | 626 NOTREACHED(); |
627 break; | 627 break; |
628 } | 628 } |
629 } | 629 } |
OLD | NEW |