Chromium Code Reviews| Index: chrome/browser/custom_handlers/protocol_handler_registry.cc |
| diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.cc b/chrome/browser/custom_handlers/protocol_handler_registry.cc |
| index d81af988fc58af5d2e7f30e6b30679ff451d30bf..52dbcfd66ab240b394ff8f47b43a3ac4c6f0972a 100644 |
| --- a/chrome/browser/custom_handlers/protocol_handler_registry.cc |
| +++ b/chrome/browser/custom_handlers/protocol_handler_registry.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/command_line.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/utf_string_conversions.h" |
| #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h" |
| #include "chrome/browser/net/chrome_url_request_context.h" |
| #include "chrome/browser/prefs/pref_service.h" |
| @@ -35,7 +36,35 @@ ProtocolHandlerRegistry::ProtocolHandlerRegistry(Profile* profile, |
| delegate_(delegate), |
| enabled_(true), |
| enabled_io_(enabled_), |
| - is_loading_(false) { |
| + is_loading_(false), |
| + locking_defaults_(false) { |
| +} |
| + |
| +void ProtocolHandlerRegistry::InstallSystemDefaultHandlers() { |
| +#if defined(OS_CHROMEOS) |
| + ProtocolHandler mail_handler = ProtocolHandler::CreateProtocolHandler( |
| + std::string("mailto"), |
| + GURL("https://mail.google.com/mail/?extsrc=mailto&url=%s"), |
| + UTF8ToUTF16(std::string("Google.com Mail"))); |
| + RegisterProtocolHandler(mail_handler); |
| + SetDefault(mail_handler); |
| + ProtocolHandler cal_handler = ProtocolHandler::CreateProtocolHandler( |
| + std::string("webcal"), |
| + GURL("https://www.google.com/calendar/render?cid=%s"), |
| + UTF8ToUTF16(std::string("Google Calendar"))); |
| + RegisterProtocolHandler(cal_handler); |
| + SetDefault(cal_handler); |
| +#endif |
| + locking_defaults_ = true; |
| +} |
| + |
| +bool ProtocolHandlerRegistry::IsFixedHandler( |
| + const std::string& scheme) const { |
| +#if defined (OS_CHROMEOS) |
| + return (locking_defaults_ && (scheme == "mailto" || scheme == "webcal")); |
| +#else |
| + return false; |
| +#endif |
| } |
| ProtocolHandlerRegistry::~ProtocolHandlerRegistry() { |
| @@ -195,6 +224,11 @@ bool ShouldRemoveHandlersNotInOS() { |
| } // namespace |
| void ProtocolHandlerRegistry::Load() { |
| + // We add our default handlers only the first time we come here. |
| + // On the next call the defaults will be locked. |
| + if (!locking_defaults_) |
| + InstallSystemDefaultHandlers(); |
| + |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| is_loading_ = true; |
| PrefService* prefs = profile_->GetPrefs(); |
| @@ -260,6 +294,8 @@ void ProtocolHandlerRegistry::Save() { |
| bool ProtocolHandlerRegistry::CanSchemeBeOverridden( |
| const std::string& scheme) const { |
| + if (IsFixedHandler(scheme)) |
|
benwells
2012/04/20 00:25:05
If I understand this change correctly, ChromeOS us
Mr4D (OOO till 08-26)
2012/04/20 13:44:41
There are no 'apps' which can do these things. As
benwells
2012/04/20 21:55:10
registerProtocolHandler is a web standard, and can
Mr4D (OOO till 08-26)
2012/04/21 00:27:28
Okay, fine. I will remove it then. :) (Who am I me
|
| + return false; |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| const ProtocolHandlerList* handlers = GetHandlerList(scheme); |
| // If we already have a handler for this scheme, we can add more. |
| @@ -274,7 +310,8 @@ void ProtocolHandlerRegistry::GetRegisteredProtocols( |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| ProtocolHandlerMultiMap::const_iterator p; |
| for (p = protocol_handlers_.begin(); p != protocol_handlers_.end(); ++p) { |
| - if (!p->second.empty()) |
| + // We don't want the settings dialog to show 'internal defaults'. |
| + if (!p->second.empty() && !IsFixedHandler(p->first)) |
| output->push_back(p->first); |
| } |
| } |