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

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

Issue 12662033: Show user data dialog earlier on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chrome_browser_main.h" 5 #include "chrome/browser/chrome_browser_main.h"
6 6
7 #if defined(TOOLKIT_GTK) 7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 browser_creator->AddFirstRunTab(*it); 258 browser_creator->AddFirstRunTab(*it);
259 } 259 }
260 } 260 }
261 261
262 // Returns the new local state object, guaranteed non-NULL. 262 // Returns the new local state object, guaranteed non-NULL.
263 // |local_state_task_runner| must be a shutdown-blocking task runner. 263 // |local_state_task_runner| must be a shutdown-blocking task runner.
264 PrefService* InitializeLocalState( 264 PrefService* InitializeLocalState(
265 base::SequencedTaskRunner* local_state_task_runner, 265 base::SequencedTaskRunner* local_state_task_runner,
266 const CommandLine& parsed_command_line, 266 const CommandLine& parsed_command_line,
267 bool is_first_run) { 267 bool is_first_run) {
268 #if defined(OS_WIN)
269 // On Windows, we must make sure that the path for USER_DATA_DIR exists,
270 // otherwise we will hit a CHECK failure when in CreateLocalState().
271 // Prompt the user to pick a different user-data-dir and restart chrome with
272 // the new dir.
273 // http://code.google.com/p/chromium/issues/detail?id=11510
274 base::FilePath user_data_path;
275 PathService::Get(chrome::USER_DATA_DIR, &user_data_path);
276 if (!file_util::PathExists(user_data_path)) {
277 #if defined(USE_AURA)
278 // TODO(beng):
279 NOTIMPLEMENTED();
280 #else
281 base::FilePath new_user_data_dir =
282 chrome::ShowUserDataDirDialog(user_data_dir);
283
284 if (!new_user_data_dir.empty()) {
285 // Because of the way CommandLine parses, it's sufficient to append a new
286 // --user-data-dir switch. The last flag of the same name wins.
287 // TODO(tc): It would be nice to remove the flag we don't want, but that
288 // sounds risky if we parse differently than CommandLineToArgvW.
289 CommandLine new_command_line = parameters.command_line;
290 new_command_line.AppendSwitchPath(switches::kUserDataDir,
291 new_user_data_dir);
292 base::LaunchProcess(new_command_line, base::LaunchOptions(), NULL);
293 }
294 #endif
295 }
296 #endif // defined(OS_WIN)
297
268 base::FilePath local_state_path; 298 base::FilePath local_state_path;
269 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); 299 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
270 bool local_state_file_exists = file_util::PathExists(local_state_path); 300 bool local_state_file_exists = file_util::PathExists(local_state_path);
271 301
272 // Load local state. This includes the application locale so we know which 302 // Load local state. This includes the application locale so we know which
273 // locale dll to load. This also causes local state prefs to be registered. 303 // locale dll to load. This also causes local state prefs to be registered.
274 PrefService* local_state = g_browser_process->local_state(); 304 PrefService* local_state = g_browser_process->local_state();
275 DCHECK(local_state); 305 DCHECK(local_state);
276 306
277 if (is_first_run) { 307 if (is_first_run) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 user_data_dir); 409 user_data_dir);
380 #else 410 #else
381 base::FilePath profile_path = 411 base::FilePath profile_path =
382 GetStartupProfilePath(user_data_dir, parsed_command_line); 412 GetStartupProfilePath(user_data_dir, parsed_command_line);
383 profile = g_browser_process->profile_manager()->GetProfile( 413 profile = g_browser_process->profile_manager()->GetProfile(
384 profile_path); 414 profile_path);
385 #endif 415 #endif
386 if (profile) 416 if (profile)
387 return profile; 417 return profile;
388 418
389 #if defined(OS_WIN)
390 #if defined(USE_AURA)
391 // TODO(beng):
392 NOTIMPLEMENTED();
393 #else
394 // Ideally, we should be able to run w/o access to disk. For now, we
395 // prompt the user to pick a different user-data-dir and restart chrome
396 // with the new dir.
397 // http://code.google.com/p/chromium/issues/detail?id=11510
398 base::FilePath new_user_data_dir =
399 chrome::ShowUserDataDirDialog(user_data_dir);
400
401 if (!new_user_data_dir.empty()) {
402 // Because of the way CommandLine parses, it's sufficient to append a new
403 // --user-data-dir switch. The last flag of the same name wins.
404 // TODO(tc): It would be nice to remove the flag we don't want, but that
405 // sounds risky if we parse differently than CommandLineToArgvW.
406 CommandLine new_command_line = parameters.command_line;
407 new_command_line.AppendSwitchPath(switches::kUserDataDir,
408 new_user_data_dir);
409 base::LaunchProcess(new_command_line, base::LaunchOptions(), NULL);
410 }
411 #endif
412 #else
413 // TODO(port): fix this. See comments near the definition of 419 // TODO(port): fix this. See comments near the definition of
414 // user_data_dir. It is better to CHECK-fail here than it is to 420 // user_data_dir. It is better to CHECK-fail here than it is to
415 // silently exit because of missing code in the above test. 421 // silently exit because of missing code in the above test.
416 CHECK(profile) << "Cannot get default profile."; 422 CHECK(profile) << "Cannot get default profile.";
417 #endif
418 423
419 return NULL; 424 return NULL;
420 } 425 }
421 426
422 #if defined(OS_MACOSX) 427 #if defined(OS_MACOSX)
423 OSStatus KeychainCallback(SecKeychainEvent keychain_event, 428 OSStatus KeychainCallback(SecKeychainEvent keychain_event,
424 SecKeychainCallbackInfo* info, void* context) { 429 SecKeychainCallbackInfo* info, void* context) {
425 return noErr; 430 return noErr;
426 } 431 }
427 #endif 432 #endif
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 DCHECK(master_prefs_.get()); 807 DCHECK(master_prefs_.get());
803 #if !defined(OS_ANDROID) 808 #if !defined(OS_ANDROID)
804 DCHECK(browser_creator_.get()); 809 DCHECK(browser_creator_.get());
805 #endif 810 #endif
806 return result_code_; 811 return result_code_;
807 } 812 }
808 813
809 int ChromeBrowserMainParts::PreCreateThreadsImpl() { 814 int ChromeBrowserMainParts::PreCreateThreadsImpl() {
810 run_message_loop_ = false; 815 run_message_loop_ = false;
811 #if defined(OS_WIN) 816 #if defined(OS_WIN)
812 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_); 817 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_);
Mattias Nissler (ping if slow) 2013/03/22 17:48:24 I'd move the check here actually.
hshi1 2013/03/22 17:59:03 Done.
813 #else 818 #else
814 // Getting the user data dir can fail if the directory isn't 819 // Getting the user data dir can fail if the directory isn't
815 // creatable, for example; on Windows in code below we bring up a 820 // creatable, for example; on Windows in code below we bring up a
816 // dialog prompting the user to pick a different directory. 821 // dialog prompting the user to pick a different directory.
817 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux, 822 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux,
818 // so it's better to fail here than fail mysteriously elsewhere. 823 // so it's better to fail here than fail mysteriously elsewhere.
819 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)) 824 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_))
820 << "Must be able to get user data directory!"; 825 << "Must be able to get user data directory!";
821 #endif 826 #endif
822 827
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 if (base::win::GetVersion() <= base::win::VERSION_XP) 1819 if (base::win::GetVersion() <= base::win::VERSION_XP)
1815 uma_name += "_XP"; 1820 uma_name += "_XP";
1816 1821
1817 uma_name += "_PreRead_"; 1822 uma_name += "_PreRead_";
1818 uma_name += pre_read_percentage; 1823 uma_name += pre_read_percentage;
1819 AddPreReadHistogramTime(uma_name.c_str(), time); 1824 AddPreReadHistogramTime(uma_name.c_str(), time);
1820 } 1825 }
1821 #endif 1826 #endif
1822 #endif 1827 #endif
1823 } 1828 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698