| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 virtual void ConfirmInstall(Delegate* delegate, Extension* extension) { | 90 virtual void ConfirmInstall(Delegate* delegate, Extension* extension) { |
| 91 delegate->InstallUIAbort(); | 91 delegate->InstallUIAbort(); |
| 92 MessageLoopForUI::current()->Quit(); | 92 MessageLoopForUI::current()->Quit(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 virtual void ConfirmUninstall(Delegate* delegate, Extension* extension) {} | 95 virtual void ConfirmUninstall(Delegate* delegate, Extension* extension) {} |
| 96 | 96 |
| 97 virtual void OnInstallSuccess(Extension* extension) {} | 97 virtual void OnInstallSuccess(Extension* extension) {} |
| 98 | 98 |
| 99 virtual void OnInstallFailure(const std::string& error) {} | 99 virtual void OnInstallFailure(const std::string& error) {} |
| 100 | |
| 101 virtual void OnOverinstallAttempted(Extension* extension) {} | |
| 102 }; | 100 }; |
| 103 | 101 |
| 104 bool ExtensionBrowserTest::InstallOrUpdateExtension(const std::string& id, | 102 bool ExtensionBrowserTest::InstallOrUpdateExtension(const std::string& id, |
| 105 const FilePath& path, | 103 const FilePath& path, |
| 106 InstallUIType ui_type, | 104 InstallUIType ui_type, |
| 107 int expected_change) { | 105 int expected_change) { |
| 108 ExtensionsService* service = browser()->profile()->GetExtensionsService(); | 106 ExtensionsService* service = browser()->profile()->GetExtensionsService(); |
| 109 service->set_show_extensions_prompts(false); | 107 service->set_show_extensions_prompts(false); |
| 110 size_t num_before = service->extensions()->size(); | 108 size_t num_before = service->extensions()->size(); |
| 111 | 109 |
| 112 { | 110 { |
| 113 NotificationRegistrar registrar; | 111 NotificationRegistrar registrar; |
| 114 registrar.Add(this, NotificationType::EXTENSION_LOADED, | 112 registrar.Add(this, NotificationType::EXTENSION_LOADED, |
| 115 NotificationService::AllSources()); | 113 NotificationService::AllSources()); |
| 116 registrar.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, | 114 registrar.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, |
| 117 NotificationService::AllSources()); | 115 NotificationService::AllSources()); |
| 118 registrar.Add(this, NotificationType::EXTENSION_OVERINSTALL_ERROR, | |
| 119 NotificationService::AllSources()); | |
| 120 registrar.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, | 116 registrar.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, |
| 121 NotificationService::AllSources()); | 117 NotificationService::AllSources()); |
| 122 | 118 |
| 123 ExtensionInstallUI* install_ui = NULL; | 119 ExtensionInstallUI* install_ui = NULL; |
| 124 if (ui_type == INSTALL_UI_TYPE_CANCEL) | 120 if (ui_type == INSTALL_UI_TYPE_CANCEL) |
| 125 install_ui = new MockAbortExtensionInstallUI(); | 121 install_ui = new MockAbortExtensionInstallUI(); |
| 126 else if (ui_type == INSTALL_UI_TYPE_NORMAL) | 122 else if (ui_type == INSTALL_UI_TYPE_NORMAL) |
| 127 install_ui = new ExtensionInstallUI(browser()->profile()); | 123 install_ui = new ExtensionInstallUI(browser()->profile()); |
| 128 | 124 |
| 129 scoped_refptr<CrxInstaller> installer( | 125 scoped_refptr<CrxInstaller> installer( |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 std::cout << "Got EXTENSION_INSTALLED notification.\n"; | 290 std::cout << "Got EXTENSION_INSTALLED notification.\n"; |
| 295 ++extension_installs_observed_; | 291 ++extension_installs_observed_; |
| 296 MessageLoopForUI::current()->Quit(); | 292 MessageLoopForUI::current()->Quit(); |
| 297 break; | 293 break; |
| 298 | 294 |
| 299 case NotificationType::EXTENSION_INSTALL_ERROR: | 295 case NotificationType::EXTENSION_INSTALL_ERROR: |
| 300 std::cout << "Got EXTENSION_INSTALL_ERROR notification.\n"; | 296 std::cout << "Got EXTENSION_INSTALL_ERROR notification.\n"; |
| 301 MessageLoopForUI::current()->Quit(); | 297 MessageLoopForUI::current()->Quit(); |
| 302 break; | 298 break; |
| 303 | 299 |
| 304 case NotificationType::EXTENSION_OVERINSTALL_ERROR: | |
| 305 std::cout << "Got EXTENSION_OVERINSTALL_ERROR notification.\n"; | |
| 306 MessageLoopForUI::current()->Quit(); | |
| 307 break; | |
| 308 | |
| 309 case NotificationType::EXTENSION_PROCESS_CREATED: | 300 case NotificationType::EXTENSION_PROCESS_CREATED: |
| 310 std::cout << "Got EXTENSION_PROCESS_CREATED notification.\n"; | 301 std::cout << "Got EXTENSION_PROCESS_CREATED notification.\n"; |
| 311 MessageLoopForUI::current()->Quit(); | 302 MessageLoopForUI::current()->Quit(); |
| 312 break; | 303 break; |
| 313 | 304 |
| 314 case NotificationType::EXTENSION_PROCESS_TERMINATED: | 305 case NotificationType::EXTENSION_PROCESS_TERMINATED: |
| 315 std::cout << "Got EXTENSION_PROCESS_TERMINATED notification.\n"; | 306 std::cout << "Got EXTENSION_PROCESS_TERMINATED notification.\n"; |
| 316 MessageLoopForUI::current()->Quit(); | 307 MessageLoopForUI::current()->Quit(); |
| 317 break; | 308 break; |
| 318 | 309 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 342 MessageLoopForUI::current()->Quit(); | 333 MessageLoopForUI::current()->Quit(); |
| 343 } | 334 } |
| 344 break; | 335 break; |
| 345 } | 336 } |
| 346 | 337 |
| 347 default: | 338 default: |
| 348 NOTREACHED(); | 339 NOTREACHED(); |
| 349 break; | 340 break; |
| 350 } | 341 } |
| 351 } | 342 } |
| OLD | NEW |