| 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" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "chrome/browser/extensions/app_shortcut_manager.h" | 15 #include "chrome/browser/extensions/app_shortcut_manager.h" |
| 16 #include "chrome/browser/extensions/component_loader.h" | 16 #include "chrome/browser/extensions/component_loader.h" |
| 17 #include "chrome/browser/extensions/crx_installer.h" | 17 #include "chrome/browser/extensions/crx_installer.h" |
| 18 #include "chrome/browser/extensions/extension_creator.h" | 18 #include "chrome/browser/extensions/extension_creator.h" |
| 19 #include "chrome/browser/extensions/extension_error_reporter.h" | 19 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 20 #include "chrome/browser/extensions/extension_install_ui.h" | 20 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 21 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 22 #include "chrome/browser/extensions/unpacked_installer.h" | 22 #include "chrome/browser/extensions/unpacked_installer.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/browser_window.h" | 25 #include "chrome/browser/ui/browser_window.h" |
| 26 #include "chrome/browser/ui/omnibox/location_bar.h" | 26 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 27 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 28 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 29 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/test/base/ui_test_utils.h" | 30 #include "chrome/test/base/ui_test_utils.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 218 } |
| 219 | 219 |
| 220 if (!file_util::PathExists(crx_path)) { | 220 if (!file_util::PathExists(crx_path)) { |
| 221 ADD_FAILURE() << crx_path.value() << " was not created."; | 221 ADD_FAILURE() << crx_path.value() << " was not created."; |
| 222 return FilePath(); | 222 return FilePath(); |
| 223 } | 223 } |
| 224 return crx_path; | 224 return crx_path; |
| 225 } | 225 } |
| 226 | 226 |
| 227 // This class is used to simulate an installation abort by the user. | 227 // This class is used to simulate an installation abort by the user. |
| 228 class MockAbortExtensionInstallUI : public ExtensionInstallUI { | 228 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { |
| 229 public: | 229 public: |
| 230 MockAbortExtensionInstallUI() : ExtensionInstallUI(NULL) {} | 230 MockAbortExtensionInstallPrompt() : ExtensionInstallPrompt(NULL) {} |
| 231 | 231 |
| 232 // Simulate a user abort on an extension installation. | 232 // Simulate a user abort on an extension installation. |
| 233 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 233 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { |
| 234 delegate->InstallUIAbort(true); | 234 delegate->InstallUIAbort(true); |
| 235 MessageLoopForUI::current()->Quit(); | 235 MessageLoopForUI::current()->Quit(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 238 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} |
| 239 | 239 |
| 240 virtual void OnInstallFailure(const string16& error) {} | 240 virtual void OnInstallFailure(const string16& error) {} |
| 241 }; | 241 }; |
| 242 | 242 |
| 243 class MockAutoConfirmExtensionInstallUI : public ExtensionInstallUI { | 243 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { |
| 244 public: | 244 public: |
| 245 explicit MockAutoConfirmExtensionInstallUI(Profile* profile) : | 245 explicit MockAutoConfirmExtensionInstallPrompt(Profile* profile) : |
| 246 ExtensionInstallUI(profile) {} | 246 ExtensionInstallPrompt(profile) {} |
| 247 | 247 |
| 248 // Proceed without confirmation prompt. | 248 // Proceed without confirmation prompt. |
| 249 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 249 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { |
| 250 delegate->InstallUIProceed(); | 250 delegate->InstallUIProceed(); |
| 251 } | 251 } |
| 252 }; | 252 }; |
| 253 | 253 |
| 254 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( | 254 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( |
| 255 const FilePath& path, | 255 const FilePath& path, |
| 256 int expected_change) { | 256 int expected_change) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 273 const FilePath& path, | 273 const FilePath& path, |
| 274 InstallUIType ui_type, | 274 InstallUIType ui_type, |
| 275 int expected_change, | 275 int expected_change, |
| 276 Profile* profile, | 276 Profile* profile, |
| 277 bool from_webstore) { | 277 bool from_webstore) { |
| 278 ExtensionService* service = profile->GetExtensionService(); | 278 ExtensionService* service = profile->GetExtensionService(); |
| 279 service->set_show_extensions_prompts(false); | 279 service->set_show_extensions_prompts(false); |
| 280 size_t num_before = service->extensions()->size(); | 280 size_t num_before = service->extensions()->size(); |
| 281 | 281 |
| 282 { | 282 { |
| 283 ExtensionInstallUI* install_ui = NULL; | 283 ExtensionInstallPrompt* install_ui = NULL; |
| 284 if (ui_type == INSTALL_UI_TYPE_CANCEL) | 284 if (ui_type == INSTALL_UI_TYPE_CANCEL) |
| 285 install_ui = new MockAbortExtensionInstallUI(); | 285 install_ui = new MockAbortExtensionInstallPrompt(); |
| 286 else if (ui_type == INSTALL_UI_TYPE_NORMAL) | 286 else if (ui_type == INSTALL_UI_TYPE_NORMAL) |
| 287 install_ui = new ExtensionInstallUI(profile); | 287 install_ui = new ExtensionInstallPrompt(profile); |
| 288 else if (ui_type == INSTALL_UI_TYPE_AUTO_CONFIRM) | 288 else if (ui_type == INSTALL_UI_TYPE_AUTO_CONFIRM) |
| 289 install_ui = new MockAutoConfirmExtensionInstallUI(profile); | 289 install_ui = new MockAutoConfirmExtensionInstallPrompt(profile); |
| 290 | 290 |
| 291 // TODO(tessamac): Update callers to always pass an unpacked extension | 291 // TODO(tessamac): Update callers to always pass an unpacked extension |
| 292 // and then always pack the extension here. | 292 // and then always pack the extension here. |
| 293 FilePath crx_path = path; | 293 FilePath crx_path = path; |
| 294 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { | 294 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { |
| 295 crx_path = PackExtension(path); | 295 crx_path = PackExtension(path); |
| 296 } | 296 } |
| 297 if (crx_path.empty()) | 297 if (crx_path.empty()) |
| 298 return NULL; | 298 return NULL; |
| 299 | 299 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 case content::NOTIFICATION_LOAD_STOP: | 537 case content::NOTIFICATION_LOAD_STOP: |
| 538 VLOG(1) << "Got LOAD_STOP notification."; | 538 VLOG(1) << "Got LOAD_STOP notification."; |
| 539 MessageLoopForUI::current()->Quit(); | 539 MessageLoopForUI::current()->Quit(); |
| 540 break; | 540 break; |
| 541 | 541 |
| 542 default: | 542 default: |
| 543 NOTREACHED(); | 543 NOTREACHED(); |
| 544 break; | 544 break; |
| 545 } | 545 } |
| 546 } | 546 } |
| OLD | NEW |