Index: chrome/browser/extensions/extension_browsertest.cc |
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc |
index ca5053ca75fa125c8c68c6210ad5d22a1da94ed7..fd2f7ed0c257d5d5b1a138084a3c5f6ea80f934f 100644 |
--- a/chrome/browser/extensions/extension_browsertest.cc |
+++ b/chrome/browser/extensions/extension_browsertest.cc |
@@ -124,8 +124,27 @@ void ExtensionBrowserTest::SetUpOnMainThread() { |
observer_.reset(new ExtensionTestNotificationObserver(browser())); |
} |
+const Extension* ExtensionBrowserTest::LoadExtension( |
+ const base::FilePath& path) { |
+ return LoadExtensionWithFlags(path, kFlagEnableFileAccess); |
+} |
+ |
+const Extension* ExtensionBrowserTest::LoadExtensionIncognito( |
+ const base::FilePath& path) { |
+ return LoadExtensionWithFlags(path, |
+ kFlagEnableFileAccess | kFlagEnableIncognito); |
+} |
+ |
const Extension* ExtensionBrowserTest::LoadExtensionWithFlags( |
const base::FilePath& path, int flags) { |
+ return LoadExtensionWithInstallParam(path, flags, std::string()); |
+} |
+ |
+const extensions::Extension* |
+ExtensionBrowserTest::LoadExtensionWithInstallParam( |
+ const base::FilePath& path, |
+ int flags, |
+ const std::string& install_param) { |
ExtensionService* service = extensions::ExtensionSystem::Get( |
profile())->extension_service(); |
{ |
@@ -169,13 +188,22 @@ const Extension* ExtensionBrowserTest::LoadExtensionWithFlags( |
const std::string extension_id = extension->id(); |
- // The call to OnExtensionInstalled ensures the other extension prefs |
- // are set up with the defaults. |
- extensions::ExtensionPrefs::Get(profile()) |
- ->OnExtensionInstalled(extension, |
- Extension::ENABLED, |
- false, |
- syncer::StringOrdinal::CreateInitialOrdinal()); |
+ if (!install_param.empty()) { |
+ extensions::ExtensionPrefs::Get(profile()) |
+ ->SetInstallParam(extension_id, install_param); |
+ // Re-enable the extension if needed. |
+ if (service->extensions()->Contains(extension_id)) { |
+ content::WindowedNotificationObserver load_signal( |
+ chrome::NOTIFICATION_EXTENSION_LOADED, |
+ content::Source<Profile>(profile())); |
+ // Reload the extension so that the NOTIFICATION_EXTENSION_LOADED |
+ // observers may access |install_param|. |
Yoyo Zhou
2014/03/18 00:07:51
I'm struggling to understand the reason for this.
vasilii
2014/03/18 10:01:22
We don't know its id yet. It'd be ideal if we coul
|
+ service->ReloadExtension(extension_id); |
+ load_signal.Wait(); |
+ extension = service->GetExtensionById(extension_id, false); |
+ CHECK(extension) << extension_id << " not found after reloading."; |
+ } |
+ } |
// Toggling incognito or file access will reload the extension, so wait for |
// the reload and grab the new extension instance. The default state is |
@@ -214,17 +242,6 @@ const Extension* ExtensionBrowserTest::LoadExtensionWithFlags( |
return extension; |
} |
-const Extension* ExtensionBrowserTest::LoadExtension( |
- const base::FilePath& path) { |
- return LoadExtensionWithFlags(path, kFlagEnableFileAccess); |
-} |
- |
-const Extension* ExtensionBrowserTest::LoadExtensionIncognito( |
- const base::FilePath& path) { |
- return LoadExtensionWithFlags(path, |
- kFlagEnableFileAccess | kFlagEnableIncognito); |
-} |
- |
const Extension* ExtensionBrowserTest::LoadExtensionAsComponentWithManifest( |
const base::FilePath& path, |
const base::FilePath::CharType* manifest_relative_path) { |