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

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

Issue 2568973002: chromeos: Replace user image notifications with observer (Closed)
Patch Set: rebase Created 4 years 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
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/ui/webui/options/browser_options_handler.h" 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 g_browser_process->profile_manager()-> 934 g_browser_process->profile_manager()->
935 GetProfileAttributesStorage().RemoveObserver(this); 935 GetProfileAttributesStorage().RemoveObserver(this);
936 #if defined(OS_WIN) 936 #if defined(OS_WIN)
937 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this); 937 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this);
938 #endif 938 #endif
939 #if defined(OS_CHROMEOS) 939 #if defined(OS_CHROMEOS)
940 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get( 940 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(
941 Profile::FromWebUI(web_ui())); 941 Profile::FromWebUI(web_ui()));
942 if (arc_prefs) 942 if (arc_prefs)
943 arc_prefs->RemoveObserver(this); 943 arc_prefs->RemoveObserver(this);
944 user_manager::UserManager::Get()->RemoveObserver(this);
944 #endif 945 #endif
945 } 946 }
946 947
947 void BrowserOptionsHandler::OnStateChanged() { 948 void BrowserOptionsHandler::OnStateChanged() {
948 UpdateSyncState(); 949 UpdateSyncState();
949 } 950 }
950 951
951 void BrowserOptionsHandler::GoogleSigninSucceeded(const std::string& account_id, 952 void BrowserOptionsHandler::GoogleSigninSucceeded(const std::string& account_id,
952 const std::string& username, 953 const std::string& username,
953 const std::string& password) { 954 const std::string& password) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 1004
1004 #if !defined(OS_CHROMEOS) 1005 #if !defined(OS_CHROMEOS)
1005 default_browser_policy_.Init( 1006 default_browser_policy_.Init(
1006 prefs::kDefaultBrowserSettingEnabled, 1007 prefs::kDefaultBrowserSettingEnabled,
1007 g_browser_process->local_state(), 1008 g_browser_process->local_state(),
1008 base::Bind(&BrowserOptionsHandler::UpdateDefaultBrowserState, 1009 base::Bind(&BrowserOptionsHandler::UpdateDefaultBrowserState,
1009 base::Unretained(this))); 1010 base::Unretained(this)));
1010 #endif 1011 #endif
1011 1012
1012 #if defined(OS_CHROMEOS) 1013 #if defined(OS_CHROMEOS)
1013 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 1014 user_manager::UserManager::Get()->AddObserver(this);
1014 content::NotificationService::AllSources());
1015 #endif 1015 #endif
1016 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 1016 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
1017 content::Source<ThemeService>( 1017 content::Source<ThemeService>(
1018 ThemeServiceFactory::GetForProfile(profile))); 1018 ThemeServiceFactory::GetForProfile(profile)));
1019 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, 1019 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED,
1020 content::Source<Profile>(profile)); 1020 content::Source<Profile>(profile));
1021 AddTemplateUrlServiceObserver(); 1021 AddTemplateUrlServiceObserver();
1022 1022
1023 #if defined(OS_WIN) 1023 #if defined(OS_WIN)
1024 ExtensionRegistry::Get(profile)->AddObserver(this); 1024 ExtensionRegistry::Get(profile)->AddObserver(this);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 // the background. If the UI is currently being loaded, no dynamic updates are 1363 // the background. If the UI is currently being loaded, no dynamic updates are
1364 // possible (as the DOM and JS are not fully loaded) or necessary (as 1364 // possible (as the DOM and JS are not fully loaded) or necessary (as
1365 // InitializePage() will update the UI at the end of the load). 1365 // InitializePage() will update the UI at the end of the load).
1366 if (!page_initialized_) 1366 if (!page_initialized_)
1367 return; 1367 return;
1368 1368
1369 switch (type) { 1369 switch (type) {
1370 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: 1370 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED:
1371 ObserveThemeChanged(); 1371 ObserveThemeChanged();
1372 break; 1372 break;
1373 #if defined(OS_CHROMEOS)
1374 case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED:
1375 UpdateAccountPicture();
1376 break;
1377 #endif
1378 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: 1373 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED:
1379 // Update our sync/signin status display. 1374 // Update our sync/signin status display.
1380 OnStateChanged(); 1375 OnStateChanged();
1381 break; 1376 break;
1382 default: 1377 default:
1383 NOTREACHED(); 1378 NOTREACHED();
1384 } 1379 }
1385 } 1380 }
1386 1381
1387 void BrowserOptionsHandler::OnProfileAdded(const base::FilePath& profile_path) { 1382 void BrowserOptionsHandler::OnProfileAdded(const base::FilePath& profile_path) {
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 } 1982 }
1988 1983
1989 void BrowserOptionsHandler::OnAppReadyChanged( 1984 void BrowserOptionsHandler::OnAppReadyChanged(
1990 const std::string& app_id, 1985 const std::string& app_id,
1991 bool ready) { 1986 bool ready) {
1992 if (app_id == arc::kSettingsAppId) { 1987 if (app_id == arc::kSettingsAppId) {
1993 UpdateAndroidSettingsAppState(ready); 1988 UpdateAndroidSettingsAppState(ready);
1994 } 1989 }
1995 } 1990 }
1996 1991
1992 void BrowserOptionsHandler::OnUserImageChanged(const user_manager::User& user) {
1993 UpdateAccountPicture();
1994 }
1995
1997 void BrowserOptionsHandler::UpdateAndroidSettingsAppState(bool visible) { 1996 void BrowserOptionsHandler::UpdateAndroidSettingsAppState(bool visible) {
1998 base::FundamentalValue is_visible(visible); 1997 base::FundamentalValue is_visible(visible);
1999 web_ui()->CallJavascriptFunctionUnsafe( 1998 web_ui()->CallJavascriptFunctionUnsafe(
2000 "BrowserOptions.setAndroidAppsSettingsVisibility", is_visible); 1999 "BrowserOptions.setAndroidAppsSettingsVisibility", is_visible);
2001 } 2000 }
2002 2001
2003 void BrowserOptionsHandler::ShowAndroidAppsSettings( 2002 void BrowserOptionsHandler::ShowAndroidAppsSettings(
2004 const base::ListValue* args) { 2003 const base::ListValue* args) {
2005 Profile* profile = Profile::FromWebUI(web_ui()); 2004 Profile* profile = Profile::FromWebUI(web_ui());
2006 // Settings in secondary profile cannot access ARC. 2005 // Settings in secondary profile cannot access ARC.
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 2297
2299 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { 2298 bool BrowserOptionsHandler::IsDeviceOwnerProfile() {
2300 #if defined(OS_CHROMEOS) 2299 #if defined(OS_CHROMEOS)
2301 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); 2300 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui()));
2302 #else 2301 #else
2303 return true; 2302 return true;
2304 #endif 2303 #endif
2305 } 2304 }
2306 2305
2307 } // namespace options 2306 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698