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

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

Issue 2823073003: Make Use of Value::GetList API
Patch Set: Further Usages Created 3 years, 8 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
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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 void ProtocolHandlersHandler::HandleClearDefault(const base::ListValue* args) { 195 void ProtocolHandlersHandler::HandleClearDefault(const base::ListValue* args) {
196 const base::Value* value; 196 const base::Value* value;
197 CHECK(args->Get(0, &value)); 197 CHECK(args->Get(0, &value));
198 std::string protocol_to_clear; 198 std::string protocol_to_clear;
199 CHECK(value->GetAsString(&protocol_to_clear)); 199 CHECK(value->GetAsString(&protocol_to_clear));
200 GetProtocolHandlerRegistry()->ClearDefault(protocol_to_clear); 200 GetProtocolHandlerRegistry()->ClearDefault(protocol_to_clear);
201 } 201 }
202 202
203 void ProtocolHandlersHandler::HandleSetDefault(const base::ListValue* args) { 203 void ProtocolHandlersHandler::HandleSetDefault(const base::ListValue* args) {
204 const base::ListValue* list; 204 const base::ListValue* list =
205 CHECK(args->GetList(0, &list)); 205 static_cast<const base::ListValue*>(&args->base::Value::GetList()[0]);
206 const ProtocolHandler& handler(ParseHandlerFromArgs(list)); 206 const ProtocolHandler& handler(ParseHandlerFromArgs(list));
207 CHECK(!handler.IsEmpty()); 207 CHECK(!handler.IsEmpty());
208 GetProtocolHandlerRegistry()->OnAcceptRegisterProtocolHandler(handler); 208 GetProtocolHandlerRegistry()->OnAcceptRegisterProtocolHandler(handler);
209 } 209 }
210 210
211 ProtocolHandler ProtocolHandlersHandler::ParseHandlerFromArgs( 211 ProtocolHandler ProtocolHandlersHandler::ParseHandlerFromArgs(
212 const base::ListValue* args) const { 212 const base::ListValue* args) const {
213 base::string16 protocol; 213 base::string16 protocol;
214 base::string16 url; 214 base::string16 url;
215 bool ok = args->GetString(0, &protocol) && args->GetString(1, &url); 215 bool ok = args->GetString(0, &protocol) && args->GetString(1, &url);
216 if (!ok) 216 if (!ok)
217 return ProtocolHandler::EmptyProtocolHandler(); 217 return ProtocolHandler::EmptyProtocolHandler();
218 return ProtocolHandler::CreateProtocolHandler(base::UTF16ToUTF8(protocol), 218 return ProtocolHandler::CreateProtocolHandler(base::UTF16ToUTF8(protocol),
219 GURL(base::UTF16ToUTF8(url))); 219 GURL(base::UTF16ToUTF8(url)));
220 } 220 }
221 221
222 void ProtocolHandlersHandler::Observe( 222 void ProtocolHandlersHandler::Observe(
223 int type, 223 int type,
224 const content::NotificationSource& source, 224 const content::NotificationSource& source,
225 const content::NotificationDetails& details) { 225 const content::NotificationDetails& details) {
226 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type); 226 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type);
227 SendHandlersEnabledValue(); 227 SendHandlersEnabledValue();
228 UpdateHandlerList(); 228 UpdateHandlerList();
229 } 229 }
230 230
231 } // namespace settings 231 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/startup_pages_handler.cc ('k') | components/ntp_snippets/pref_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698