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

Side by Side Diff: chrome/browser/profiles/profile_manager_util.cc

Issue 18615010: Refactor utility methods out of the ProfileManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix CrOS compile error Created 7 years, 5 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
(Empty)
1 // Copyright (c) 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/ui/browser.h"
11 #include "chrome/common/chrome_constants.h"
12 #include "chrome/common/pref_names.h"
13 #include "content/public/browser/user_metrics.h"
14
15 #if !defined(OS_IOS)
16 #include "chrome/browser/ui/browser_finder.h"
17 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/browser/ui/startup/startup_browser_creator.h"
19 #endif // !defined (OS_IOS)
20
21 #if defined(OS_CHROMEOS)
22 #include "chromeos/chromeos_switches.h"
23 #endif
24
25 using content::UserMetricsAction;
26
27 namespace profiles {
28
29 bool IsMultipleProfilesEnabled() {
30 #if defined(OS_ANDROID)
31 return false;
32 #endif
33 #if defined(OS_CHROMEOS)
34 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles))
35 return false;
36 #endif
37
38 return true;
39 }
40
41 base::FilePath GetDefaultProfileDir(
42 const base::FilePath& user_data_dir) {
43 base::FilePath default_profile_dir(user_data_dir);
44 default_profile_dir =
45 default_profile_dir.AppendASCII(chrome::kInitialProfile);
46 return default_profile_dir;
47 }
48
49 base::FilePath GetProfilePrefsPath(
50 const base::FilePath &profile_dir) {
51 base::FilePath default_prefs_path(profile_dir);
52 default_prefs_path = default_prefs_path.Append(chrome::kPreferencesFilename);
53 return default_prefs_path;
54 }
55
56 void RegisterPrefs(PrefRegistrySimple* registry) {
57 registry->RegisterStringPref(prefs::kProfileLastUsed, std::string());
58 registry->RegisterIntegerPref(prefs::kProfilesNumCreated, 1);
59 registry->RegisterListPref(prefs::kProfilesLastActive);
60 }
61
62 void FindOrCreateNewWindowForProfile(
63 Profile* profile,
64 chrome::startup::IsProcessStartup process_startup,
65 chrome::startup::IsFirstRun is_first_run,
66 chrome::HostDesktopType desktop_type,
67 bool always_create) {
68 #if defined(OS_IOS)
69 NOTREACHED();
70 #else
71 DCHECK(profile);
72
73 if (!always_create) {
74 Browser* browser = chrome::FindTabbedBrowser(profile, false, desktop_type);
75 if (browser) {
76 browser->window()->Activate();
77 return;
78 }
79 }
80
81 content::RecordAction(UserMetricsAction("NewWindow"));
82 CommandLine command_line(CommandLine::NO_PROGRAM);
83 int return_code;
84 StartupBrowserCreator browser_creator;
85 browser_creator.LaunchBrowser(command_line, profile, base::FilePath(),
86 process_startup, is_first_run, &return_code);
87 #endif // defined(OS_IOS)
88 }
89
90 } // namespace profiles
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698