| OLD | NEW |
| 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/profiles/profile.h" | 5 #include "chrome/browser/profiles/profile.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/browser/sync/profile_sync_service.h" | 11 #include "chrome/browser/sync/profile_sync_service.h" |
| 12 #include "chrome/browser/sync/sync_prefs.h" | 12 #include "chrome/browser/sync/sync_prefs.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "components/user_prefs/pref_registry_syncable.h" | 15 #include "components/user_prefs/pref_registry_syncable.h" |
| 16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "content/public/browser/web_ui.h" | 19 #include "content/public/browser/web_ui.h" |
| 20 | 20 |
| 21 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
| 22 #include "base/command_line.h" | 22 #include "base/command_line.h" |
| 23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 24 #include "chromeos/chromeos_switches.h" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 Profile::Profile() | 27 Profile::Profile() |
| 27 : restored_last_session_(false), | 28 : restored_last_session_(false), |
| 28 sent_destroyed_notification_(false), | 29 sent_destroyed_notification_(false), |
| 29 accessibility_pause_level_(0) { | 30 accessibility_pause_level_(0) { |
| 30 } | 31 } |
| 31 | 32 |
| 32 Profile::~Profile() { | 33 Profile::~Profile() { |
| 33 } | 34 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 std::string Profile::GetDebugName() { | 123 std::string Profile::GetDebugName() { |
| 123 std::string name = GetPath().BaseName().MaybeAsASCII(); | 124 std::string name = GetPath().BaseName().MaybeAsASCII(); |
| 124 if (name.empty()) { | 125 if (name.empty()) { |
| 125 name = "UnknownProfile"; | 126 name = "UnknownProfile"; |
| 126 } | 127 } |
| 127 return name; | 128 return name; |
| 128 } | 129 } |
| 129 | 130 |
| 130 bool Profile::IsGuestSession() const { | 131 bool Profile::IsGuestSession() const { |
| 131 #if defined(OS_CHROMEOS) | 132 #if defined(OS_CHROMEOS) |
| 132 static bool is_guest_session = | 133 static bool is_guest_session = CommandLine::ForCurrentProcess()->HasSwitch( |
| 133 CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession); | 134 chromeos::switches::kGuestSession); |
| 134 return is_guest_session; | 135 return is_guest_session; |
| 135 #else | 136 #else |
| 136 return false; | 137 return false; |
| 137 #endif | 138 #endif |
| 138 } | 139 } |
| 139 | 140 |
| 140 bool Profile::IsSyncAccessible() { | 141 bool Profile::IsSyncAccessible() { |
| 141 browser_sync::SyncPrefs prefs(GetPrefs()); | 142 browser_sync::SyncPrefs prefs(GetPrefs()); |
| 142 return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged(); | 143 return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged(); |
| 143 } | 144 } |
| 144 | 145 |
| 145 void Profile::MaybeSendDestroyedNotification() { | 146 void Profile::MaybeSendDestroyedNotification() { |
| 146 if (!sent_destroyed_notification_) { | 147 if (!sent_destroyed_notification_) { |
| 147 sent_destroyed_notification_ = true; | 148 sent_destroyed_notification_ = true; |
| 148 content::NotificationService::current()->Notify( | 149 content::NotificationService::current()->Notify( |
| 149 chrome::NOTIFICATION_PROFILE_DESTROYED, | 150 chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 150 content::Source<Profile>(this), | 151 content::Source<Profile>(this), |
| 151 content::NotificationService::NoDetails()); | 152 content::NotificationService::NoDetails()); |
| 152 } | 153 } |
| 153 } | 154 } |
| OLD | NEW |