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

Unified Diff: chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc

Issue 1988463002: MD Settings: Convert C++ handlers to be JavaScript-lifecycle aware. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
diff --git a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
index 892ff5583d5b7cbd84ed7921bc89fd70eaf7bdef..7a51417d4e3ab8b4cc1951086673408bef99ff0d 100644
--- a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
@@ -69,22 +69,26 @@ void ManageProfileHandler::RegisterMessages() {
base::Unretained(this)));
}
+void ManageProfileHandler::OnJavascriptAllowed() {
+ observer_.Add(
+ &g_browser_process->profile_manager()->GetProfileAttributesStorage());
+}
+
+void ManageProfileHandler::OnJavascriptDisallowed() {
+ observer_.RemoveAll();
+}
+
void ManageProfileHandler::OnProfileAvatarChanged(
const base::FilePath& profile_path) {
// This is necessary to send the potentially updated GAIA photo.
- web_ui()->CallJavascriptFunction("cr.webUIListenerCallback",
- base::StringValue("available-icons-changed"),
- *GetAvailableIcons());
+ CallJavascriptFunction("cr.webUIListenerCallback",
+ base::StringValue("available-icons-changed"),
+ *GetAvailableIcons());
}
void ManageProfileHandler::HandleGetAvailableIcons(
const base::ListValue* args) {
- // This is also used as a signal that the page has loaded and is ready to
- // observe profile avatar changes.
- if (!observer_.IsObservingSources()) {
- observer_.Add(
- &g_browser_process->profile_manager()->GetProfileAttributesStorage());
- }
+ AllowJavascript();
profiles::UpdateGaiaProfileInfoIfNeeded(profile_);
@@ -193,9 +197,8 @@ void ManageProfileHandler::OnHasProfileShortcuts(bool has_shortcuts) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
const base::FundamentalValue has_shortcuts_value(has_shortcuts);
- web_ui()->CallJavascriptFunction(
- "settings.SyncPrivateApi.receiveHasProfileShortcuts",
- has_shortcuts_value);
+ CallJavascriptFunction("settings.SyncPrivateApi.receiveHasProfileShortcuts",
+ has_shortcuts_value);
}
void ManageProfileHandler::HandleAddProfileShortcut(

Powered by Google App Engine
This is Rietveld 408576698