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

Side by Side Diff: chrome/browser/ui/webui/settings/protocol_handlers_handler.cc

Issue 2598893002: [MD settings] lighter weight initializer for protocol handler enabled messages (Closed)
Patch Set: 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/settings/protocol_handlers_handler.h" 5 #include "chrome/browser/ui/webui/settings/protocol_handlers_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 void ProtocolHandlersHandler::OnJavascriptDisallowed() { 38 void ProtocolHandlersHandler::OnJavascriptDisallowed() {
39 notification_registrar_.RemoveAll(); 39 notification_registrar_.RemoveAll();
40 } 40 }
41 41
42 void ProtocolHandlersHandler::RegisterMessages() { 42 void ProtocolHandlersHandler::RegisterMessages() {
43 web_ui()->RegisterMessageCallback("initializeProtocolHandlerList", 43 web_ui()->RegisterMessageCallback("initializeProtocolHandlerList",
44 base::Bind(&ProtocolHandlersHandler::HandleInitializeList, 44 base::Bind(&ProtocolHandlersHandler::HandleInitializeList,
45 base::Unretained(this))); 45 base::Unretained(this)));
46 web_ui()->RegisterMessageCallback("initializeProtocolHandlerUpdates",
47 base::Bind(&ProtocolHandlersHandler::HandleInitializeUpdates,
48 base::Unretained(this)));
46 web_ui()->RegisterMessageCallback("clearDefault", 49 web_ui()->RegisterMessageCallback("clearDefault",
47 base::Bind(&ProtocolHandlersHandler::HandleClearDefault, 50 base::Bind(&ProtocolHandlersHandler::HandleClearDefault,
48 base::Unretained(this))); 51 base::Unretained(this)));
49 web_ui()->RegisterMessageCallback("removeHandler", 52 web_ui()->RegisterMessageCallback("removeHandler",
50 base::Bind(&ProtocolHandlersHandler::HandleRemoveHandler, 53 base::Bind(&ProtocolHandlersHandler::HandleRemoveHandler,
51 base::Unretained(this))); 54 base::Unretained(this)));
52 web_ui()->RegisterMessageCallback("setHandlersEnabled", 55 web_ui()->RegisterMessageCallback("setHandlersEnabled",
53 base::Bind(&ProtocolHandlersHandler::HandleSetHandlersEnabled, 56 base::Bind(&ProtocolHandlersHandler::HandleSetHandlersEnabled,
54 base::Unretained(this))); 57 base::Unretained(this)));
55 web_ui()->RegisterMessageCallback("setDefault", 58 web_ui()->RegisterMessageCallback("setDefault",
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 base::StringValue("setProtocolHandlers"), 130 base::StringValue("setProtocolHandlers"),
128 handlers); 131 handlers);
129 CallJavascriptFunction("cr.webUIListenerCallback", 132 CallJavascriptFunction("cr.webUIListenerCallback",
130 base::StringValue("setIgnoredProtocolHandlers"), 133 base::StringValue("setIgnoredProtocolHandlers"),
131 *ignored_handlers); 134 *ignored_handlers);
132 } 135 }
133 136
134 void ProtocolHandlersHandler::HandleInitializeList( 137 void ProtocolHandlersHandler::HandleInitializeList(
135 const base::ListValue* args) { 138 const base::ListValue* args) {
136 AllowJavascript(); 139 AllowJavascript();
137 SendHandlersEnabledValue(); 140 SendHandlersEnabledValue();
dschuyler 2016/12/22 02:00:05 I'd want to call AllowJavascript(); and UpdateHand
138 UpdateHandlerList(); 141 UpdateHandlerList();
139 } 142 }
140 143
144 void ProtocolHandlersHandler::HandleInitializeUpdates(
145 const base::ListValue* args) {
146 AllowJavascript();
147 SendHandlersEnabledValue();
148 }
149
141 void ProtocolHandlersHandler::SendHandlersEnabledValue() { 150 void ProtocolHandlersHandler::SendHandlersEnabledValue() {
142 CallJavascriptFunction("cr.webUIListenerCallback", 151 CallJavascriptFunction("cr.webUIListenerCallback",
143 base::StringValue("setHandlersEnabled"), 152 base::StringValue("setHandlersEnabled"),
144 base::FundamentalValue( 153 base::FundamentalValue(
145 GetProtocolHandlerRegistry()->enabled())); 154 GetProtocolHandlerRegistry()->enabled()));
146 } 155 }
147 156
148 void ProtocolHandlersHandler::HandleRemoveHandler(const base::ListValue* args) { 157 void ProtocolHandlersHandler::HandleRemoveHandler(const base::ListValue* args) {
149 const base::ListValue* list; 158 const base::ListValue* list;
150 if (!args->GetList(0, &list)) { 159 if (!args->GetList(0, &list)) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 void ProtocolHandlersHandler::Observe( 221 void ProtocolHandlersHandler::Observe(
213 int type, 222 int type,
214 const content::NotificationSource& source, 223 const content::NotificationSource& source,
215 const content::NotificationDetails& details) { 224 const content::NotificationDetails& details) {
216 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type); 225 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type);
217 SendHandlersEnabledValue(); 226 SendHandlersEnabledValue();
218 UpdateHandlerList(); 227 UpdateHandlerList();
219 } 228 }
220 229
221 } // namespace settings 230 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698