| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 if (!file_util::PathExists(crx_path)) { | 224 if (!file_util::PathExists(crx_path)) { |
| 225 ADD_FAILURE() << crx_path.value() << " was not created."; | 225 ADD_FAILURE() << crx_path.value() << " was not created."; |
| 226 return FilePath(); | 226 return FilePath(); |
| 227 } | 227 } |
| 228 return crx_path; | 228 return crx_path; |
| 229 } | 229 } |
| 230 | 230 |
| 231 // This class is used to simulate an installation abort by the user. | 231 // This class is used to simulate an installation abort by the user. |
| 232 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { | 232 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { |
| 233 public: | 233 public: |
| 234 MockAbortExtensionInstallPrompt() : ExtensionInstallPrompt(NULL) {} | 234 MockAbortExtensionInstallPrompt() : ExtensionInstallPrompt(NULL, NULL, NULL) { |
| 235 } |
| 235 | 236 |
| 236 // Simulate a user abort on an extension installation. | 237 // Simulate a user abort on an extension installation. |
| 237 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 238 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { |
| 238 delegate->InstallUIAbort(true); | 239 delegate->InstallUIAbort(true); |
| 239 MessageLoopForUI::current()->Quit(); | 240 MessageLoopForUI::current()->Quit(); |
| 240 } | 241 } |
| 241 | 242 |
| 242 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} | 243 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon) {} |
| 243 | 244 |
| 244 virtual void OnInstallFailure(const CrxInstallerError& error) {} | 245 virtual void OnInstallFailure(const CrxInstallerError& error) {} |
| 245 }; | 246 }; |
| 246 | 247 |
| 247 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { | 248 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { |
| 248 public: | 249 public: |
| 249 explicit MockAutoConfirmExtensionInstallPrompt(Browser* browser) : | 250 explicit MockAutoConfirmExtensionInstallPrompt( |
| 250 ExtensionInstallPrompt(browser) {} | 251 gfx::NativeWindow parent, |
| 252 content::PageNavigator* navigator, |
| 253 Profile* profile) : ExtensionInstallPrompt(parent, navigator, profile) {} |
| 251 | 254 |
| 252 // Proceed without confirmation prompt. | 255 // Proceed without confirmation prompt. |
| 253 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { | 256 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { |
| 254 delegate->InstallUIProceed(); | 257 delegate->InstallUIProceed(); |
| 255 } | 258 } |
| 256 }; | 259 }; |
| 257 | 260 |
| 258 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( | 261 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( |
| 259 const FilePath& path, | 262 const FilePath& path, |
| 260 int expected_change) { | 263 int expected_change) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 277 InstallUIType ui_type, | 280 InstallUIType ui_type, |
| 278 int expected_change, | 281 int expected_change, |
| 279 Browser* browser, | 282 Browser* browser, |
| 280 bool from_webstore) { | 283 bool from_webstore) { |
| 281 ExtensionService* service = browser->profile()->GetExtensionService(); | 284 ExtensionService* service = browser->profile()->GetExtensionService(); |
| 282 service->set_show_extensions_prompts(false); | 285 service->set_show_extensions_prompts(false); |
| 283 size_t num_before = service->extensions()->size(); | 286 size_t num_before = service->extensions()->size(); |
| 284 | 287 |
| 285 { | 288 { |
| 286 ExtensionInstallPrompt* install_ui = NULL; | 289 ExtensionInstallPrompt* install_ui = NULL; |
| 287 if (ui_type == INSTALL_UI_TYPE_CANCEL) | 290 if (ui_type == INSTALL_UI_TYPE_CANCEL) { |
| 288 install_ui = new MockAbortExtensionInstallPrompt(); | 291 install_ui = new MockAbortExtensionInstallPrompt(); |
| 289 else if (ui_type == INSTALL_UI_TYPE_NORMAL) | 292 } else if (ui_type == INSTALL_UI_TYPE_NORMAL) { |
| 290 install_ui = new ExtensionInstallPrompt(browser); | 293 install_ui = chrome::CreateExtensionInstallPromptWithBrowser(browser); |
| 291 else if (ui_type == INSTALL_UI_TYPE_AUTO_CONFIRM) | 294 } else if (ui_type == INSTALL_UI_TYPE_AUTO_CONFIRM) { |
| 292 install_ui = new MockAutoConfirmExtensionInstallPrompt(browser); | 295 gfx::NativeWindow parent = |
| 296 browser->window() ? browser->window()->GetNativeWindow() : NULL; |
| 297 install_ui = new MockAutoConfirmExtensionInstallPrompt( |
| 298 parent, |
| 299 browser, |
| 300 browser->profile()); |
| 301 } |
| 293 | 302 |
| 294 // TODO(tessamac): Update callers to always pass an unpacked extension | 303 // TODO(tessamac): Update callers to always pass an unpacked extension |
| 295 // and then always pack the extension here. | 304 // and then always pack the extension here. |
| 296 FilePath crx_path = path; | 305 FilePath crx_path = path; |
| 297 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { | 306 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { |
| 298 crx_path = PackExtension(path); | 307 crx_path = PackExtension(path); |
| 299 } | 308 } |
| 300 if (crx_path.empty()) | 309 if (crx_path.empty()) |
| 301 return NULL; | 310 return NULL; |
| 302 | 311 |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 case content::NOTIFICATION_LOAD_STOP: | 629 case content::NOTIFICATION_LOAD_STOP: |
| 621 VLOG(1) << "Got LOAD_STOP notification."; | 630 VLOG(1) << "Got LOAD_STOP notification."; |
| 622 MessageLoopForUI::current()->Quit(); | 631 MessageLoopForUI::current()->Quit(); |
| 623 break; | 632 break; |
| 624 | 633 |
| 625 default: | 634 default: |
| 626 NOTREACHED(); | 635 NOTREACHED(); |
| 627 break; | 636 break; |
| 628 } | 637 } |
| 629 } | 638 } |
| OLD | NEW |