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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 const FilePath& path, bool incognito_enabled, bool fileaccess_enabled) { | 78 const FilePath& path, bool incognito_enabled, bool fileaccess_enabled) { |
79 ExtensionService* service = browser()->profile()->GetExtensionService(); | 79 ExtensionService* service = browser()->profile()->GetExtensionService(); |
80 { | 80 { |
81 content::NotificationRegistrar registrar; | 81 content::NotificationRegistrar registrar; |
82 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 82 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
83 content::NotificationService::AllSources()); | 83 content::NotificationService::AllSources()); |
84 scoped_refptr<extensions::UnpackedInstaller> installer( | 84 scoped_refptr<extensions::UnpackedInstaller> installer( |
85 extensions::UnpackedInstaller::Create(service)); | 85 extensions::UnpackedInstaller::Create(service)); |
86 installer->set_prompt_for_plugins(false); | 86 installer->set_prompt_for_plugins(false); |
87 installer->Load(path); | 87 installer->Load(path); |
88 ui_test_utils::RunMessageLoop(); | 88 content::RunMessageLoop(); |
89 } | 89 } |
90 | 90 |
91 // Find the loaded extension by its path. See crbug.com/59531 for why | 91 // Find the loaded extension by its path. See crbug.com/59531 for why |
92 // we cannot just use last_loaded_extension_id_. | 92 // we cannot just use last_loaded_extension_id_. |
93 FilePath extension_path = path; | 93 FilePath extension_path = path; |
94 file_util::AbsolutePath(&extension_path); | 94 file_util::AbsolutePath(&extension_path); |
95 const Extension* extension = NULL; | 95 const Extension* extension = NULL; |
96 for (ExtensionSet::const_iterator iter = service->extensions()->begin(); | 96 for (ExtensionSet::const_iterator iter = service->extensions()->begin(); |
97 iter != service->extensions()->end(); ++iter) { | 97 iter != service->extensions()->end(); ++iter) { |
98 if ((*iter)->path() == extension_path) { | 98 if ((*iter)->path() == extension_path) { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 installer->set_off_store_install_allow_reason( | 320 installer->set_off_store_install_allow_reason( |
321 extensions::CrxInstaller::OffStoreInstallAllowedInTest); | 321 extensions::CrxInstaller::OffStoreInstallAllowedInTest); |
322 } | 322 } |
323 | 323 |
324 content::NotificationRegistrar registrar; | 324 content::NotificationRegistrar registrar; |
325 registrar.Add(this, chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 325 registrar.Add(this, chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
326 content::Source<extensions::CrxInstaller>(installer.get())); | 326 content::Source<extensions::CrxInstaller>(installer.get())); |
327 | 327 |
328 installer->InstallCrx(crx_path); | 328 installer->InstallCrx(crx_path); |
329 | 329 |
330 ui_test_utils::RunMessageLoop(); | 330 content::RunMessageLoop(); |
331 } | 331 } |
332 | 332 |
333 size_t num_after = service->extensions()->size(); | 333 size_t num_after = service->extensions()->size(); |
334 EXPECT_EQ(num_before + expected_change, num_after); | 334 EXPECT_EQ(num_before + expected_change, num_after); |
335 if (num_before + expected_change != num_after) { | 335 if (num_before + expected_change != num_after) { |
336 VLOG(1) << "Num extensions before: " << base::IntToString(num_before) | 336 VLOG(1) << "Num extensions before: " << base::IntToString(num_before) |
337 << " num after: " << base::IntToString(num_after) | 337 << " num after: " << base::IntToString(num_after) |
338 << " Installed extensions follow:"; | 338 << " Installed extensions follow:"; |
339 | 339 |
340 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 340 for (ExtensionSet::const_iterator it = service->extensions()->begin(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 416 |
417 ExtensionProcessManager* manager = | 417 ExtensionProcessManager* manager = |
418 browser()->profile()->GetExtensionProcessManager(); | 418 browser()->profile()->GetExtensionProcessManager(); |
419 ExtensionProcessManager::ViewSet all_views = manager->GetAllViews(); | 419 ExtensionProcessManager::ViewSet all_views = manager->GetAllViews(); |
420 for (ExtensionProcessManager::ViewSet::const_iterator iter = | 420 for (ExtensionProcessManager::ViewSet::const_iterator iter = |
421 all_views.begin(); | 421 all_views.begin(); |
422 iter != all_views.end();) { | 422 iter != all_views.end();) { |
423 if (!(*iter)->IsLoading()) { | 423 if (!(*iter)->IsLoading()) { |
424 ++iter; | 424 ++iter; |
425 } else { | 425 } else { |
426 ui_test_utils::RunMessageLoop(); | 426 content::RunMessageLoop(); |
427 | 427 |
428 // Test activity may have modified the set of extension processes during | 428 // Test activity may have modified the set of extension processes during |
429 // message processing, so re-start the iteration to catch added/removed | 429 // message processing, so re-start the iteration to catch added/removed |
430 // processes. | 430 // processes. |
431 all_views = manager->GetAllViews(); | 431 all_views = manager->GetAllViews(); |
432 iter = all_views.begin(); | 432 iter = all_views.begin(); |
433 } | 433 } |
434 } | 434 } |
435 return true; | 435 return true; |
436 } | 436 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 case content::NOTIFICATION_LOAD_STOP: | 632 case content::NOTIFICATION_LOAD_STOP: |
633 VLOG(1) << "Got LOAD_STOP notification."; | 633 VLOG(1) << "Got LOAD_STOP notification."; |
634 MessageLoopForUI::current()->Quit(); | 634 MessageLoopForUI::current()->Quit(); |
635 break; | 635 break; |
636 | 636 |
637 default: | 637 default: |
638 NOTREACHED(); | 638 NOTREACHED(); |
639 break; | 639 break; |
640 } | 640 } |
641 } | 641 } |
OLD | NEW |