From f253006b157f9c917fba21a7312290aaa2e889e7 Mon Sep 17 00:00:00 2001 From: "munjal@chromium.org" Date: Wed, 3 Dec 2008 23:52:03 +0000 Subject: Chromium-MultiProfile-Prototype Summary ======= Implement a prototype of multiple profiles in Chrome by utilizing the functionality of user-data-dir command line flag that already exists. A profile in this case is an umbrella for all user data including cookies, history, bookmarks, settings, etc. Each profile gives the user a separation of all these data elements. User Interface ============== - Wrench > "New window in profile" menu item, with sub-menu items. This new menu item has sub menu items for each existing profile, for up to 9 profiles, and one more sub menu item to launch a window in a new profile. The 9 sub-menu items also have the accelerators like CTRL + SHIFT + 1, CTRL + SHIFT + 2, etc. If there are more than 9 profiles, we will also show an extra sub-menu item, "Other...". - New Profile dialog box This dialog box is shown to the use when (s)he clicks Wrench > New window in profile > . It lets the user specify a profile name, and also shows a checkbox to create a desktop shortcut to launch Chrome in that profile. - Choose profile dialog box This dialog box lets the user select a profile from a drop down to open a new window in. It also has an item in the drop down, selecting which will show the new profile dialog box mentioned above. CTRL + M shortcut also launches this dialog box. Code Organization ================= chrome\browser\user_data_dir_profile_manager.h/.cc: This class provides an abstraction of profiles on top of the user data dir command line flag. chrome\browser\views\user_data_dir_new_profile_dialog.h/.cc New profile dialog box code. chrome\browser\views\user_data_dir_profiles_dialog.h/.cc Choose profile dialog box code. Review URL: http://codereview.chromium.org/12895 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6333 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/browser_main.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'chrome/browser/browser_main.cc') diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index ff87093..66c5f7f 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -39,6 +39,7 @@ #include "chrome/browser/rlz/rlz.h" #include "chrome/browser/shell_integration.h" #include "chrome/browser/url_fixer_upper.h" +#include "chrome/browser/user_data_manager.h" #include "chrome/browser/user_metrics.h" #include "chrome/browser/views/user_data_dir_dialog.h" #include "chrome/common/chrome_constants.h" @@ -323,6 +324,10 @@ int BrowserMain(CommandLine &parsed_command_line, // BrowserProcessImpl's constructor should set g_browser_process. DCHECK(g_browser_process); + std::wstring local_state_path; + PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); + bool local_state_file_exists = file_util::PathExists(local_state_path); + // Load local state. This includes the application locale so we know which // locale dll to load. PrefService* local_state = browser_process->local_state(); @@ -359,6 +364,27 @@ int BrowserMain(CommandLine &parsed_command_line, first_run_ui_bypass = true; } + // If the local state file for the current profile doesn't exist and the + // parent profile command line flag is present, then we should inherit some + // local state from the parent profile. + // Checking that the local state file for the current profile doesn't exist + // is the most robust way to determine whether we need to inherit or not + // since the parent profile command line flag can be present even when the + // current profile is not a new one, and in that case we do not want to + // inherit and reset the user's setting. + if (!local_state_file_exists && + parsed_command_line.HasSwitch(switches::kParentProfile)) { + std::wstring parent_profile = + parsed_command_line.GetSwitchValue(switches::kParentProfile); + PrefService parent_local_state(parent_profile); + parent_local_state.RegisterStringPref(prefs::kApplicationLocale, + std::wstring()); + // Right now, we only inherit the locale setting from the parent profile. + local_state->SetString( + prefs::kApplicationLocale, + parent_local_state.GetString(prefs::kApplicationLocale)); + } + ResourceBundle::InitSharedInstance( local_state->GetString(prefs::kApplicationLocale)); // We only load the theme dll in the browser process. @@ -378,6 +404,9 @@ int BrowserMain(CommandLine &parsed_command_line, tracking_objects = tracked_objects::ThreadData::StartTracking(true); #endif + // Initialize the shared instance of user data manager. + UserDataManager::Create(); + // Try to create/load the profile. ProfileManager* profile_manager = browser_process->profile_manager(); Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); -- cgit v1.1