summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-28 23:24:42 +0000
committerhshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-28 23:24:42 +0000
commitff35feeb0cf1383913624250bc53b822abbd24d0 (patch)
tree997a34e7bd51bf73cd64d4d18cbe4f17b49bf37d
parentc63072f1c2698294750b9e3a24c9ef1362612d53 (diff)
downloadchromium_src-ff35feeb0cf1383913624250bc53b822abbd24d0.zip
chromium_src-ff35feeb0cf1383913624250bc53b822abbd24d0.tar.gz
chromium_src-ff35feeb0cf1383913624250bc53b822abbd24d0.tar.bz2
Revert 191225 "Merge 190833 "Show user data dialog earlier on Wi..."
> Merge 190833 "Show user data dialog earlier on Windows." > > > Show user data dialog earlier on Windows. > > > > On Windows if the user data directory does not exist, we must show the user > > data dir picker dialog prior to creating the local state to avoid a CHECK > > failure. After obtaining the new dir we will restart chrome with the switch > > --user-data-dir appended to the command line. > > > > BUG=196301 > > TEST=CQ > > > > > > Review URL: https://chromiumcodereview.appspot.com/12662033 > > TBR=hshi@chromium.org > Review URL: https://codereview.chromium.org/13245005 TBR=hshi@chromium.org Review URL: https://codereview.chromium.org/13262003 git-svn-id: svn://svn.chromium.org/chrome/branches/1410/src@191237 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_process.h2
-rw-r--r--chrome/browser/browser_process_impl.cc4
-rw-r--r--chrome/browser/browser_process_impl.h1
-rw-r--r--chrome/browser/chrome_browser_main.cc38
-rw-r--r--chrome/browser/user_data_dir_extractor.cc26
-rw-r--r--chrome/browser/user_data_dir_extractor.h23
-rw-r--r--chrome/browser/user_data_dir_extractor_win.cc68
-rw-r--r--chrome/browser/user_data_dir_extractor_win.h22
-rw-r--r--chrome/browser/user_data_dir_extractor_win_browsertest.cc74
-rw-r--r--chrome/chrome_browser.gypi5
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--chrome/test/base/testing_browser_process.cc4
-rw-r--r--chrome/test/base/testing_browser_process.h1
13 files changed, 36 insertions, 234 deletions
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index 69fb4d5..40f70b5 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -220,8 +220,6 @@ class BrowserProcess {
virtual void PlatformSpecificCommandLineProcessing(
const CommandLine& command_line) = 0;
- virtual bool created_local_state() const = 0;
-
private:
DISALLOW_COPY_AND_ASSIGN(BrowserProcess);
};
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index a6af2e7..79a413a 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -622,10 +622,6 @@ void BrowserProcessImpl::PlatformSpecificCommandLineProcessing(
}
#endif
-bool BrowserProcessImpl::created_local_state() const {
- return created_local_state_;
-}
-
// static
void BrowserProcessImpl::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled,
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index f2c1566..b01591f 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -131,7 +131,6 @@ class BrowserProcessImpl : public BrowserProcess,
media_file_system_registry() OVERRIDE;
virtual void PlatformSpecificCommandLineProcessing(
const CommandLine& command_line) OVERRIDE;
- virtual bool created_local_state() const OVERRIDE;
static void RegisterPrefs(PrefRegistrySimple* registry);
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index b8c174b..68dd97e 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -101,7 +101,6 @@
#include "chrome/browser/ui/uma_browsing_activity_observer.h"
#include "chrome/browser/ui/user_data_dir_dialog.h"
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
-#include "chrome/browser/user_data_dir_extractor.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
@@ -383,10 +382,35 @@ Profile* CreateProfile(const content::MainFunctionParams& parameters,
if (profile)
return profile;
+#if defined(OS_WIN)
+#if defined(USE_AURA)
+ // TODO(beng):
+ NOTIMPLEMENTED();
+#else
+ // Ideally, we should be able to run w/o access to disk. For now, we
+ // prompt the user to pick a different user-data-dir and restart chrome
+ // with the new dir.
+ // http://code.google.com/p/chromium/issues/detail?id=11510
+ base::FilePath new_user_data_dir =
+ chrome::ShowUserDataDirDialog(user_data_dir);
+
+ if (!new_user_data_dir.empty()) {
+ // Because of the way CommandLine parses, it's sufficient to append a new
+ // --user-data-dir switch. The last flag of the same name wins.
+ // TODO(tc): It would be nice to remove the flag we don't want, but that
+ // sounds risky if we parse differently than CommandLineToArgvW.
+ CommandLine new_command_line = parameters.command_line;
+ new_command_line.AppendSwitchPath(switches::kUserDataDir,
+ new_user_data_dir);
+ base::LaunchProcess(new_command_line, base::LaunchOptions(), NULL);
+ }
+#endif
+#else
// TODO(port): fix this. See comments near the definition of
// user_data_dir. It is better to CHECK-fail here than it is to
// silently exit because of missing code in the above test.
CHECK(profile) << "Cannot get default profile.";
+#endif
return NULL;
}
@@ -772,7 +796,17 @@ int ChromeBrowserMainParts::PreCreateThreads() {
int ChromeBrowserMainParts::PreCreateThreadsImpl() {
run_message_loop_ = false;
- user_data_dir_ = chrome::GetUserDataDir(parameters());
+#if defined(OS_WIN)
+ PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_);
+#else
+ // Getting the user data dir can fail if the directory isn't
+ // creatable, for example; on Windows in code below we bring up a
+ // dialog prompting the user to pick a different directory.
+ // However, ProcessSingleton needs a real user_data_dir on Mac/Linux,
+ // so it's better to fail here than fail mysteriously elsewhere.
+ CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_))
+ << "Must be able to get user data directory!";
+#endif
// Whether this is First Run. |do_first_run_tasks_| should be prefered to this
// unless the desire is actually to know whether this is really First Run
diff --git a/chrome/browser/user_data_dir_extractor.cc b/chrome/browser/user_data_dir_extractor.cc
deleted file mode 100644
index 45084c3..0000000
--- a/chrome/browser/user_data_dir_extractor.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/user_data_dir_extractor.h"
-
-#include "base/files/file_path.h"
-#include "base/logging.h"
-#include "base/path_service.h"
-#include "chrome/common/chrome_paths.h"
-
-namespace chrome {
-
-base::FilePath GetUserDataDir(const content::MainFunctionParams& parameters) {
- base::FilePath user_data_dir;
-
- // Getting the user data dir can fail if the directory isn't creatable, for
- // example: on Windows we bring up a dialog prompting the user to pick a
- // different directory. However, ProcessSingleton needs a real user_data_dir
- // on Mac/Linux, so it's better to fail here than fail mysteriously elsewhere.
- CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir))
- << "Must be able to get user data directory!";
- return user_data_dir;
-}
-
-} // namespace chrome
diff --git a/chrome/browser/user_data_dir_extractor.h b/chrome/browser/user_data_dir_extractor.h
deleted file mode 100644
index 5e8af0a..0000000
--- a/chrome/browser/user_data_dir_extractor.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_USER_DATA_DIR_EXTRACTOR_H_
-#define CHROME_BROWSER_USER_DATA_DIR_EXTRACTOR_H_
-
-namespace base {
-class FilePath;
-}
-
-namespace content{
-struct MainFunctionParams;
-}
-
-namespace chrome {
-
-// Returns the user data dir. Must be called prior to InitializeLocalState().
-base::FilePath GetUserDataDir(const content::MainFunctionParams& parameters);
-
-} // namespace chrome
-
-#endif // CHROME_BROWSER_USER_DATA_DIR_EXTRACTOR_H_
diff --git a/chrome/browser/user_data_dir_extractor_win.cc b/chrome/browser/user_data_dir_extractor_win.cc
deleted file mode 100644
index 5c4b941..0000000
--- a/chrome/browser/user_data_dir_extractor_win.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/user_data_dir_extractor_win.h"
-
-#include "base/command_line.h"
-#include "base/file_util.h"
-#include "base/logging.h"
-#include "base/path_service.h"
-#include "base/process_util.h"
-#include "chrome/browser/ui/user_data_dir_dialog.h"
-#include "chrome/browser/user_data_dir_extractor.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/chrome_switches.h"
-#include "content/public/common/main_function_params.h"
-
-namespace chrome {
-
-namespace {
-
-GetUserDataDirCallback* custom_get_user_data_dir_callback = NULL;
-
-} // namespace
-
-void InstallCustomGetUserDataDirCallbackForTest(
- GetUserDataDirCallback* callback) {
- custom_get_user_data_dir_callback = callback;
-}
-
-base::FilePath GetUserDataDir(const content::MainFunctionParams& parameters) {
- // If tests have installed a custom callback for GetUserDataDir(), invoke the
- // callback and return.
- if (custom_get_user_data_dir_callback)
- return custom_get_user_data_dir_callback->Run();
-
- base::FilePath user_data_dir;
- PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
-
- // On Windows, if we fail to get the user data dir, bring up a dialog to
- // prompt the user to pick a different directory, and restart chrome with
- // the new dir.
- // http://code.google.com/p/chromium/issues/detail?id=11510
- if (!file_util::PathExists(user_data_dir)) {
-#if defined(USE_AURA)
- // TODO(beng):
- NOTIMPLEMENTED();
-#else
- base::FilePath new_user_data_dir =
- chrome::ShowUserDataDirDialog(user_data_dir);
-
- if (!new_user_data_dir.empty()) {
- // Because of the way CommandLine parses, it's sufficient to append a new
- // --user-data-dir switch. The last flag of the same name wins.
- // TODO(tc): It would be nice to remove the flag we don't want, but that
- // sounds risky if we parse differently than CommandLineToArgvW.
- CommandLine new_command_line = parameters.command_line;
- new_command_line.AppendSwitchPath(switches::kUserDataDir,
- new_user_data_dir);
- base::LaunchProcess(new_command_line, base::LaunchOptions(), NULL);
- }
-#endif
- NOTREACHED() << "Failed to get user data directory!";
- }
- return user_data_dir;
-}
-
-} // namespace chrome
diff --git a/chrome/browser/user_data_dir_extractor_win.h b/chrome/browser/user_data_dir_extractor_win.h
deleted file mode 100644
index bff11a7..0000000
--- a/chrome/browser/user_data_dir_extractor_win.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_USER_DATA_DIR_EXTRACTOR_WIN_H_
-#define CHROME_BROWSER_USER_DATA_DIR_EXTRACTOR_WIN_H_
-
-#include "base/callback.h"
-#include "base/files/file_path.h"
-
-namespace chrome {
-
-typedef base::Callback<base::FilePath()> GetUserDataDirCallback;
-
-// Tests can call this to install a custom callback to be called when
-// GetUserDataDir() is invoked.
-void InstallCustomGetUserDataDirCallbackForTest(
- GetUserDataDirCallback* callback);
-
-} // namespace chrome
-
-#endif // CHROME_BROWSER_USER_DATA_DIR_EXTRACTOR_WIN_H_
diff --git a/chrome/browser/user_data_dir_extractor_win_browsertest.cc b/chrome/browser/user_data_dir_extractor_win_browsertest.cc
deleted file mode 100644
index fa8483c..0000000
--- a/chrome/browser/user_data_dir_extractor_win_browsertest.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/test/ui/ui_test.h"
-
-#include "base/command_line.h"
-#include "base/file_util.h"
-#include "base/path_service.h"
-#include "base/process_util.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/user_data_dir_extractor_win.h"
-#include "chrome/common/chrome_notification_types.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "chrome/test/base/ui_test_utils.h"
-
-// These tests only apply to the Windows version; see chrome_browser_main.cc:
-// function GetUserDataDir() for details.
-class ChromeMainUserDataDirTest : public InProcessBrowserTest {
- public:
- ChromeMainUserDataDirTest()
- : did_get_user_data_dir_(false),
- did_create_local_state_before_get_user_data_dir_(false) {}
-
- bool did_get_user_data_dir() const { return did_get_user_data_dir_; }
- bool did_create_local_state_before_get_user_data_dir() const {
- return did_create_local_state_before_get_user_data_dir_;
- }
-
- protected:
- virtual void SetUp() OVERRIDE {
- // Install custom GetUserDataDir callback.
- callback_ = base::Bind(&ChromeMainUserDataDirTest::GetUserDataDirCallback,
- this);
- chrome::InstallCustomGetUserDataDirCallbackForTest(&callback_);
-
- InProcessBrowserTest::SetUp();
- }
-
- private:
- base::FilePath GetUserDataDirCallback() {
- did_get_user_data_dir_ = true;
- did_create_local_state_before_get_user_data_dir_ =
- g_browser_process && g_browser_process->created_local_state();
-
- base::FilePath user_data_dir;
- PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
- return user_data_dir;
- }
-
- chrome::GetUserDataDirCallback callback_;
- bool did_get_user_data_dir_;
- bool did_create_local_state_before_get_user_data_dir_;
-
- DISALLOW_COPY_AND_ASSIGN(ChromeMainUserDataDirTest);
-};
-
-IN_PROC_BROWSER_TEST_F(ChromeMainUserDataDirTest, GetUserDataDir) {
- // Verify that GetUserDataDir() has been invoked.
- ASSERT_TRUE(did_get_user_data_dir());
-
- // Verify that local state was not created before invoking GetUserDataDir().
- ASSERT_FALSE(did_create_local_state_before_get_user_data_dir());
-
- // Verify that we have a valid browser process.
- ASSERT_TRUE(g_browser_process);
-
- // Verify that local state is created now.
- ASSERT_TRUE(g_browser_process->created_local_state());
-}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index c07fda5..7602549 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2163,10 +2163,6 @@
'browser/usb/usb_service.h',
'browser/usb/usb_service_factory.cc',
'browser/usb/usb_service_factory.h',
- 'browser/user_data_dir_extractor.cc',
- 'browser/user_data_dir_extractor.h',
- 'browser/user_data_dir_extractor_win.cc',
- 'browser/user_data_dir_extractor_win.h',
'browser/user_style_sheet_watcher.cc',
'browser/user_style_sheet_watcher.h',
'browser/user_style_sheet_watcher_factory.cc',
@@ -2876,7 +2872,6 @@
'browser/importer/nss_decryptor_system_nss.h',
'browser/lifetime/application_lifetime_stub.cc',
'browser/profiles/profile_shortcut_manager_stub.cc',
- 'browser/user_data_dir_extractor.cc',
],
'conditions': [
['win_use_allocator_shim==1', {
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 4c33725..6e92537 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1411,7 +1411,6 @@
'browser/ui/webui/sync_setup_browsertest.js',
'browser/ui/webui/web_ui_test_handler.cc',
'browser/ui/webui/web_ui_test_handler.h',
- 'browser/user_data_dir_extractor_win_browsertest.cc',
'browser/unload_browsertest.cc',
'common/mac/mock_launchd.cc',
'common/mac/mock_launchd.h',
@@ -1713,7 +1712,6 @@
# TODO(port): http://crbug.com/45770
'browser/printing/printing_layout_browsertest.cc',
'browser/ui/views/message_center/web_notification_tray_win_browsertest.cc',
- 'browser/user_data_dir_extractor_win_browsertest.cc',
],
}],
['toolkit_uses_gtk == 1', {
diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc
index 53c2690f..dcc937c 100644
--- a/chrome/test/base/testing_browser_process.cc
+++ b/chrome/test/base/testing_browser_process.cc
@@ -335,10 +335,6 @@ void TestingBrowserProcess::PlatformSpecificCommandLineProcessing(
const CommandLine& command_line) {
}
-bool TestingBrowserProcess::created_local_state() const {
- return (local_state_ != NULL);
-}
-
void TestingBrowserProcess::SetBookmarkPromptController(
BookmarkPromptController* controller) {
#if !defined(OS_IOS)
diff --git a/chrome/test/base/testing_browser_process.h b/chrome/test/base/testing_browser_process.h
index c582e8d..76da2ca 100644
--- a/chrome/test/base/testing_browser_process.h
+++ b/chrome/test/base/testing_browser_process.h
@@ -109,7 +109,6 @@ class TestingBrowserProcess : public BrowserProcess {
media_file_system_registry() OVERRIDE;
virtual void PlatformSpecificCommandLineProcessing(
const CommandLine& command_line) OVERRIDE;
- virtual bool created_local_state() const OVERRIDE;
// Set the local state for tests. Consumer is responsible for cleaning it up
// afterwards (using ScopedTestingLocalState, for example).