Chromium Code Reviews| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 } | 113 } |
| 114 | 114 |
| 115 virtual void ConfirmUninstall(Delegate* delegate, | 115 virtual void ConfirmUninstall(Delegate* delegate, |
| 116 const Extension* extension) {} | 116 const Extension* extension) {} |
| 117 | 117 |
| 118 virtual void OnInstallSuccess(const Extension* extension) {} | 118 virtual void OnInstallSuccess(const Extension* extension) {} |
| 119 | 119 |
| 120 virtual void OnInstallFailure(const std::string& error) {} | 120 virtual void OnInstallFailure(const std::string& error) {} |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 class MockAutoConfirmExtensionInstallUI : public ExtensionInstallUI { | |
| 124 public: | |
| 125 MockAutoConfirmExtensionInstallUI(Profile* profile) : ExtensionInstallUI(profi le) {} | |
|
Aaron Boodman
2010/12/14 23:21:44
80 cols
Tessa MacDuff
2010/12/15 00:38:55
Done.
| |
| 126 | |
| 127 // Proceed without confirmation prompt. | |
| 128 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | |
| 129 delegate->InstallUIProceed(); | |
| 130 } | |
| 131 }; | |
| 132 | |
| 123 bool ExtensionBrowserTest::InstallOrUpdateExtension(const std::string& id, | 133 bool ExtensionBrowserTest::InstallOrUpdateExtension(const std::string& id, |
| 124 const FilePath& path, | 134 const FilePath& path, |
| 125 InstallUIType ui_type, | 135 InstallUIType ui_type, |
| 126 int expected_change) { | 136 int expected_change) { |
| 127 ExtensionService* service = browser()->profile()->GetExtensionService(); | 137 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
| 138 browser()->profile()); | |
| 139 } | |
| 140 | |
| 141 bool ExtensionBrowserTest::InstallOrUpdateExtension(const std::string& id, | |
| 142 const FilePath& path, | |
| 143 InstallUIType ui_type, | |
| 144 int expected_change, | |
| 145 Profile* profile) { | |
| 146 ExtensionService* service = profile->GetExtensionService(); | |
| 128 service->set_show_extensions_prompts(false); | 147 service->set_show_extensions_prompts(false); |
| 129 size_t num_before = service->extensions()->size(); | 148 size_t num_before = service->extensions()->size(); |
| 130 | 149 |
| 131 { | 150 { |
| 132 NotificationRegistrar registrar; | 151 NotificationRegistrar registrar; |
| 133 registrar.Add(this, NotificationType::EXTENSION_LOADED, | 152 registrar.Add(this, NotificationType::EXTENSION_LOADED, |
| 134 NotificationService::AllSources()); | 153 NotificationService::AllSources()); |
| 135 registrar.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, | 154 registrar.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, |
| 136 NotificationService::AllSources()); | 155 NotificationService::AllSources()); |
| 137 registrar.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, | 156 registrar.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, |
| 138 NotificationService::AllSources()); | 157 NotificationService::AllSources()); |
| 139 | 158 |
| 140 ExtensionInstallUI* install_ui = NULL; | 159 ExtensionInstallUI* install_ui = NULL; |
| 141 if (ui_type == INSTALL_UI_TYPE_CANCEL) | 160 if (ui_type == INSTALL_UI_TYPE_CANCEL) |
| 142 install_ui = new MockAbortExtensionInstallUI(); | 161 install_ui = new MockAbortExtensionInstallUI(); |
| 143 else if (ui_type == INSTALL_UI_TYPE_NORMAL) | 162 else if (ui_type == INSTALL_UI_TYPE_NORMAL) |
| 144 install_ui = new ExtensionInstallUI(browser()->profile()); | 163 install_ui = new ExtensionInstallUI(profile); |
| 164 else if (ui_type == INSTALL_UI_TYPE_AUTO_CONFIRM) | |
| 165 install_ui = new MockAutoConfirmExtensionInstallUI(profile); | |
| 145 | 166 |
| 146 scoped_refptr<CrxInstaller> installer( | 167 scoped_refptr<CrxInstaller> installer( |
| 147 new CrxInstaller(service, install_ui)); | 168 new CrxInstaller(service, install_ui)); |
| 148 installer->set_expected_id(id); | 169 installer->set_expected_id(id); |
| 149 installer->InstallCrx(path); | 170 installer->InstallCrx(path); |
| 150 | 171 |
| 151 ui_test_utils::RunMessageLoop(); | 172 ui_test_utils::RunMessageLoop(); |
| 152 } | 173 } |
| 153 | 174 |
| 154 size_t num_after = service->extensions()->size(); | 175 size_t num_after = service->extensions()->size(); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 MessageLoopForUI::current()->Quit(); | 371 MessageLoopForUI::current()->Quit(); |
| 351 } | 372 } |
| 352 break; | 373 break; |
| 353 } | 374 } |
| 354 | 375 |
| 355 default: | 376 default: |
| 356 NOTREACHED(); | 377 NOTREACHED(); |
| 357 break; | 378 break; |
| 358 } | 379 } |
| 359 } | 380 } |
| OLD | NEW |