| Index: chrome/browser/profiles/profile_manager_util.cc
|
| diff --git a/chrome/browser/profiles/profile_manager_util.cc b/chrome/browser/profiles/profile_manager_util.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..da0d042c1e0d5fbe915b0354682e6e62fce1a6cf
|
| --- /dev/null
|
| +++ b/chrome/browser/profiles/profile_manager_util.cc
|
| @@ -0,0 +1,88 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/profiles/profile_manager_util.h"
|
| +
|
| +#include "base/command_line.h"
|
| +#include "base/files/file_path.h"
|
| +#include "base/prefs/pref_registry_simple.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/ui/browser.h"
|
| +#include "chrome/common/chrome_constants.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| +#include "chrome/common/pref_names.h"
|
| +#include "content/public/browser/user_metrics.h"
|
| +
|
| +#if !defined(OS_IOS)
|
| +#include "chrome/browser/ui/browser_finder.h"
|
| +#include "chrome/browser/ui/browser_window.h"
|
| +#include "chrome/browser/ui/startup/startup_browser_creator.h"
|
| +#endif // !defined (OS_IOS)
|
| +
|
| +using content::UserMetricsAction;
|
| +
|
| +namespace profiles {
|
| +
|
| +bool IsMultipleProfilesEnabled() {
|
| +#if defined(OS_ANDROID)
|
| + return false;
|
| +#endif
|
| +#if defined(OS_CHROMEOS)
|
| + if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles))
|
| + return false;
|
| +#endif
|
| +
|
| + return true;
|
| +}
|
| +
|
| +base::FilePath GetDefaultProfileDir(
|
| + const base::FilePath& user_data_dir) {
|
| + base::FilePath default_profile_dir(user_data_dir);
|
| + default_profile_dir =
|
| + default_profile_dir.AppendASCII(chrome::kInitialProfile);
|
| + return default_profile_dir;
|
| +}
|
| +
|
| +base::FilePath GetProfilePrefsPath(
|
| + const base::FilePath &profile_dir) {
|
| + base::FilePath default_prefs_path(profile_dir);
|
| + default_prefs_path = default_prefs_path.Append(chrome::kPreferencesFilename);
|
| + return default_prefs_path;
|
| +}
|
| +
|
| +void RegisterPrefs(PrefRegistrySimple* registry) {
|
| + registry->RegisterStringPref(prefs::kProfileLastUsed, std::string());
|
| + registry->RegisterIntegerPref(prefs::kProfilesNumCreated, 1);
|
| + registry->RegisterListPref(prefs::kProfilesLastActive);
|
| +}
|
| +
|
| +void FindOrCreateNewWindowForProfile(
|
| + Profile* profile,
|
| + chrome::startup::IsProcessStartup process_startup,
|
| + chrome::startup::IsFirstRun is_first_run,
|
| + chrome::HostDesktopType desktop_type,
|
| + bool always_create) {
|
| +#if defined(OS_IOS)
|
| + NOTREACHED();
|
| +#else
|
| + DCHECK(profile);
|
| +
|
| + if (!always_create) {
|
| + Browser* browser = chrome::FindTabbedBrowser(profile, false, desktop_type);
|
| + if (browser) {
|
| + browser->window()->Activate();
|
| + return;
|
| + }
|
| + }
|
| +
|
| + content::RecordAction(UserMetricsAction("NewWindow"));
|
| + CommandLine command_line(CommandLine::NO_PROGRAM);
|
| + int return_code;
|
| + StartupBrowserCreator browser_creator;
|
| + browser_creator.LaunchBrowser(command_line, profile, base::FilePath(),
|
| + process_startup, is_first_run, &return_code);
|
| +#endif // defined(OS_IOS)
|
| +}
|
| +
|
| +} // namespace profiles
|
|
|