| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/profiles/profile_manager_util.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" |
| 9 #include "base/prefs/pref_registry_simple.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/common/chrome_constants.h" |
| 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/pref_names.h" |
| 15 #include "content/public/browser/user_metrics.h" |
| 16 |
| 17 #if !defined(OS_IOS) |
| 18 #include "chrome/browser/ui/browser_finder.h" |
| 19 #include "chrome/browser/ui/browser_window.h" |
| 20 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 21 #endif // !defined (OS_IOS) |
| 22 |
| 23 using content::UserMetricsAction; |
| 24 |
| 25 namespace profiles { |
| 26 |
| 27 bool IsMultipleProfilesEnabled() { |
| 28 #if defined(OS_ANDROID) |
| 29 return false; |
| 30 #endif |
| 31 #if defined(OS_CHROMEOS) |
| 32 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles)) |
| 33 return false; |
| 34 #endif |
| 35 |
| 36 return true; |
| 37 } |
| 38 |
| 39 base::FilePath GetDefaultProfileDir( |
| 40 const base::FilePath& user_data_dir) { |
| 41 base::FilePath default_profile_dir(user_data_dir); |
| 42 default_profile_dir = |
| 43 default_profile_dir.AppendASCII(chrome::kInitialProfile); |
| 44 return default_profile_dir; |
| 45 } |
| 46 |
| 47 base::FilePath GetProfilePrefsPath( |
| 48 const base::FilePath &profile_dir) { |
| 49 base::FilePath default_prefs_path(profile_dir); |
| 50 default_prefs_path = default_prefs_path.Append(chrome::kPreferencesFilename); |
| 51 return default_prefs_path; |
| 52 } |
| 53 |
| 54 void RegisterPrefs(PrefRegistrySimple* registry) { |
| 55 registry->RegisterStringPref(prefs::kProfileLastUsed, std::string()); |
| 56 registry->RegisterIntegerPref(prefs::kProfilesNumCreated, 1); |
| 57 registry->RegisterListPref(prefs::kProfilesLastActive); |
| 58 } |
| 59 |
| 60 void FindOrCreateNewWindowForProfile( |
| 61 Profile* profile, |
| 62 chrome::startup::IsProcessStartup process_startup, |
| 63 chrome::startup::IsFirstRun is_first_run, |
| 64 chrome::HostDesktopType desktop_type, |
| 65 bool always_create) { |
| 66 #if defined(OS_IOS) |
| 67 NOTREACHED(); |
| 68 #else |
| 69 DCHECK(profile); |
| 70 |
| 71 if (!always_create) { |
| 72 Browser* browser = chrome::FindTabbedBrowser(profile, false, desktop_type); |
| 73 if (browser) { |
| 74 browser->window()->Activate(); |
| 75 return; |
| 76 } |
| 77 } |
| 78 |
| 79 content::RecordAction(UserMetricsAction("NewWindow")); |
| 80 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 81 int return_code; |
| 82 StartupBrowserCreator browser_creator; |
| 83 browser_creator.LaunchBrowser(command_line, profile, base::FilePath(), |
| 84 process_startup, is_first_run, &return_code); |
| 85 #endif // defined(OS_IOS) |
| 86 } |
| 87 |
| 88 } // namespace profiles |
| OLD | NEW |