| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/handler_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/handler_options_handler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 }; | 38 }; |
| 39 RegisterTitle(localized_strings, "handlersPage", | 39 RegisterTitle(localized_strings, "handlersPage", |
| 40 IDS_HANDLER_OPTIONS_WINDOW_TITLE); | 40 IDS_HANDLER_OPTIONS_WINDOW_TITLE); |
| 41 RegisterStrings(localized_strings, resources, arraysize(resources)); | 41 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void HandlerOptionsHandler::Initialize() { | 44 void HandlerOptionsHandler::Initialize() { |
| 45 UpdateHandlerList(); | 45 UpdateHandlerList(); |
| 46 notification_registrar_.Add( | 46 notification_registrar_.Add( |
| 47 this, chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, | 47 this, chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, |
| 48 Source<Profile>(web_ui_->GetProfile())); | 48 Source<Profile>(Profile::FromWebUI(web_ui_))); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void HandlerOptionsHandler::RegisterMessages() { | 51 void HandlerOptionsHandler::RegisterMessages() { |
| 52 DCHECK(web_ui_); | 52 DCHECK(web_ui_); |
| 53 web_ui_->RegisterMessageCallback("clearDefault", | 53 web_ui_->RegisterMessageCallback("clearDefault", |
| 54 NewCallback(this, &HandlerOptionsHandler::ClearDefault)); | 54 NewCallback(this, &HandlerOptionsHandler::ClearDefault)); |
| 55 web_ui_->RegisterMessageCallback("removeHandler", | 55 web_ui_->RegisterMessageCallback("removeHandler", |
| 56 NewCallback(this, &HandlerOptionsHandler::RemoveHandler)); | 56 NewCallback(this, &HandlerOptionsHandler::RemoveHandler)); |
| 57 web_ui_->RegisterMessageCallback("setHandlersEnabled", | 57 web_ui_->RegisterMessageCallback("setHandlersEnabled", |
| 58 NewCallback(this, &HandlerOptionsHandler::SetHandlersEnabled)); | 58 NewCallback(this, &HandlerOptionsHandler::SetHandlersEnabled)); |
| 59 web_ui_->RegisterMessageCallback("setDefault", | 59 web_ui_->RegisterMessageCallback("setDefault", |
| 60 NewCallback(this, &HandlerOptionsHandler::SetDefault)); | 60 NewCallback(this, &HandlerOptionsHandler::SetDefault)); |
| 61 web_ui_->RegisterMessageCallback("removeIgnoredHandler", | 61 web_ui_->RegisterMessageCallback("removeIgnoredHandler", |
| 62 NewCallback(this, &HandlerOptionsHandler::RemoveIgnoredHandler)); | 62 NewCallback(this, &HandlerOptionsHandler::RemoveIgnoredHandler)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 ProtocolHandlerRegistry* HandlerOptionsHandler::GetProtocolHandlerRegistry() { | 65 ProtocolHandlerRegistry* HandlerOptionsHandler::GetProtocolHandlerRegistry() { |
| 66 DCHECK(web_ui_); | 66 DCHECK(web_ui_); |
| 67 return web_ui_->GetProfile()->GetProtocolHandlerRegistry(); | 67 return Profile::FromWebUI(web_ui_)->GetProtocolHandlerRegistry(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 static void GetHandlersAsListValue( | 70 static void GetHandlersAsListValue( |
| 71 const ProtocolHandlerRegistry::ProtocolHandlerList& handlers, | 71 const ProtocolHandlerRegistry::ProtocolHandlerList& handlers, |
| 72 ListValue* handler_list) { | 72 ListValue* handler_list) { |
| 73 ProtocolHandlerRegistry::ProtocolHandlerList::const_iterator handler; | 73 ProtocolHandlerRegistry::ProtocolHandlerList::const_iterator handler; |
| 74 for (handler = handlers.begin(); handler != handlers.end(); ++handler) { | 74 for (handler = handlers.begin(); handler != handlers.end(); ++handler) { |
| 75 ListValue* handlerValue = new ListValue(); | 75 ListValue* handlerValue = new ListValue(); |
| 76 handlerValue->Append(Value::CreateStringValue(handler->protocol())); | 76 handlerValue->Append(Value::CreateStringValue(handler->protocol())); |
| 77 handlerValue->Append(Value::CreateStringValue(handler->url().spec())); | 77 handlerValue->Append(Value::CreateStringValue(handler->url().spec())); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } | 190 } |
| 191 | 191 |
| 192 void HandlerOptionsHandler::Observe(int type, | 192 void HandlerOptionsHandler::Observe(int type, |
| 193 const NotificationSource& source, | 193 const NotificationSource& source, |
| 194 const NotificationDetails& details) { | 194 const NotificationDetails& details) { |
| 195 if (type == chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED) | 195 if (type == chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED) |
| 196 UpdateHandlerList(); | 196 UpdateHandlerList(); |
| 197 else | 197 else |
| 198 NOTREACHED(); | 198 NOTREACHED(); |
| 199 } | 199 } |
| OLD | NEW |