This source file includes following definitions.
- accessibility_pause_level_
- FromBrowserContext
- FromWebUI
- AsTestingProfile
- RegisterProfilePrefs
- GetDebugName
- IsGuestSession
- IsNewProfile
- IsSyncAccessible
- MaybeSendDestroyedNotification
#include "chrome/browser/profiles/profile.h"
#include <string>
#include "base/prefs/pref_service.h"
#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/pref_names.h"
#include "components/sync_driver/sync_prefs.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "extensions/browser/pref_names.h"
#if defined(OS_CHROMEOS)
#include "base/command_line.h"
#include "chrome/common/chrome_switches.h"
#include "chromeos/chromeos_switches.h"
#endif
Profile::Profile()
: restored_last_session_(false),
sent_destroyed_notification_(false),
accessibility_pause_level_(0) {
}
Profile::~Profile() {
}
Profile* Profile::FromBrowserContext(content::BrowserContext* browser_context) {
return static_cast<Profile*>(browser_context);
}
Profile* Profile::FromWebUI(content::WebUI* web_ui) {
return FromBrowserContext(web_ui->GetWebContents()->GetBrowserContext());
}
TestingProfile* Profile::AsTestingProfile() {
return NULL;
}
Profile::Delegate::~Delegate() {
}
const char Profile::kProfileKey[] = "__PROFILE__";
void Profile::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(
prefs::kSearchSuggestEnabled,
true,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
#if defined(OS_ANDROID)
registry->RegisterIntegerPref(
prefs::kContextualSearchEnabled,
0,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
#endif
registry->RegisterBooleanPref(
prefs::kSessionExitedCleanly,
true,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterStringPref(
prefs::kSessionExitType,
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kSafeBrowsingEnabled,
true,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kSafeBrowsingDownloadFeedbackEnabled,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kSafeBrowsingReportingEnabled,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kSafeBrowsingProceedAnywayDisabled,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
#if defined(ENABLE_GOOGLE_NOW)
registry->RegisterBooleanPref(
prefs::kGoogleGeolocationAccessEnabled,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
#endif
registry->RegisterBooleanPref(
prefs::kDisableExtensions,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
extensions::pref_names::kAlertsInitialized,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterStringPref(
prefs::kSelectFileLastDirectory,
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterDoublePref(
prefs::kDefaultZoomLevel,
0.0,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterDictionaryPref(
prefs::kPerHostZoomLevels,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterStringPref(
prefs::kDefaultApps,
"install",
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kSpeechRecognitionFilterProfanities,
true,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterIntegerPref(
prefs::kProfileIconVersion,
0,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
#if defined(OS_CHROMEOS)
registry->RegisterStringPref(
prefs::kApplicationLocale,
std::string(),
user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF);
registry->RegisterStringPref(
prefs::kApplicationLocaleBackup,
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterStringPref(
prefs::kApplicationLocaleAccepted,
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
#endif
#if defined(OS_ANDROID)
registry->RegisterBooleanPref(
prefs::kDevToolsRemoteEnabled,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
#endif
#if defined(OS_ANDROID) || defined(OS_IOS)
registry->RegisterBooleanPref(
prefs::kSpdyProxyAuthEnabled,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kSpdyProxyAuthWasEnabledBefore,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
#endif
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) && !defined(OS_IOS)
registry->RegisterIntegerPref(
prefs::kProfileAvatarTutorialShown,
0,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kProfileUserManagerTutorialShown,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
#endif
}
std::string Profile::GetDebugName() {
std::string name = GetPath().BaseName().MaybeAsASCII();
if (name.empty()) {
name = "UnknownProfile";
}
return name;
}
bool Profile::IsGuestSession() const {
#if defined(OS_CHROMEOS)
static bool is_guest_session = CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kGuestSession);
return is_guest_session;
#else
return GetPath() == ProfileManager::GetGuestProfilePath();
#endif
}
bool Profile::IsNewProfile() {
return GetOriginalProfile()->GetPrefs()->GetInitializationStatus() ==
PrefService::INITIALIZATION_STATUS_CREATED_NEW_PREF_STORE;
}
bool Profile::IsSyncAccessible() {
if (ProfileSyncServiceFactory::HasProfileSyncService(this))
return !ProfileSyncServiceFactory::GetForProfile(this)->IsManaged();
sync_driver::SyncPrefs prefs(GetPrefs());
return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged();
}
void Profile::MaybeSendDestroyedNotification() {
if (!sent_destroyed_notification_) {
sent_destroyed_notification_ = true;
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PROFILE_DESTROYED,
content::Source<Profile>(this),
content::NotificationService::NoDetails());
}
}