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