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

Unified Diff: chrome/browser/custom_handlers/protocol_handler_registry.cc

Issue 10139002: Preventing our default handlers for ChromeOS to show up or confuse the user (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added a few more comments Created 8 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 side-by-side diff with in-line comments
Download patch
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);
}
}

Powered by Google App Engine
This is Rietveld 408576698