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

Unified Diff: chrome/browser/extensions/extension_browsertest.cc

Issue 196663003: Introduce an extension parameter which is used to customize the extension. It's available for exter… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months 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 side-by-side diff with in-line comments
Download patch
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..a2c341ddfff13573601a1ae05894449f8d533714 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();
{
@@ -167,15 +186,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());
+ std::string extension_id = extension->id();
Finnur 2014/03/13 16:37:51 Out of curiosity... What necessitates the const re
vasilii 2014/03/14 10:54:58 I wanted to remove the reference here..
+
+ if (!install_param.empty()) {
+ extensions::ExtensionPrefs::Get(profile())
+ ->SetInstallParam(extension_id, install_param);
+ // Reenable the extension if needed
Finnur 2014/03/13 16:37:51 nit: s/Reenable/Re-enable/ ... and end the comment
vasilii 2014/03/14 10:54:58 Done.
+ if (service->extensions()->Contains(extension_id)) {
+ content::WindowedNotificationObserver load_signal(
+ chrome::NOTIFICATION_EXTENSION_LOADED,
+ content::Source<Profile>(profile()));
+ service->ReloadExtension(extension_id);
Finnur 2014/03/13 16:37:51 Maybe document why this is needed?
vasilii 2014/03/14 10:54:58 Done.
+ 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 +240,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) {

Powered by Google App Engine
This is Rietveld 408576698