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

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

Issue 12090062: Enable profile switching for standalone App Launcher via the Settings App. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disable tests on aura Created 7 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
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 #include "chrome/browser/profiles/profile.h" 85 #include "chrome/browser/profiles/profile.h"
86 #include "chrome/browser/profiles/profile_manager.h" 86 #include "chrome/browser/profiles/profile_manager.h"
87 #include "chrome/browser/search_engines/search_engine_type.h" 87 #include "chrome/browser/search_engines/search_engine_type.h"
88 #include "chrome/browser/search_engines/template_url.h" 88 #include "chrome/browser/search_engines/template_url.h"
89 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 89 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
90 #include "chrome/browser/search_engines/template_url_service.h" 90 #include "chrome/browser/search_engines/template_url_service.h"
91 #include "chrome/browser/search_engines/template_url_service_factory.h" 91 #include "chrome/browser/search_engines/template_url_service_factory.h"
92 #include "chrome/browser/service/service_process_control.h" 92 #include "chrome/browser/service/service_process_control.h"
93 #include "chrome/browser/shell_integration.h" 93 #include "chrome/browser/shell_integration.h"
94 #include "chrome/browser/translate/translate_manager.h" 94 #include "chrome/browser/translate/translate_manager.h"
95 #include "chrome/browser/ui/app_list/app_list_util.h"
95 #include "chrome/browser/ui/browser.h" 96 #include "chrome/browser/ui/browser.h"
96 #include "chrome/browser/ui/browser_finder.h" 97 #include "chrome/browser/ui/browser_finder.h"
97 #include "chrome/browser/ui/startup/default_browser_prompt.h" 98 #include "chrome/browser/ui/startup/default_browser_prompt.h"
98 #include "chrome/browser/ui/startup/startup_browser_creator.h" 99 #include "chrome/browser/ui/startup/startup_browser_creator.h"
99 #include "chrome/browser/ui/uma_browsing_activity_observer.h" 100 #include "chrome/browser/ui/uma_browsing_activity_observer.h"
100 #include "chrome/browser/ui/user_data_dir_dialog.h" 101 #include "chrome/browser/ui/user_data_dir_dialog.h"
101 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" 102 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
102 #include "chrome/common/child_process_logging.h" 103 #include "chrome/common/child_process_logging.h"
103 #include "chrome/common/chrome_constants.h" 104 #include "chrome/common/chrome_constants.h"
104 #include "chrome/common/chrome_paths.h" 105 #include "chrome/common/chrome_paths.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 local_state->GetString(prefs::kApplicationLocale) != owner_locale && 323 local_state->GetString(prefs::kApplicationLocale) != owner_locale &&
323 !local_state->IsManagedPreference(prefs::kApplicationLocale)) { 324 !local_state->IsManagedPreference(prefs::kApplicationLocale)) {
324 local_state->SetString(prefs::kApplicationLocale, owner_locale); 325 local_state->SetString(prefs::kApplicationLocale, owner_locale);
325 } 326 }
326 } 327 }
327 #endif 328 #endif
328 329
329 return local_state; 330 return local_state;
330 } 331 }
331 332
333 // Returns the path that contains the profile that should be loaded
334 // on process startup.
335 FilePath GetStartupProfilePath(const FilePath& user_data_dir,
336 const CommandLine& command_line) {
337 if (command_line.HasSwitch(switches::kProfileDirectory)) {
338 return user_data_dir.Append(
339 command_line.GetSwitchValuePath(switches::kProfileDirectory));
340 }
341
342 #if defined(ENABLE_APP_LIST)
343 // If we are showing the app list then chrome isn't shown so load the app
344 // list's profile rather than chrome's.
345 if (command_line.HasSwitch(switches::kShowAppList))
346 return chrome::GetAppListProfilePath(user_data_dir);
347 #endif
348
349 return g_browser_process->profile_manager()->GetLastUsedProfileDir(
350 user_data_dir);
351 }
352
332 // Initializes the profile, possibly doing some user prompting to pick a 353 // Initializes the profile, possibly doing some user prompting to pick a
333 // fallback profile. Returns the newly created profile, or NULL if startup 354 // fallback profile. Returns the newly created profile, or NULL if startup
334 // should not continue. 355 // should not continue.
335 Profile* CreateProfile(const content::MainFunctionParams& parameters, 356 Profile* CreateProfile(const content::MainFunctionParams& parameters,
336 const FilePath& user_data_dir, 357 const FilePath& user_data_dir,
337 const CommandLine& parsed_command_line) { 358 const CommandLine& parsed_command_line) {
338 Profile* profile;
339 if (ProfileManager::IsMultipleProfilesEnabled() && 359 if (ProfileManager::IsMultipleProfilesEnabled() &&
340 parsed_command_line.HasSwitch(switches::kProfileDirectory)) { 360 parsed_command_line.HasSwitch(switches::kProfileDirectory)) {
341 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, 361 g_browser_process->local_state()->SetString(prefs::kProfileLastUsed,
342 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory)); 362 parsed_command_line.GetSwitchValueASCII(switches::kProfileDirectory));
343 // Clear kProfilesLastActive since the user only wants to launch a specific 363 // Clear kProfilesLastActive since the user only wants to launch a specific
344 // profile. 364 // profile.
345 ListPrefUpdate update(g_browser_process->local_state(), 365 ListPrefUpdate update(g_browser_process->local_state(),
346 prefs::kProfilesLastActive); 366 prefs::kProfilesLastActive);
347 ListValue* profile_list = update.Get(); 367 ListValue* profile_list = update.Get();
348 profile_list->Clear(); 368 profile_list->Clear();
349 } 369 }
370
371 Profile* profile = NULL;
350 #if defined(OS_CHROMEOS) 372 #if defined(OS_CHROMEOS)
351 // TODO(ivankr): http://crbug.com/83792 373 // TODO(ivankr): http://crbug.com/83792
352 profile = g_browser_process->profile_manager()->GetDefaultProfile( 374 profile = g_browser_process->profile_manager()->GetDefaultProfile(
353 user_data_dir); 375 user_data_dir);
354 #else 376 #else
355 profile = g_browser_process->profile_manager()->GetLastUsedProfile( 377 FilePath profile_path =
356 user_data_dir); 378 GetStartupProfilePath(user_data_dir, parsed_command_line);
379 profile = g_browser_process->profile_manager()->GetProfile(
380 profile_path);
357 #endif 381 #endif
358 if (profile) 382 if (profile)
359 return profile; 383 return profile;
360 384
361 #if defined(OS_WIN) 385 #if defined(OS_WIN)
362 #if defined(USE_AURA) 386 #if defined(USE_AURA)
363 // TODO(beng): 387 // TODO(beng):
364 NOTIMPLEMENTED(); 388 NOTIMPLEMENTED();
365 #else 389 #else
366 // Ideally, we should be able to run w/o access to disk. For now, we 390 // Ideally, we should be able to run w/o access to disk. For now, we
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 // We should never be called before the profile has been created. 487 // We should never be called before the profile has been created.
464 NOTREACHED(); 488 NOTREACHED();
465 return true; 489 return true;
466 } 490 }
467 491
468 extensions::StartupHelper extension_startup_helper; 492 extensions::StartupHelper extension_startup_helper;
469 extension_startup_helper.UninstallExtension(command_line, profile); 493 extension_startup_helper.UninstallExtension(command_line, profile);
470 return true; 494 return true;
471 } 495 }
472 496
497 FilePath user_data_dir =
498 g_browser_process->profile_manager()->user_data_dir();
499 FilePath startup_profile_dir =
500 GetStartupProfilePath(user_data_dir, command_line);
501
473 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( 502 StartupBrowserCreator::ProcessCommandLineAlreadyRunning(
474 command_line, current_directory); 503 command_line, current_directory, startup_profile_dir);
475 return true; 504 return true;
476 } 505 }
477 506
478 void LaunchDevToolsHandlerIfNeeded(Profile* profile, 507 void LaunchDevToolsHandlerIfNeeded(Profile* profile,
479 const CommandLine& command_line) { 508 const CommandLine& command_line) {
480 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { 509 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) {
481 std::string port_str = 510 std::string port_str =
482 command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort); 511 command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort);
483 int port; 512 int port;
484 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { 513 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) {
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 if (base::win::GetVersion() <= base::win::VERSION_XP) 1758 if (base::win::GetVersion() <= base::win::VERSION_XP)
1730 uma_name += "_XP"; 1759 uma_name += "_XP";
1731 1760
1732 uma_name += "_PreRead_"; 1761 uma_name += "_PreRead_";
1733 uma_name += pre_read_percentage; 1762 uma_name += pre_read_percentage;
1734 AddPreReadHistogramTime(uma_name.c_str(), time); 1763 AddPreReadHistogramTime(uma_name.c_str(), time);
1735 } 1764 }
1736 #endif 1765 #endif
1737 #endif 1766 #endif
1738 } 1767 }
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/extensions/extension_install_ui_default.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698