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

Side by Side 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: Resolving merge issues Created 8 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/custom_handlers/protocol_handler_registry.h" 5 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 145
146 // ProtocolHandlerRegistry ----------------------------------------------------- 146 // ProtocolHandlerRegistry -----------------------------------------------------
147 147
148 ProtocolHandlerRegistry::ProtocolHandlerRegistry(Profile* profile, 148 ProtocolHandlerRegistry::ProtocolHandlerRegistry(Profile* profile,
149 Delegate* delegate) 149 Delegate* delegate)
150 : profile_(profile), 150 : profile_(profile),
151 delegate_(delegate), 151 delegate_(delegate),
152 enabled_(true), 152 enabled_(true),
153 enabled_io_(enabled_), 153 enabled_io_(enabled_),
154 is_loading_(false) { 154 is_loading_(false),
155 is_loaded_(false) {
155 } 156 }
156 157
157 bool ProtocolHandlerRegistry::SilentlyHandleRegisterHandlerRequest( 158 bool ProtocolHandlerRegistry::SilentlyHandleRegisterHandlerRequest(
158 const ProtocolHandler& handler) { 159 const ProtocolHandler& handler) {
159 if (handler.IsEmpty() || !CanSchemeBeOverridden(handler.protocol())) 160 if (handler.IsEmpty() || !CanSchemeBeOverridden(handler.protocol()))
160 return true; 161 return true;
161 162
162 if (!enabled() || IsRegistered(handler) || HasIgnoredEquivalent(handler)) 163 if (!enabled() || IsRegistered(handler) || HasIgnoredEquivalent(handler))
163 return true; 164 return true;
164 165
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 NotifyChanged(); 241 NotifyChanged();
241 } 242 }
242 243
243 bool ProtocolHandlerRegistry::IsDefault( 244 bool ProtocolHandlerRegistry::IsDefault(
244 const ProtocolHandler& handler) const { 245 const ProtocolHandler& handler) const {
245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
246 return GetHandlerFor(handler.protocol()) == handler; 247 return GetHandlerFor(handler.protocol()) == handler;
247 } 248 }
248 249
249 void ProtocolHandlerRegistry::Load() { 250 void ProtocolHandlerRegistry::Load() {
251 // Any further default additions to the table will get rejected from now on.
252 is_loaded_ = true;
250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
251 is_loading_ = true; 254 is_loading_ = true;
252 PrefService* prefs = profile_->GetPrefs(); 255 PrefService* prefs = profile_->GetPrefs();
253 if (prefs->HasPrefPath(prefs::kCustomHandlersEnabled)) { 256 if (prefs->HasPrefPath(prefs::kCustomHandlersEnabled)) {
254 enabled_ = prefs->GetBoolean(prefs::kCustomHandlersEnabled); 257 enabled_ = prefs->GetBoolean(prefs::kCustomHandlersEnabled);
255 BrowserThread::PostTask( 258 BrowserThread::PostTask(
256 BrowserThread::IO, 259 BrowserThread::IO,
257 FROM_HERE, 260 FROM_HERE,
258 base::Bind(enabled_ ? &ProtocolHandlerRegistry::EnableIO : 261 base::Bind(enabled_ ? &ProtocolHandlerRegistry::EnableIO :
259 &ProtocolHandlerRegistry::DisableIO, this)); 262 &ProtocolHandlerRegistry::DisableIO, this));
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 } 704 }
702 } 705 }
703 return result; 706 return result;
704 } 707 }
705 708
706 void ProtocolHandlerRegistry::IgnoreProtocolHandler( 709 void ProtocolHandlerRegistry::IgnoreProtocolHandler(
707 const ProtocolHandler& handler) { 710 const ProtocolHandler& handler) {
708 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 711 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
709 ignored_protocol_handlers_.push_back(handler); 712 ignored_protocol_handlers_.push_back(handler);
710 } 713 }
714
715 void ProtocolHandlerRegistry::AddDefaultHandler(
716 const ProtocolHandler& handler) {
717 // If called after the load command was issued this function will fail.
718 DCHECK(!is_loaded_);
719 RegisterProtocolHandler(handler);
720 SetDefault(handler);
721 }
722
723
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698