Chromium Code Reviews| 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(gfx::NativeWindow parent, |
| 250 ExtensionInstallPrompt(browser) {} | 251 content::PageNavigator* navigat or, |
|
Aaron Boodman
2012/07/03 00:52:14
8
0
cols
Ben Goodger (Google)
2012/07/03 19:17:00
Done.
| |
| 252 Profile* profile) : | |
| 253 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(parent, | |
| 298 browser, | |
| 299 browser->profile()) ; | |
|
Aaron Boodman
2012/07/03 00:52:14
..................................................
Ben Goodger (Google)
2012/07/03 19:17:00
Done.
| |
| 300 } | |
| 293 | 301 |
| 294 // TODO(tessamac): Update callers to always pass an unpacked extension | 302 // TODO(tessamac): Update callers to always pass an unpacked extension |
| 295 // and then always pack the extension here. | 303 // and then always pack the extension here. |
| 296 FilePath crx_path = path; | 304 FilePath crx_path = path; |
| 297 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { | 305 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { |
| 298 crx_path = PackExtension(path); | 306 crx_path = PackExtension(path); |
| 299 } | 307 } |
| 300 if (crx_path.empty()) | 308 if (crx_path.empty()) |
| 301 return NULL; | 309 return NULL; |
| 302 | 310 |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 case content::NOTIFICATION_LOAD_STOP: | 628 case content::NOTIFICATION_LOAD_STOP: |
| 621 VLOG(1) << "Got LOAD_STOP notification."; | 629 VLOG(1) << "Got LOAD_STOP notification."; |
| 622 MessageLoopForUI::current()->Quit(); | 630 MessageLoopForUI::current()->Quit(); |
| 623 break; | 631 break; |
| 624 | 632 |
| 625 default: | 633 default: |
| 626 NOTREACHED(); | 634 NOTREACHED(); |
| 627 break; | 635 break; |
| 628 } | 636 } |
| 629 } | 637 } |
| OLD | NEW |