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

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

Issue 12079097: Introduce PrefRegistrySyncable, simplifying PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add to PrefRegistrySyncable and PrefServiceSyncable to let sync know of pre-registered prefs. Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
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 "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/prefs/pref_registry_syncable.h"
10 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/sync/profile_sync_service.h" 12 #include "chrome/browser/sync/profile_sync_service.h"
12 #include "chrome/browser/sync/sync_prefs.h" 13 #include "chrome/browser/sync/sync_prefs.h"
13 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "content/public/browser/notification_service.h" 16 #include "content/public/browser/notification_service.h"
16 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "content/public/browser/web_ui.h" 19 #include "content/public/browser/web_ui.h"
19 20
(...skipping 20 matching lines...) Expand all
40 } 41 }
41 42
42 TestingProfile* Profile::AsTestingProfile() { 43 TestingProfile* Profile::AsTestingProfile() {
43 return NULL; 44 return NULL;
44 } 45 }
45 46
46 // static 47 // static
47 const char* const Profile::kProfileKey = "__PROFILE__"; 48 const char* const Profile::kProfileKey = "__PROFILE__";
48 49
49 // static 50 // static
50 void Profile::RegisterUserPrefs(PrefServiceSyncable* prefs) { 51 void Profile::RegisterUserPrefs(PrefRegistrySyncable* registry) {
51 prefs->RegisterBooleanPref(prefs::kSearchSuggestEnabled, 52 registry->RegisterBooleanPref(prefs::kSearchSuggestEnabled,
52 true, 53 true,
53 PrefServiceSyncable::SYNCABLE_PREF); 54 PrefRegistrySyncable::SYNCABLE_PREF);
54 prefs->RegisterBooleanPref(prefs::kSessionExitedCleanly, 55 registry->RegisterBooleanPref(prefs::kSessionExitedCleanly,
55 true, 56 true,
56 PrefServiceSyncable::UNSYNCABLE_PREF); 57 PrefRegistrySyncable::UNSYNCABLE_PREF);
57 prefs->RegisterStringPref(prefs::kSessionExitType, 58 registry->RegisterStringPref(prefs::kSessionExitType,
58 std::string(), 59 std::string(),
59 PrefServiceSyncable::UNSYNCABLE_PREF); 60 PrefRegistrySyncable::UNSYNCABLE_PREF);
60 prefs->RegisterBooleanPref(prefs::kSafeBrowsingEnabled, 61 registry->RegisterBooleanPref(prefs::kSafeBrowsingEnabled,
61 true, 62 true,
62 PrefServiceSyncable::SYNCABLE_PREF); 63 PrefRegistrySyncable::SYNCABLE_PREF);
63 prefs->RegisterBooleanPref(prefs::kSafeBrowsingReportingEnabled, 64 registry->RegisterBooleanPref(prefs::kSafeBrowsingReportingEnabled,
64 false, 65 false,
65 PrefServiceSyncable::UNSYNCABLE_PREF); 66 PrefRegistrySyncable::UNSYNCABLE_PREF);
66 prefs->RegisterBooleanPref(prefs::kSafeBrowsingProceedAnywayDisabled, 67 registry->RegisterBooleanPref(prefs::kSafeBrowsingProceedAnywayDisabled,
67 false, 68 false,
68 PrefServiceSyncable::UNSYNCABLE_PREF); 69 PrefRegistrySyncable::UNSYNCABLE_PREF);
69 prefs->RegisterBooleanPref(prefs::kDisableExtensions, 70 registry->RegisterBooleanPref(prefs::kDisableExtensions,
70 false, 71 false,
71 PrefServiceSyncable::UNSYNCABLE_PREF); 72 PrefRegistrySyncable::UNSYNCABLE_PREF);
72 prefs->RegisterBooleanPref(prefs::kExtensionAlertsInitializedPref, 73 registry->RegisterBooleanPref(prefs::kExtensionAlertsInitializedPref,
73 false, PrefServiceSyncable::UNSYNCABLE_PREF); 74 false, PrefRegistrySyncable::UNSYNCABLE_PREF);
74 prefs->RegisterStringPref(prefs::kSelectFileLastDirectory, 75 registry->RegisterStringPref(prefs::kSelectFileLastDirectory,
75 std::string(), 76 std::string(),
76 PrefServiceSyncable::UNSYNCABLE_PREF); 77 PrefRegistrySyncable::UNSYNCABLE_PREF);
77 prefs->RegisterDoublePref(prefs::kDefaultZoomLevel, 78 registry->RegisterDoublePref(prefs::kDefaultZoomLevel,
78 0.0, 79 0.0,
79 PrefServiceSyncable::UNSYNCABLE_PREF); 80 PrefRegistrySyncable::UNSYNCABLE_PREF);
80 prefs->RegisterDictionaryPref(prefs::kPerHostZoomLevels, 81 registry->RegisterDictionaryPref(prefs::kPerHostZoomLevels,
81 PrefServiceSyncable::UNSYNCABLE_PREF); 82 PrefRegistrySyncable::UNSYNCABLE_PREF);
82 prefs->RegisterStringPref(prefs::kDefaultApps, 83 registry->RegisterStringPref(prefs::kDefaultApps,
83 "install", 84 "install",
84 PrefServiceSyncable::UNSYNCABLE_PREF); 85 PrefRegistrySyncable::UNSYNCABLE_PREF);
85 #if defined(OS_CHROMEOS) 86 #if defined(OS_CHROMEOS)
86 // TODO(dilmah): For OS_CHROMEOS we maintain kApplicationLocale in both 87 // TODO(dilmah): For OS_CHROMEOS we maintain kApplicationLocale in both
87 // local state and user's profile. For other platforms we maintain 88 // local state and user's profile. For other platforms we maintain
88 // kApplicationLocale only in local state. 89 // kApplicationLocale only in local state.
89 // In the future we may want to maintain kApplicationLocale 90 // In the future we may want to maintain kApplicationLocale
90 // in user's profile for other platforms as well. 91 // in user's profile for other platforms as well.
91 prefs->RegisterStringPref(prefs::kApplicationLocale, 92 registry->RegisterStringPref(prefs::kApplicationLocale,
92 std::string(), 93 std::string(),
93 PrefServiceSyncable::SYNCABLE_PREF); 94 PrefRegistrySyncable::SYNCABLE_PREF);
94 prefs->RegisterStringPref(prefs::kApplicationLocaleBackup, 95 registry->RegisterStringPref(prefs::kApplicationLocaleBackup,
95 std::string(), 96 std::string(),
96 PrefServiceSyncable::UNSYNCABLE_PREF); 97 PrefRegistrySyncable::UNSYNCABLE_PREF);
97 prefs->RegisterStringPref(prefs::kApplicationLocaleAccepted, 98 registry->RegisterStringPref(prefs::kApplicationLocaleAccepted,
98 std::string(), 99 std::string(),
99 PrefServiceSyncable::UNSYNCABLE_PREF); 100 PrefRegistrySyncable::UNSYNCABLE_PREF);
100 #endif 101 #endif
101 102
102 #if defined(OS_ANDROID) 103 #if defined(OS_ANDROID)
103 prefs->RegisterBooleanPref(prefs::kDevToolsRemoteEnabled, 104 registry->RegisterBooleanPref(prefs::kDevToolsRemoteEnabled,
104 false, 105 false,
105 PrefServiceSyncable::UNSYNCABLE_PREF); 106 PrefRegistrySyncable::UNSYNCABLE_PREF);
106 prefs->RegisterBooleanPref(prefs::kSpdyProxyEnabled, 107 registry->RegisterBooleanPref(prefs::kSpdyProxyEnabled,
107 true, 108 true,
108 PrefServiceSyncable::UNSYNCABLE_PREF); 109 PrefRegistrySyncable::UNSYNCABLE_PREF);
109 #endif 110 #endif
110
111 } 111 }
112 112
113 113
114 std::string Profile::GetDebugName() { 114 std::string Profile::GetDebugName() {
115 std::string name = GetPath().BaseName().MaybeAsASCII(); 115 std::string name = GetPath().BaseName().MaybeAsASCII();
116 if (name.empty()) { 116 if (name.empty()) {
117 name = "UnknownProfile"; 117 name = "UnknownProfile";
118 } 118 }
119 return name; 119 return name;
120 } 120 }
121 121
122 bool Profile::IsGuestSession() const { 122 bool Profile::IsGuestSession() const {
123 #if defined(OS_CHROMEOS) 123 #if defined(OS_CHROMEOS)
124 static bool is_guest_session = 124 static bool is_guest_session =
125 CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession); 125 CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession);
126 return is_guest_session; 126 return is_guest_session;
127 #else 127 #else
128 return false; 128 return false;
129 #endif 129 #endif
130 } 130 }
131 131
132 bool Profile::IsSyncAccessible() { 132 bool Profile::IsSyncAccessible() {
133 browser_sync::SyncPrefs prefs(GetPrefs()); 133 browser_sync::SyncPrefs prefs(GetPrefs());
134 return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged(); 134 return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged(); //
Mattias Nissler (ping if slow) 2013/02/06 17:53:33 revert
Jói 2013/02/07 14:52:32 Done.
135 } 135 }
136 136
137 void Profile::MaybeSendDestroyedNotification() { 137 void Profile::MaybeSendDestroyedNotification() {
138 if (!sent_destroyed_notification_) { 138 if (!sent_destroyed_notification_) {
139 sent_destroyed_notification_ = true; 139 sent_destroyed_notification_ = true;
140 content::NotificationService::current()->Notify( 140 content::NotificationService::current()->Notify(
141 chrome::NOTIFICATION_PROFILE_DESTROYED, 141 chrome::NOTIFICATION_PROFILE_DESTROYED,
142 content::Source<Profile>(this), 142 content::Source<Profile>(this),
143 content::NotificationService::NoDetails()); 143 content::NotificationService::NoDetails());
144 } 144 }
145 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698