summaryrefslogtreecommitdiffstats
path: root/chrome/browser/first_run
diff options
context:
space:
mode:
authortapted@chromium.org <tapted@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 01:16:25 +0000
committertapted@chromium.org <tapted@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 01:16:25 +0000
commitae4c37e92410ecac0983171b35a3fd5a331075b5 (patch)
treea40f6c3f9af759dc509fcd7cd549851201e341f7 /chrome/browser/first_run
parent38afc5413a07c3101bd1d85aba1adbef08e360b1 (diff)
downloadchromium_src-ae4c37e92410ecac0983171b35a3fd5a331075b5.zip
chromium_src-ae4c37e92410ecac0983171b35a3fd5a331075b5.tar.gz
chromium_src-ae4c37e92410ecac0983171b35a3fd5a331075b5.tar.bz2
Do not load extension system in the Profile import process.
Also, defer loading component extensions with background pages until the import process is complete, so that the renderer host does not compete for the database lock. This also adds a regression test for http://crbug.com/163925. BUG=163925,107636 TEST=Test first-run flows and profile import after uninstalling chrome and removing AppData/Local/Google/Chrome directory Review URL: https://chromiumcodereview.appspot.com/11572036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174302 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/first_run')
-rw-r--r--chrome/browser/first_run/first_run.cc15
-rw-r--r--chrome/browser/first_run/first_run.h6
-rw-r--r--chrome/browser/first_run/first_run_browsertest.cc32
-rw-r--r--chrome/browser/first_run/first_run_win.cc4
4 files changed, 57 insertions, 0 deletions
diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc
index 566976e..255284d 100644
--- a/chrome/browser/first_run/first_run.cc
+++ b/chrome/browser/first_run/first_run.cc
@@ -451,6 +451,21 @@ void LogFirstRunMetric(FirstRunBubbleMetric metric) {
NUM_FIRST_RUN_BUBBLE_METRICS);
}
+namespace {
+CommandLine* GetExtraArgumentsInstance() {
+ CR_DEFINE_STATIC_LOCAL(CommandLine, arguments, (CommandLine::NoProgram()));
+ return &arguments;
+}
+} // namespace
+
+void SetExtraArgumentsForImportProcess(const CommandLine& arguments) {
+ GetExtraArgumentsInstance()->AppendArguments(arguments, false);
+}
+
+const CommandLine& GetExtraArgumentsForImportProcess() {
+ return *GetExtraArgumentsInstance();
+}
+
// static
void FirstRunBubbleLauncher::ShowFirstRunBubbleSoon() {
SetShowFirstRunBubblePref(true);
diff --git a/chrome/browser/first_run/first_run.h b/chrome/browser/first_run/first_run.h
index e06603a..b86203a 100644
--- a/chrome/browser/first_run/first_run.h
+++ b/chrome/browser/first_run/first_run.h
@@ -97,6 +97,12 @@ bool SetPersonalDataManagerFirstRunPref();
// Log a metric for the "FirstRun.SearchEngineBubble" histogram.
void LogFirstRunMetric(FirstRunBubbleMetric metric);
+// Allow a test to specify additional arguments for the profile import process.
+void SetExtraArgumentsForImportProcess(const CommandLine& arguments);
+
+// Get any extra arguments set with SetExtraArgumentsForImportProcess.
+const CommandLine& GetExtraArgumentsForImportProcess();
+
// -- Platform-specific functions --
// Automatically import history and home page (and search engine, if
diff --git a/chrome/browser/first_run/first_run_browsertest.cc b/chrome/browser/first_run/first_run_browsertest.cc
index 40383b2..50bd807 100644
--- a/chrome/browser/first_run/first_run_browsertest.cc
+++ b/chrome/browser/first_run/first_run_browsertest.cc
@@ -2,11 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/command_line.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
+#include "content/public/test/test_launcher.h"
#include "testing/gtest/include/gtest/gtest.h"
typedef InProcessBrowserTest FirstRunBrowserTest;
@@ -37,3 +42,30 @@ IN_PROC_BROWSER_TEST_F(FirstRunBrowserTest, SetShowWelcomePagePref) {
EXPECT_TRUE(g_browser_process->local_state()->GetBoolean(
prefs::kShouldShowWelcomePage));
}
+
+namespace {
+class FirstRunIntegrationBrowserTest : public InProcessBrowserTest {
+ public:
+ FirstRunIntegrationBrowserTest() {}
+ protected:
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ InProcessBrowserTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch(switches::kFirstRun);
+ command_line->AppendSwitch(switches::kFirstRunForceImport);
+ EXPECT_FALSE(ProfileManager::DidPerformProfileImport());
+
+ extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
+
+ // The forked import process should run BrowserMain.
+ CommandLine import_arguments((CommandLine::NoProgram()));
+ import_arguments.AppendSwitch(content::kLaunchAsBrowser);
+ first_run::SetExtraArgumentsForImportProcess(import_arguments);
+ }
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FirstRunIntegrationBrowserTest);
+};
+}
+
+IN_PROC_BROWSER_TEST_F(FirstRunIntegrationBrowserTest, WaitForImport) {
+ ASSERT_TRUE(ProfileManager::DidPerformProfileImport());
+}
diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc
index 4971eb1..0ad9b17 100644
--- a/chrome/browser/first_run/first_run_win.cc
+++ b/chrome/browser/first_run/first_run_win.cc
@@ -332,6 +332,10 @@ bool ImportSettingsWin(Profile* profile,
};
import_cmd.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames));
+ // Allow tests to introduce additional switches.
+ import_cmd.AppendArguments(first_run::GetExtraArgumentsForImportProcess(),
+ false);
+
// Since ImportSettings is called before the local state is stored on disk
// we pass the language as an argument. GetApplicationLocale checks the
// current command line as fallback.