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

Side by Side Diff: chrome/browser/ui/webui/options/manage_profile_handler.cc

Issue 22751002: Dynamically update sign-in/Sync status in the profile creation overlay. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: skip for tests Created 7 years, 4 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
« no previous file with comments | « chrome/browser/ui/webui/options/manage_profile_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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/ui/webui/options/manage_profile_handler.h" 5 #include "chrome/browser/ui/webui/options/manage_profile_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 } 76 }
77 77
78 } // namespace 78 } // namespace
79 79
80 ManageProfileHandler::ManageProfileHandler() 80 ManageProfileHandler::ManageProfileHandler()
81 : weak_factory_(this) { 81 : weak_factory_(this) {
82 } 82 }
83 83
84 ManageProfileHandler::~ManageProfileHandler() { 84 ManageProfileHandler::~ManageProfileHandler() {
85 ProfileSyncService* service =
86 ProfileSyncServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
87 // Sync may be disabled in tests.
88 if (service)
89 service->RemoveObserver(this);
85 } 90 }
86 91
87 void ManageProfileHandler::GetLocalizedValues( 92 void ManageProfileHandler::GetLocalizedValues(
88 DictionaryValue* localized_strings) { 93 DictionaryValue* localized_strings) {
89 DCHECK(localized_strings); 94 DCHECK(localized_strings);
90 95
91 static OptionsStringResource resources[] = { 96 static OptionsStringResource resources[] = {
92 { "manageProfilesNameLabel", IDS_PROFILES_MANAGE_NAME_LABEL }, 97 { "manageProfilesNameLabel", IDS_PROFILES_MANAGE_NAME_LABEL },
93 { "manageProfilesDuplicateNameError", 98 { "manageProfilesDuplicateNameError",
94 IDS_PROFILES_MANAGE_DUPLICATE_NAME_ERROR }, 99 IDS_PROFILES_MANAGE_DUPLICATE_NAME_ERROR },
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 localized_strings->SetBoolean( 138 localized_strings->SetBoolean(
134 "allowCreateExistingManagedUsers", 139 "allowCreateExistingManagedUsers",
135 CommandLine::ForCurrentProcess()->HasSwitch( 140 CommandLine::ForCurrentProcess()->HasSwitch(
136 switches::kAllowCreateExistingManagedUsers)); 141 switches::kAllowCreateExistingManagedUsers));
137 } 142 }
138 143
139 void ManageProfileHandler::InitializeHandler() { 144 void ManageProfileHandler::InitializeHandler() {
140 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, 145 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
141 content::NotificationService::AllSources()); 146 content::NotificationService::AllSources());
142 147
143 pref_change_registrar_.Init(Profile::FromWebUI(web_ui())->GetPrefs()); 148 Profile* profile = Profile::FromWebUI(web_ui());
149 pref_change_registrar_.Init(profile->GetPrefs());
144 pref_change_registrar_.Add( 150 pref_change_registrar_.Add(
145 prefs::kManagedUserCreationAllowed, 151 prefs::kManagedUserCreationAllowed,
146 base::Bind(&ManageProfileHandler::OnCreateManagedUserPrefChange, 152 base::Bind(&ManageProfileHandler::OnCreateManagedUserPrefChange,
147 base::Unretained(this))); 153 base::Unretained(this)));
154 ProfileSyncService* service =
155 ProfileSyncServiceFactory::GetForProfile(profile);
156 // Sync may be disabled for tests.
157 if (service)
158 service->AddObserver(this);
148 } 159 }
149 160
150 void ManageProfileHandler::InitializePage() { 161 void ManageProfileHandler::InitializePage() {
151 SendProfileNames(); 162 SendProfileNames();
152 OnCreateManagedUserPrefChange(); 163 OnCreateManagedUserPrefChange();
153 } 164 }
154 165
155 void ManageProfileHandler::RegisterMessages() { 166 void ManageProfileHandler::RegisterMessages() {
156 web_ui()->RegisterMessageCallback("setProfileIconAndName", 167 web_ui()->RegisterMessageCallback("setProfileIconAndName",
157 base::Bind(&ManageProfileHandler::SetProfileIconAndName, 168 base::Bind(&ManageProfileHandler::SetProfileIconAndName,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 if (!web_ui()->GetWebContents()->GetRenderViewHost()) 210 if (!web_ui()->GetWebContents()->GetRenderViewHost())
200 return; 211 return;
201 SendProfileNames(); 212 SendProfileNames();
202 base::StringValue value(kManageProfileIconGridName); 213 base::StringValue value(kManageProfileIconGridName);
203 SendProfileIcons(value); 214 SendProfileIcons(value);
204 } else { 215 } else {
205 OptionsPageUIHandler::Observe(type, source, details); 216 OptionsPageUIHandler::Observe(type, source, details);
206 } 217 }
207 } 218 }
208 219
220 void ManageProfileHandler::OnStateChanged() {
221 RequestCreateProfileUpdate(NULL);
222 }
223
209 void ManageProfileHandler::RequestDefaultProfileIcons(const ListValue* args) { 224 void ManageProfileHandler::RequestDefaultProfileIcons(const ListValue* args) {
210 base::StringValue create_value(kCreateProfileIconGridName); 225 base::StringValue create_value(kCreateProfileIconGridName);
211 base::StringValue manage_value(kManageProfileIconGridName); 226 base::StringValue manage_value(kManageProfileIconGridName);
212 SendProfileIcons(manage_value); 227 SendProfileIcons(manage_value);
213 SendProfileIcons(create_value); 228 SendProfileIcons(create_value);
214 } 229 }
215 230
216 void ManageProfileHandler::RequestNewProfileDefaults(const ListValue* args) { 231 void ManageProfileHandler::RequestNewProfileDefaults(const ListValue* args) {
217 const ProfileInfoCache& cache = 232 const ProfileInfoCache& cache =
218 g_browser_process->profile_manager()->GetProfileInfoCache(); 233 g_browser_process->profile_manager()->GetProfileInfoCache();
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 g_browser_process->profile_manager()->profile_shortcut_manager(); 523 g_browser_process->profile_manager()->profile_shortcut_manager();
509 DCHECK(shortcut_manager); 524 DCHECK(shortcut_manager);
510 525
511 shortcut_manager->RemoveProfileShortcuts(profile_file_path); 526 shortcut_manager->RemoveProfileShortcuts(profile_file_path);
512 527
513 // Update the UI buttons. 528 // Update the UI buttons.
514 OnHasProfileShortcuts(false); 529 OnHasProfileShortcuts(false);
515 } 530 }
516 531
517 } // namespace options 532 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/manage_profile_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698