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

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

Issue 12895: Chromium-MultiProfile-Prototype... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years 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 | « chrome/browser/browser.vcproj ('k') | chrome/browser/browser_process.h » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <windows.h> 5 #include <windows.h>
6 #include <shellapi.h> 6 #include <shellapi.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 21 matching lines...) Expand all
32 #include "chrome/browser/first_run.h" 32 #include "chrome/browser/first_run.h"
33 #include "chrome/browser/jankometer.h" 33 #include "chrome/browser/jankometer.h"
34 #include "chrome/browser/metrics_service.h" 34 #include "chrome/browser/metrics_service.h"
35 #include "chrome/browser/net/dns_global.h" 35 #include "chrome/browser/net/dns_global.h"
36 #include "chrome/browser/net/sdch_dictionary_fetcher.h" 36 #include "chrome/browser/net/sdch_dictionary_fetcher.h"
37 #include "chrome/browser/plugin_service.h" 37 #include "chrome/browser/plugin_service.h"
38 #include "chrome/browser/printing/print_job_manager.h" 38 #include "chrome/browser/printing/print_job_manager.h"
39 #include "chrome/browser/rlz/rlz.h" 39 #include "chrome/browser/rlz/rlz.h"
40 #include "chrome/browser/shell_integration.h" 40 #include "chrome/browser/shell_integration.h"
41 #include "chrome/browser/url_fixer_upper.h" 41 #include "chrome/browser/url_fixer_upper.h"
42 #include "chrome/browser/user_data_manager.h"
42 #include "chrome/browser/user_metrics.h" 43 #include "chrome/browser/user_metrics.h"
43 #include "chrome/browser/views/user_data_dir_dialog.h" 44 #include "chrome/browser/views/user_data_dir_dialog.h"
44 #include "chrome/common/chrome_constants.h" 45 #include "chrome/common/chrome_constants.h"
45 #include "chrome/common/chrome_paths.h" 46 #include "chrome/common/chrome_paths.h"
46 #include "chrome/common/chrome_switches.h" 47 #include "chrome/common/chrome_switches.h"
47 #include "chrome/common/env_vars.h" 48 #include "chrome/common/env_vars.h"
48 #include "chrome/common/jstemplate_builder.h" 49 #include "chrome/common/jstemplate_builder.h"
49 #include "chrome/common/l10n_util.h" 50 #include "chrome/common/l10n_util.h"
50 #include "chrome/common/resource_bundle.h" 51 #include "chrome/common/resource_bundle.h"
51 #include "chrome/common/pref_names.h" 52 #include "chrome/common/pref_names.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // instantiated (as it makes a URLRequest and we don't have an IO thread, 317 // instantiated (as it makes a URLRequest and we don't have an IO thread,
317 // see bug #1292702). 318 // see bug #1292702).
318 browser_process.reset(new FirstRunBrowserProcess(parsed_command_line)); 319 browser_process.reset(new FirstRunBrowserProcess(parsed_command_line));
319 } else { 320 } else {
320 browser_process.reset(new BrowserProcessImpl(parsed_command_line)); 321 browser_process.reset(new BrowserProcessImpl(parsed_command_line));
321 } 322 }
322 323
323 // BrowserProcessImpl's constructor should set g_browser_process. 324 // BrowserProcessImpl's constructor should set g_browser_process.
324 DCHECK(g_browser_process); 325 DCHECK(g_browser_process);
325 326
327 std::wstring local_state_path;
328 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
329 bool local_state_file_exists = file_util::PathExists(local_state_path);
330
326 // Load local state. This includes the application locale so we know which 331 // Load local state. This includes the application locale so we know which
327 // locale dll to load. 332 // locale dll to load.
328 PrefService* local_state = browser_process->local_state(); 333 PrefService* local_state = browser_process->local_state();
329 DCHECK(local_state); 334 DCHECK(local_state);
330 335
331 bool is_first_run = FirstRun::IsChromeFirstRun() || 336 bool is_first_run = FirstRun::IsChromeFirstRun() ||
332 parsed_command_line.HasSwitch(switches::kFirstRun); 337 parsed_command_line.HasSwitch(switches::kFirstRun);
333 bool first_run_ui_bypass = false; 338 bool first_run_ui_bypass = false;
334 339
335 // Initialize ResourceBundle which handles files loaded from external 340 // Initialize ResourceBundle which handles files loaded from external
(...skipping 16 matching lines...) Expand all
352 first_run_ui_bypass = 357 first_run_ui_bypass =
353 !FirstRun::ProcessMasterPreferences(user_data_dir, 358 !FirstRun::ProcessMasterPreferences(user_data_dir,
354 std::wstring(), NULL); 359 std::wstring(), NULL);
355 360
356 // If we are running in App mode, we do not want to show the importer 361 // If we are running in App mode, we do not want to show the importer
357 // (first run) UI. 362 // (first run) UI.
358 if (!first_run_ui_bypass && parsed_command_line.HasSwitch(switches::kApp)) 363 if (!first_run_ui_bypass && parsed_command_line.HasSwitch(switches::kApp))
359 first_run_ui_bypass = true; 364 first_run_ui_bypass = true;
360 } 365 }
361 366
367 // If the local state file for the current profile doesn't exist and the
368 // parent profile command line flag is present, then we should inherit some
369 // local state from the parent profile.
370 // Checking that the local state file for the current profile doesn't exist
371 // is the most robust way to determine whether we need to inherit or not
372 // since the parent profile command line flag can be present even when the
373 // current profile is not a new one, and in that case we do not want to
374 // inherit and reset the user's setting.
375 if (!local_state_file_exists &&
376 parsed_command_line.HasSwitch(switches::kParentProfile)) {
377 std::wstring parent_profile =
378 parsed_command_line.GetSwitchValue(switches::kParentProfile);
379 PrefService parent_local_state(parent_profile);
380 parent_local_state.RegisterStringPref(prefs::kApplicationLocale,
381 std::wstring());
382 // Right now, we only inherit the locale setting from the parent profile.
383 local_state->SetString(
384 prefs::kApplicationLocale,
385 parent_local_state.GetString(prefs::kApplicationLocale));
386 }
387
362 ResourceBundle::InitSharedInstance( 388 ResourceBundle::InitSharedInstance(
363 local_state->GetString(prefs::kApplicationLocale)); 389 local_state->GetString(prefs::kApplicationLocale));
364 // We only load the theme dll in the browser process. 390 // We only load the theme dll in the browser process.
365 ResourceBundle::GetSharedInstance().LoadThemeResources(); 391 ResourceBundle::GetSharedInstance().LoadThemeResources();
366 392
367 if (!parsed_command_line.HasSwitch(switches::kNoErrorDialogs)) { 393 if (!parsed_command_line.HasSwitch(switches::kNoErrorDialogs)) {
368 // Display a warning if the user is running windows 2000. 394 // Display a warning if the user is running windows 2000.
369 CheckForWin2000(); 395 CheckForWin2000();
370 } 396 }
371 397
372 // Initialize histogram statistics gathering system. 398 // Initialize histogram statistics gathering system.
373 StatisticsRecorder statistics; 399 StatisticsRecorder statistics;
374 400
375 // Start tracking the creation and deletion of Task instances 401 // Start tracking the creation and deletion of Task instances
376 bool tracking_objects = false; 402 bool tracking_objects = false;
377 #ifdef TRACK_ALL_TASK_OBJECTS 403 #ifdef TRACK_ALL_TASK_OBJECTS
378 tracking_objects = tracked_objects::ThreadData::StartTracking(true); 404 tracking_objects = tracked_objects::ThreadData::StartTracking(true);
379 #endif 405 #endif
380 406
407 // Initialize the shared instance of user data manager.
408 UserDataManager::Create();
409
381 // Try to create/load the profile. 410 // Try to create/load the profile.
382 ProfileManager* profile_manager = browser_process->profile_manager(); 411 ProfileManager* profile_manager = browser_process->profile_manager();
383 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); 412 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir);
384 if (!profile) { 413 if (!profile) {
385 user_data_dir = UserDataDirDialog::RunUserDataDirDialog(user_data_dir); 414 user_data_dir = UserDataDirDialog::RunUserDataDirDialog(user_data_dir);
386 // Flush the message loop which lets the UserDataDirDialog close. 415 // Flush the message loop which lets the UserDataDirDialog close.
387 MessageLoop::current()->Run(); 416 MessageLoop::current()->Run();
388 417
389 ResourceBundle::CleanupSharedInstance(); 418 ResourceBundle::CleanupSharedInstance();
390 419
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 // The following should ONLY be called when in single threaded mode. It is 629 // The following should ONLY be called when in single threaded mode. It is
601 // unsafe to do this cleanup if other threads are still active. 630 // unsafe to do this cleanup if other threads are still active.
602 // It is also very unnecessary, so I'm only doing this in debug to satisfy 631 // It is also very unnecessary, so I'm only doing this in debug to satisfy
603 // purify. 632 // purify.
604 if (tracking_objects) 633 if (tracking_objects)
605 tracked_objects::ThreadData::ShutdownSingleThreadedCleanup(); 634 tracked_objects::ThreadData::ShutdownSingleThreadedCleanup();
606 #endif // NDEBUG 635 #endif // NDEBUG
607 636
608 return result_code; 637 return result_code;
609 } 638 }
OLDNEW
« no previous file with comments | « chrome/browser/browser.vcproj ('k') | chrome/browser/browser_process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698