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 29 matching lines...) Expand all Loading... |
40 #include "content/public/browser/navigation_entry.h" | 40 #include "content/public/browser/navigation_entry.h" |
41 #include "content/public/browser/notification_registrar.h" | 41 #include "content/public/browser/notification_registrar.h" |
42 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
43 #include "content/public/browser/render_view_host.h" | 43 #include "content/public/browser/render_view_host.h" |
44 #include "content/public/test/browser_test_utils.h" | 44 #include "content/public/test/browser_test_utils.h" |
45 #include "sync/api/string_ordinal.h" | 45 #include "sync/api/string_ordinal.h" |
46 | 46 |
47 using extensions::Extension; | 47 using extensions::Extension; |
48 using extensions::ExtensionCreator; | 48 using extensions::ExtensionCreator; |
49 using extensions::FeatureSwitch; | 49 using extensions::FeatureSwitch; |
| 50 using extensions::Manifest; |
50 | 51 |
51 ExtensionBrowserTest::ExtensionBrowserTest() | 52 ExtensionBrowserTest::ExtensionBrowserTest() |
52 : loaded_(false), | 53 : loaded_(false), |
53 installed_(false), | 54 installed_(false), |
54 extension_installs_observed_(0), | 55 extension_installs_observed_(0), |
55 extension_load_errors_observed_(0), | 56 extension_load_errors_observed_(0), |
56 target_page_action_count_(-1), | 57 target_page_action_count_(-1), |
57 target_visible_page_action_count_(-1), | 58 target_visible_page_action_count_(-1), |
58 current_channel_(chrome::VersionInfo::CHANNEL_DEV), | 59 current_channel_(chrome::VersionInfo::CHANNEL_DEV), |
59 override_prompt_for_external_extensions_( | 60 override_prompt_for_external_extensions_( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 iter != service->extensions()->end(); ++iter) { | 106 iter != service->extensions()->end(); ++iter) { |
106 if ((*iter)->path() == extension_path) { | 107 if ((*iter)->path() == extension_path) { |
107 extension = *iter; | 108 extension = *iter; |
108 break; | 109 break; |
109 } | 110 } |
110 } | 111 } |
111 if (!extension) | 112 if (!extension) |
112 return NULL; | 113 return NULL; |
113 | 114 |
114 if (!(flags & kFlagIgnoreManifestWarnings)) { | 115 if (!(flags & kFlagIgnoreManifestWarnings)) { |
115 const Extension::InstallWarningVector& install_warnings = | 116 const std::vector<extensions::InstallWarning>& install_warnings = |
116 extension->install_warnings(); | 117 extension->install_warnings(); |
117 if (!install_warnings.empty()) { | 118 if (!install_warnings.empty()) { |
118 std::string install_warnings_message = StringPrintf( | 119 std::string install_warnings_message = StringPrintf( |
119 "Unexpected warnings when loading test extension %s:\n", | 120 "Unexpected warnings when loading test extension %s:\n", |
120 path.AsUTF8Unsafe().c_str()); | 121 path.AsUTF8Unsafe().c_str()); |
121 | 122 |
122 for (Extension::InstallWarningVector::const_iterator it = | 123 for (std::vector<extensions::InstallWarning>::const_iterator it = |
123 install_warnings.begin(); it != install_warnings.end(); ++it) { | 124 install_warnings.begin(); it != install_warnings.end(); ++it) { |
124 install_warnings_message += " " + it->message + "\n"; | 125 install_warnings_message += " " + it->message + "\n"; |
125 } | 126 } |
126 | 127 |
127 EXPECT_TRUE(extension->install_warnings().empty()) << | 128 EXPECT_TRUE(extension->install_warnings().empty()) << |
128 install_warnings_message; | 129 install_warnings_message; |
129 return NULL; | 130 return NULL; |
130 } | 131 } |
131 } | 132 } |
132 | 133 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 const Extension* extension, | 290 const Extension* extension, |
290 const ShowDialogCallback& show_dialog_callback) { | 291 const ShowDialogCallback& show_dialog_callback) { |
291 delegate->InstallUIProceed(); | 292 delegate->InstallUIProceed(); |
292 } | 293 } |
293 }; | 294 }; |
294 | 295 |
295 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( | 296 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( |
296 const FilePath& path, | 297 const FilePath& path, |
297 int expected_change) { | 298 int expected_change) { |
298 return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_NONE, | 299 return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_NONE, |
299 expected_change, Extension::INTERNAL, | 300 expected_change, Manifest::INTERNAL, |
300 browser(), true); | 301 browser(), true); |
301 } | 302 } |
302 | 303 |
303 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 304 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
304 const std::string& id, | 305 const std::string& id, |
305 const FilePath& path, | 306 const FilePath& path, |
306 InstallUIType ui_type, | 307 InstallUIType ui_type, |
307 int expected_change) { | 308 int expected_change) { |
308 return InstallOrUpdateExtension(id, path, ui_type, expected_change, | 309 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
309 Extension::INTERNAL, browser(), false); | 310 Manifest::INTERNAL, browser(), false); |
310 } | 311 } |
311 | 312 |
312 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 313 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
313 const std::string& id, | 314 const std::string& id, |
314 const FilePath& path, | 315 const FilePath& path, |
315 InstallUIType ui_type, | 316 InstallUIType ui_type, |
316 int expected_change, | 317 int expected_change, |
317 Browser* browser, | 318 Browser* browser, |
318 bool from_webstore) { | 319 bool from_webstore) { |
319 return InstallOrUpdateExtension(id, path, ui_type, expected_change, | 320 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
320 Extension::INTERNAL, browser, from_webstore); | 321 Manifest::INTERNAL, browser, from_webstore); |
321 } | 322 } |
322 | 323 |
323 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 324 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
324 const std::string& id, | 325 const std::string& id, |
325 const FilePath& path, | 326 const FilePath& path, |
326 InstallUIType ui_type, | 327 InstallUIType ui_type, |
327 int expected_change, | 328 int expected_change, |
328 Extension::Location install_source) { | 329 Manifest::Location install_source) { |
329 return InstallOrUpdateExtension(id, path, ui_type, expected_change, | 330 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
330 install_source, browser(), false); | 331 install_source, browser(), false); |
331 } | 332 } |
332 | 333 |
333 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 334 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
334 const std::string& id, | 335 const std::string& id, |
335 const FilePath& path, | 336 const FilePath& path, |
336 InstallUIType ui_type, | 337 InstallUIType ui_type, |
337 int expected_change, | 338 int expected_change, |
338 Extension::Location install_source, | 339 Manifest::Location install_source, |
339 Browser* browser, | 340 Browser* browser, |
340 bool from_webstore) { | 341 bool from_webstore) { |
341 ExtensionService* service = browser->profile()->GetExtensionService(); | 342 ExtensionService* service = browser->profile()->GetExtensionService(); |
342 service->set_show_extensions_prompts(false); | 343 service->set_show_extensions_prompts(false); |
343 size_t num_before = service->extensions()->size(); | 344 size_t num_before = service->extensions()->size(); |
344 | 345 |
345 { | 346 { |
346 ExtensionInstallPrompt* install_ui = NULL; | 347 ExtensionInstallPrompt* install_ui = NULL; |
347 if (ui_type == INSTALL_UI_TYPE_CANCEL) { | 348 if (ui_type == INSTALL_UI_TYPE_CANCEL) { |
348 install_ui = new MockAbortExtensionInstallPrompt(); | 349 install_ui = new MockAbortExtensionInstallPrompt(); |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 case content::NOTIFICATION_LOAD_STOP: | 690 case content::NOTIFICATION_LOAD_STOP: |
690 VLOG(1) << "Got LOAD_STOP notification."; | 691 VLOG(1) << "Got LOAD_STOP notification."; |
691 MessageLoopForUI::current()->Quit(); | 692 MessageLoopForUI::current()->Quit(); |
692 break; | 693 break; |
693 | 694 |
694 default: | 695 default: |
695 NOTREACHED(); | 696 NOTREACHED(); |
696 break; | 697 break; |
697 } | 698 } |
698 } | 699 } |
OLD | NEW |