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

Side by Side Diff: chrome/app/chrome_main_delegate.cc

Issue 123693003: Revise user-data-dir switch handling; avoid crashes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup. Created 6 years, 10 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
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/app/chrome_main_delegate.h" 5 #include "chrome/app/chrome_main_delegate.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/environment.h"
9 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
10 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
11 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
12 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/statistics_recorder.h" 12 #include "base/metrics/statistics_recorder.h"
14 #include "base/metrics/stats_counters.h" 13 #include "base/metrics/stats_counters.h"
15 #include "base/path_service.h" 14 #include "base/path_service.h"
16 #include "base/process/memory.h" 15 #include "base/process/memory.h"
17 #include "base/process/process_handle.h" 16 #include "base/process/process_handle.h"
18 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h"
20 #include "build/build_config.h" 17 #include "build/build_config.h"
21 #include "chrome/browser/chrome_content_browser_client.h" 18 #include "chrome/browser/chrome_content_browser_client.h"
22 #include "chrome/browser/defaults.h" 19 #include "chrome/browser/defaults.h"
23 #include "chrome/browser/policy/policy_path_parser.h"
24 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
25 #include "chrome/common/chrome_content_client.h" 21 #include "chrome/common/chrome_content_client.h"
26 #include "chrome/common/chrome_paths.h" 22 #include "chrome/common/chrome_paths.h"
27 #include "chrome/common/chrome_paths_internal.h"
28 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/chrome_version_info.h" 24 #include "chrome/common/chrome_version_info.h"
30 #include "chrome/common/crash_keys.h" 25 #include "chrome/common/crash_keys.h"
31 #include "chrome/common/logging_chrome.h" 26 #include "chrome/common/logging_chrome.h"
32 #include "chrome/common/profiling.h" 27 #include "chrome/common/profiling.h"
33 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
34 #include "chrome/plugin/chrome_content_plugin_client.h" 29 #include "chrome/plugin/chrome_content_plugin_client.h"
35 #include "chrome/renderer/chrome_content_renderer_client.h" 30 #include "chrome/renderer/chrome_content_renderer_client.h"
36 #include "chrome/utility/chrome_content_utility_client.h" 31 #include "chrome/utility/chrome_content_utility_client.h"
37 #include "components/nacl/common/nacl_switches.h" 32 #include "components/nacl/common/nacl_switches.h"
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 chrome::GetVersionedDirectory(). 571 chrome::GetVersionedDirectory().
577 Append(chrome::kHelperProcessExecutablePath)); 572 Append(chrome::kHelperProcessExecutablePath));
578 573
579 InitMacCrashReporter(command_line, process_type); 574 InitMacCrashReporter(command_line, process_type);
580 #endif 575 #endif
581 576
582 #if defined(OS_WIN) 577 #if defined(OS_WIN)
583 child_process_logging::Init(); 578 child_process_logging::Init();
584 #endif 579 #endif
585 580
586 // Notice a user data directory override if any
587 base::FilePath user_data_dir =
588 command_line.GetSwitchValuePath(switches::kUserDataDir);
589 #if defined(OS_LINUX)
590 // On Linux, Chrome does not support running multiple copies under different
591 // DISPLAYs, so the profile directory can be specified in the environment to
592 // support the virtual desktop use-case.
593 if (user_data_dir.empty()) {
594 std::string user_data_dir_string;
595 scoped_ptr<base::Environment> environment(base::Environment::Create());
596 if (environment->GetVar("CHROME_USER_DATA_DIR", &user_data_dir_string) &&
597 IsStringUTF8(user_data_dir_string)) {
598 user_data_dir = base::FilePath::FromUTF8Unsafe(user_data_dir_string);
599 }
600 }
601 #endif
602 #if defined(OS_MACOSX) || defined(OS_WIN)
603 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir);
604 #endif
605 if (!user_data_dir.empty()) {
606 CHECK(PathService::OverrideAndCreateIfNeeded(
607 chrome::DIR_USER_DATA,
608 user_data_dir,
Vitaly Buka (NO REVIEWS) 2014/02/20 11:24:07 We need to revert this part of change or to find w
609 chrome::ProcessNeedsProfileDir(process_type)));
610 }
611
612 stats_counter_timer_.reset(new base::StatsCounterTimer("Chrome.Init")); 581 stats_counter_timer_.reset(new base::StatsCounterTimer("Chrome.Init"));
613 startup_timer_.reset(new base::StatsScope<base::StatsCounterTimer> 582 startup_timer_.reset(new base::StatsScope<base::StatsCounterTimer>
614 (*stats_counter_timer_)); 583 (*stats_counter_timer_));
615 584
616 // Enable the heap profiler as early as possible! 585 // Enable the heap profiler as early as possible!
617 EnableHeapProfiler(command_line); 586 EnableHeapProfiler(command_line);
618 587
619 // Enable Message Loop related state asap. 588 // Enable Message Loop related state asap.
620 if (command_line.HasSwitch(switches::kMessageLoopHistogrammer)) 589 if (command_line.HasSwitch(switches::kMessageLoopHistogrammer))
621 base::MessageLoop::EnableHistogrammer(true); 590 base::MessageLoop::EnableHistogrammer(true);
622 591
623 #if !defined(OS_ANDROID) 592 #if !defined(OS_ANDROID)
624 // Android does InitLogging when library is loaded. Skip here. 593 // Android does InitLogging when library is loaded. Skip here.
625 logging::OldFileDeletionState file_state = 594 logging::OldFileDeletionState file_state =
626 logging::APPEND_TO_OLD_LOG_FILE; 595 logging::APPEND_TO_OLD_LOG_FILE;
627 if (process_type.empty()) { 596 if (process_type.empty()) {
628 file_state = logging::DELETE_OLD_LOG_FILE; 597 file_state = logging::DELETE_OLD_LOG_FILE;
629 } 598 }
630 logging::InitChromeLogging(command_line, file_state); 599 logging::InitChromeLogging(command_line, file_state);
Vitaly Buka (NO REVIEWS) 2014/02/20 11:40:33 Actually logging is brocken for all processes incl
631 #endif 600 #endif
632 601
633 #if defined(OS_WIN) 602 #if defined(OS_WIN)
634 // TODO(darin): Kill this once http://crbug.com/52609 is fixed. 603 // TODO(darin): Kill this once http://crbug.com/52609 is fixed.
635 ui::SetResourcesDataDLL(_AtlBaseModule.GetResourceInstance()); 604 ui::SetResourcesDataDLL(_AtlBaseModule.GetResourceInstance());
636 #endif 605 #endif
637 606
638 if (SubprocessNeedsResourceBundle(process_type)) { 607 if (SubprocessNeedsResourceBundle(process_type)) {
639 // Initialize ResourceBundle which handles files loaded from external 608 // Initialize ResourceBundle which handles files loaded from external
640 // sources. The language should have been passed in to us from the 609 // sources. The language should have been passed in to us from the
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 } 827 }
859 828
860 content::ContentUtilityClient* 829 content::ContentUtilityClient*
861 ChromeMainDelegate::CreateContentUtilityClient() { 830 ChromeMainDelegate::CreateContentUtilityClient() {
862 #if defined(CHROME_MULTIPLE_DLL_BROWSER) 831 #if defined(CHROME_MULTIPLE_DLL_BROWSER)
863 return NULL; 832 return NULL;
864 #else 833 #else
865 return g_chrome_content_utility_client.Pointer(); 834 return g_chrome_content_utility_client.Pointer();
866 #endif 835 #endif
867 } 836 }
OLDNEW
« no previous file with comments | « no previous file | chrome/app/chromium_strings.grd » ('j') | chrome/browser/user_data_dir_extractor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698