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

Side by Side Diff: chrome/browser/user_data_dir_extractor_win.cc

Issue 12662033: Show user data dialog earlier on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix chromium style warning: inline virtual method with non-empty bodies. Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/user_data_dir_extractor_win.h"
6
7 #include "base/command_line.h"
8 #include "base/file_util.h"
9 #include "base/logging.h"
10 #include "base/path_service.h"
11 #include "base/process_util.h"
12 #include "chrome/browser/ui/user_data_dir_dialog.h"
13 #include "chrome/browser/user_data_dir_extractor.h"
14 #include "chrome/common/chrome_paths.h"
15 #include "chrome/common/chrome_switches.h"
16 #include "content/public/common/main_function_params.h"
17
18 namespace chrome {
19
20 namespace {
21
22 GetUserDataDirCallback* custom_get_user_data_dir_callback = NULL;
23
24 } // namespace
25
26 void InstallCustomGetUserDataDirCallbackForTest(
27 GetUserDataDirCallback* callback) {
28 custom_get_user_data_dir_callback = callback;
29 }
30
31 base::FilePath GetUserDataDir(const content::MainFunctionParams& parameters) {
32 // If tests have installed a custom callback for GetUserDataDir(), invoke the
33 // callback and return.
34 if (custom_get_user_data_dir_callback)
35 return custom_get_user_data_dir_callback->Run();
36
37 base::FilePath user_data_dir;
38 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
39
40 // On Windows, if we fail to get the user data dir, bring up a dialog to
41 // prompt the user to pick a different directory, and restart chrome with
42 // the new dir.
43 // http://code.google.com/p/chromium/issues/detail?id=11510
44 if (!file_util::PathExists(user_data_dir)) {
45 #if defined(USE_AURA)
46 // TODO(beng):
47 NOTIMPLEMENTED();
48 #else
49 base::FilePath new_user_data_dir =
50 chrome::ShowUserDataDirDialog(user_data_dir);
51
52 if (!new_user_data_dir.empty()) {
53 // Because of the way CommandLine parses, it's sufficient to append a new
54 // --user-data-dir switch. The last flag of the same name wins.
55 // TODO(tc): It would be nice to remove the flag we don't want, but that
56 // sounds risky if we parse differently than CommandLineToArgvW.
57 CommandLine new_command_line = parameters.command_line;
58 new_command_line.AppendSwitchPath(switches::kUserDataDir,
59 new_user_data_dir);
60 base::LaunchProcess(new_command_line, base::LaunchOptions(), NULL);
61 }
62 #endif
63 NOTREACHED() << "Failed to get user data directory!";
64 }
65 return user_data_dir;
66 }
67
68 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/user_data_dir_extractor_win.h ('k') | chrome/browser/user_data_dir_extractor_win_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698