Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: chrome/browser/extensions/extension_browsertest.cc

Issue 8417012: Refactor loading out of ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/extensions/component_loader.h"
15 #include "chrome/browser/extensions/crx_installer.h" 16 #include "chrome/browser/extensions/crx_installer.h"
16 #include "chrome/browser/extensions/extension_creator.h" 17 #include "chrome/browser/extensions/extension_creator.h"
17 #include "chrome/browser/extensions/extension_error_reporter.h" 18 #include "chrome/browser/extensions/extension_error_reporter.h"
18 #include "chrome/browser/extensions/extension_host.h" 19 #include "chrome/browser/extensions/extension_host.h"
19 #include "chrome/browser/extensions/extension_install_ui.h" 20 #include "chrome/browser/extensions/extension_install_ui.h"
20 #include "chrome/browser/extensions/extension_service.h" 21 #include "chrome/browser/extensions/extension_service.h"
22 #include "chrome/browser/extensions/unpacked_installer.h"
21 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_window.h" 25 #include "chrome/browser/ui/browser_window.h"
24 #include "chrome/browser/ui/omnibox/location_bar.h" 26 #include "chrome/browser/ui/omnibox/location_bar.h"
25 #include "chrome/common/chrome_notification_types.h" 27 #include "chrome/common/chrome_notification_types.h"
26 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
27 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
28 #include "chrome/test/base/ui_test_utils.h" 30 #include "chrome/test/base/ui_test_utils.h"
29 #include "content/public/browser/notification_registrar.h" 31 #include "content/public/browser/notification_registrar.h"
30 #include "content/public/browser/notification_service.h" 32 #include "content/public/browser/notification_service.h"
(...skipping 28 matching lines...) Expand all
59 #endif 61 #endif
60 } 62 }
61 63
62 const Extension* ExtensionBrowserTest::LoadExtensionWithOptions( 64 const Extension* ExtensionBrowserTest::LoadExtensionWithOptions(
63 const FilePath& path, bool incognito_enabled, bool fileaccess_enabled) { 65 const FilePath& path, bool incognito_enabled, bool fileaccess_enabled) {
64 ExtensionService* service = browser()->profile()->GetExtensionService(); 66 ExtensionService* service = browser()->profile()->GetExtensionService();
65 { 67 {
66 content::NotificationRegistrar registrar; 68 content::NotificationRegistrar registrar;
67 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 69 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
68 content::NotificationService::AllSources()); 70 content::NotificationService::AllSources());
69 service->LoadExtension(path, false); 71 scoped_refptr<UnpackedInstaller> installer(
72 service->MakeUnpackedInstaller());
73 installer->set_prompt_for_plugins(false);
Yoyo Zhou 2011/10/31 21:58:15 FYI, here's the one other place where we _disable_
74 installer->Load(path);
70 ui_test_utils::RunMessageLoop(); 75 ui_test_utils::RunMessageLoop();
71 } 76 }
72 77
73 // Find the extension by iterating backwards since it is likely last. 78 // Find the extension by iterating backwards since it is likely last.
74 FilePath extension_path = path; 79 FilePath extension_path = path;
75 file_util::AbsolutePath(&extension_path); 80 file_util::AbsolutePath(&extension_path);
76 const Extension* extension = NULL; 81 const Extension* extension = NULL;
77 for (ExtensionList::const_reverse_iterator iter = 82 for (ExtensionList::const_reverse_iterator iter =
78 service->extensions()->rbegin(); 83 service->extensions()->rbegin();
79 iter != service->extensions()->rend(); ++iter) { 84 iter != service->extensions()->rend(); ++iter) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 145 }
141 146
142 bool ExtensionBrowserTest::LoadExtensionAsComponent(const FilePath& path) { 147 bool ExtensionBrowserTest::LoadExtensionAsComponent(const FilePath& path) {
143 ExtensionService* service = browser()->profile()->GetExtensionService(); 148 ExtensionService* service = browser()->profile()->GetExtensionService();
144 149
145 std::string manifest; 150 std::string manifest;
146 if (!file_util::ReadFileToString(path.Append(Extension::kManifestFilename), 151 if (!file_util::ReadFileToString(path.Append(Extension::kManifestFilename),
147 &manifest)) 152 &manifest))
148 return false; 153 return false;
149 154
150 service->LoadComponentExtension( 155 service->component_loader()->LoadComponentExtension(
151 ExtensionService::ComponentExtensionInfo(manifest, path)); 156 ComponentLoader::ComponentExtensionInfo(manifest, path));
152 157
153 return true; 158 return true;
154 } 159 }
155 160
156 FilePath ExtensionBrowserTest::PackExtension(const FilePath& dir_path) { 161 FilePath ExtensionBrowserTest::PackExtension(const FilePath& dir_path) {
157 FilePath crx_path = temp_dir_.path().AppendASCII("temp.crx"); 162 FilePath crx_path = temp_dir_.path().AppendASCII("temp.crx");
158 if (!file_util::Delete(crx_path, false)) { 163 if (!file_util::Delete(crx_path, false)) {
159 ADD_FAILURE() << "Failed to delete crx: " << crx_path.value(); 164 ADD_FAILURE() << "Failed to delete crx: " << crx_path.value();
160 return FilePath(); 165 return FilePath();
161 } 166 }
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 MessageLoopForUI::current()->Quit(); 488 MessageLoopForUI::current()->Quit();
484 } 489 }
485 break; 490 break;
486 } 491 }
487 492
488 default: 493 default:
489 NOTREACHED(); 494 NOTREACHED();
490 break; 495 break;
491 } 496 }
492 } 497 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698