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

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: Addressed third review 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..f3d4ffb4b3097f162f2f38a9e496a1565fb7923b 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"
@@ -21,8 +22,10 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/notification_service.h"
+#include "grit/generated_resources.h"
#include "net/base/network_delegate.h"
#include "net/url_request/url_request_redirect_job.h"
+#include "ui/base/l10n/l10n_util.h"
using content::BrowserThread;
using content::ChildProcessSecurityPolicy;
@@ -38,6 +41,27 @@ ProtocolHandlerRegistry::ProtocolHandlerRegistry(Profile* profile,
is_loading_(false) {
}
+void ProtocolHandlerRegistry::InstallFixedHandlers() {
+#if defined(OS_CHROMEOS)
+ if (NULL == GetHandlerList(std::string("mailto"))) {
+ ProtocolHandler mailto_handler = ProtocolHandler::CreateProtocolHandler(
+ "mailto",
+ GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_MAILTO_HANDLER_URL)),
+ l10n_util::GetStringUTF16(IDS_GOOGLE_MAILTO_HANDLER_NAME));
+ RegisterProtocolHandler(mailto_handler);
+ SetDefault(mailto_handler);
+ }
+ if (NULL == GetHandlerList(std::string("webcal"))) {
+ ProtocolHandler webcal_handler = ProtocolHandler::CreateProtocolHandler(
+ "webcal",
+ GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_WEBCAL_HANDLER_URL)),
+ l10n_util::GetStringUTF16(IDS_GOOGLE_WEBCAL_HANDLER_NAME));
+ RegisterProtocolHandler(webcal_handler);
+ SetDefault(webcal_handler);
+ }
+#endif
+}
+
ProtocolHandlerRegistry::~ProtocolHandlerRegistry() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(default_client_observers_.empty());
@@ -195,6 +219,10 @@ bool ShouldRemoveHandlersNotInOS() {
} // namespace
void ProtocolHandlerRegistry::Load() {
+ // We add our default handlers. Since we assume that this gets only called
+ // once, we can call this every time.
+ InstallFixedHandlers();
+
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
is_loading_ = true;
PrefService* prefs = profile_->GetPrefs();

Powered by Google App Engine
This is Rietveld 408576698