diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-27 02:56:21 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-27 02:56:21 +0000 |
commit | 649d1c0ea7c08dec1586220da91a2ac3f73206ea (patch) | |
tree | da3ba2bd2812f1440827aac59c2e657c0b06a243 /chrome/browser | |
parent | 3819c76919240d0470005263ae64761d7f7ed97f (diff) | |
download | chromium_src-649d1c0ea7c08dec1586220da91a2ac3f73206ea.zip chromium_src-649d1c0ea7c08dec1586220da91a2ac3f73206ea.tar.gz chromium_src-649d1c0ea7c08dec1586220da91a2ac3f73206ea.tar.bz2 |
RefCounted types should not have public destructors, chrome/browser/ part 6
BUG=123295
TEST=none
Review URL: http://codereview.chromium.org/10071036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134218 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
50 files changed, 724 insertions, 604 deletions
diff --git a/chrome/browser/autocomplete/builtin_provider.cc b/chrome/browser/autocomplete/builtin_provider.cc index c72d1d3..a80ee2d 100644 --- a/chrome/browser/autocomplete/builtin_provider.cc +++ b/chrome/browser/autocomplete/builtin_provider.cc @@ -46,8 +46,6 @@ BuiltinProvider::BuiltinProvider(ACProviderListener* listener, builtins_.push_back(settings + ASCIIToUTF16(kChromeSettingsSubPages[i])); } -BuiltinProvider::~BuiltinProvider() {} - void BuiltinProvider::Start(const AutocompleteInput& input, bool minimal_changes) { matches_.clear(); @@ -108,6 +106,8 @@ void BuiltinProvider::Start(const AutocompleteInput& input, matches_[i].relevance = kRelevance + matches_.size() - (i + 1); } +BuiltinProvider::~BuiltinProvider() {} + void BuiltinProvider::AddMatch(const string16& match_string, const ACMatchClassifications& styles) { AutocompleteMatch match(this, kRelevance, false, diff --git a/chrome/browser/autocomplete/builtin_provider.h b/chrome/browser/autocomplete/builtin_provider.h index 858c92d..e9af4cc 100644 --- a/chrome/browser/autocomplete/builtin_provider.h +++ b/chrome/browser/autocomplete/builtin_provider.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -22,13 +22,14 @@ class BuiltinProvider : public AutocompleteProvider { public: BuiltinProvider(ACProviderListener* listener, Profile* profile); - virtual ~BuiltinProvider(); // AutocompleteProvider: virtual void Start(const AutocompleteInput& input, bool minimal_changes) OVERRIDE; private: + virtual ~BuiltinProvider(); + typedef std::vector<string16> Builtins; static const int kRelevance; diff --git a/chrome/browser/autocomplete/history_provider.cc b/chrome/browser/autocomplete/history_provider.cc index fa6dd30..eab7c65 100644 --- a/chrome/browser/autocomplete/history_provider.cc +++ b/chrome/browser/autocomplete/history_provider.cc @@ -23,6 +23,8 @@ HistoryProvider::HistoryProvider(ACProviderListener* listener, always_prevent_inline_autocomplete_(false) { } +HistoryProvider::~HistoryProvider() {} + void HistoryProvider::DeleteMatch(const AutocompleteMatch& match) { DCHECK(done_); DCHECK(profile_); diff --git a/chrome/browser/autocomplete/history_provider.h b/chrome/browser/autocomplete/history_provider.h index df71ce9..98d62fa 100644 --- a/chrome/browser/autocomplete/history_provider.h +++ b/chrome/browser/autocomplete/history_provider.h @@ -19,6 +19,7 @@ class HistoryProvider : public AutocompleteProvider { HistoryProvider(ACProviderListener* listener, Profile* profile, const char* name); + virtual ~HistoryProvider(); // Fixes up user URL input to make it more possible to match against. Among // many other things, this takes care of the following: diff --git a/chrome/browser/autocomplete/history_quick_provider.cc b/chrome/browser/autocomplete/history_quick_provider.cc index 933278e..4f395ed 100644 --- a/chrome/browser/autocomplete/history_quick_provider.cc +++ b/chrome/browser/autocomplete/history_quick_provider.cc @@ -102,8 +102,6 @@ HistoryQuickProvider::HistoryQuickProvider(ACProviderListener* listener, inlining_option, NUM_OPTIONS); } -HistoryQuickProvider::~HistoryQuickProvider() {} - void HistoryQuickProvider::Start(const AutocompleteInput& input, bool minimal_changes) { matches_.clear(); @@ -142,6 +140,8 @@ void HistoryQuickProvider::Start(const AutocompleteInput& input, // TODO(mrossetti): Implement this function. (Will happen in next CL.) void HistoryQuickProvider::DeleteMatch(const AutocompleteMatch& match) {} +HistoryQuickProvider::~HistoryQuickProvider() {} + void HistoryQuickProvider::DoAutocomplete() { // Get the matching URLs from the DB. string16 term_string = autocomplete_input_.text(); diff --git a/chrome/browser/autocomplete/history_quick_provider.h b/chrome/browser/autocomplete/history_quick_provider.h index d8d7cc9..3622e12 100644 --- a/chrome/browser/autocomplete/history_quick_provider.h +++ b/chrome/browser/autocomplete/history_quick_provider.h @@ -24,8 +24,6 @@ class HistoryQuickProvider : public HistoryProvider { public: HistoryQuickProvider(ACProviderListener* listener, Profile* profile); - virtual ~HistoryQuickProvider(); - // AutocompleteProvider. |minimal_changes| is ignored since there // is no asynch completion performed. virtual void Start(const AutocompleteInput& input, @@ -45,6 +43,8 @@ class HistoryQuickProvider : public HistoryProvider { FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Spans); FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Relevance); + virtual ~HistoryQuickProvider(); + // Performs the autocomplete matching and scoring. void DoAutocomplete(); diff --git a/chrome/browser/autocomplete/shortcuts_provider.cc b/chrome/browser/autocomplete/shortcuts_provider.cc index 96bb9d1..f03467d 100644 --- a/chrome/browser/autocomplete/shortcuts_provider.cc +++ b/chrome/browser/autocomplete/shortcuts_provider.cc @@ -61,11 +61,6 @@ ShortcutsProvider::ShortcutsProvider(ACProviderListener* listener, } } -ShortcutsProvider::~ShortcutsProvider() { - if (shortcuts_backend_.get()) - shortcuts_backend_->RemoveObserver(this); -} - void ShortcutsProvider::Start(const AutocompleteInput& input, bool minimal_changes) { matches_.clear(); @@ -111,6 +106,11 @@ void ShortcutsProvider::DeleteMatch(const AutocompleteMatch& match) { history_service->DeleteURL(match.destination_url); } +ShortcutsProvider::~ShortcutsProvider() { + if (shortcuts_backend_.get()) + shortcuts_backend_->RemoveObserver(this); +} + void ShortcutsProvider::OnShortcutsLoaded() { initialized_ = true; } diff --git a/chrome/browser/autocomplete/shortcuts_provider.h b/chrome/browser/autocomplete/shortcuts_provider.h index 46260de..50c2e30 100644 --- a/chrome/browser/autocomplete/shortcuts_provider.h +++ b/chrome/browser/autocomplete/shortcuts_provider.h @@ -26,7 +26,6 @@ class ShortcutsProvider public history::ShortcutsBackend::ShortcutsBackendObserver { public: ShortcutsProvider(ACProviderListener* listener, Profile* profile); - virtual ~ShortcutsProvider(); // Performs the autocompletion synchronously. Since no asynch completion is // performed |minimal_changes| is ignored. @@ -41,6 +40,8 @@ class ShortcutsProvider FRIEND_TEST_ALL_PREFIXES(ShortcutsProviderTest, CalculateScore); FRIEND_TEST_ALL_PREFIXES(ShortcutsProviderTest, DeleteMatch); + virtual ~ShortcutsProvider(); + // ShortcutsBackendObserver: virtual void OnShortcutsLoaded() OVERRIDE; diff --git a/chrome/browser/autocomplete_history_manager_unittest.cc b/chrome/browser/autocomplete_history_manager_unittest.cc index 6cd211a..476b297 100644 --- a/chrome/browser/autocomplete_history_manager_unittest.cc +++ b/chrome/browser/autocomplete_history_manager_unittest.cc @@ -29,6 +29,9 @@ class MockWebDataService : public WebDataService { public: MOCK_METHOD1(AddFormFields, void(const std::vector<webkit::forms::FormField>&)); // NOLINT + + protected: + virtual ~MockWebDataService() {} }; class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness { diff --git a/chrome/browser/autofill/autofill_external_delegate_unittest.cc b/chrome/browser/autofill/autofill_external_delegate_unittest.cc index e0ba283..1f1c918 100644 --- a/chrome/browser/autofill/autofill_external_delegate_unittest.cc +++ b/chrome/browser/autofill/autofill_external_delegate_unittest.cc @@ -55,13 +55,15 @@ class MockAutofillManager : public AutofillManager { public: explicit MockAutofillManager(TabContentsWrapper* tab_contents) : AutofillManager(tab_contents) {} - ~MockAutofillManager() {} MOCK_METHOD4(OnFillAutofillFormData, void(int query_id, const webkit::forms::FormData& form, const webkit::forms::FormField& field, int unique_id)); + + protected: + virtual ~MockAutofillManager() {} }; } // namespace diff --git a/chrome/browser/background/background_contents_service.cc b/chrome/browser/background/background_contents_service.cc index 150f8a9..d6dc9a7 100644 --- a/chrome/browser/background/background_contents_service.cc +++ b/chrome/browser/background/background_contents_service.cc @@ -61,9 +61,6 @@ class CrashNotificationDelegate : public NotificationDelegate { extension_id_(extension->id()) { } - ~CrashNotificationDelegate() { - } - void Display() {} void Error() {} @@ -93,6 +90,8 @@ class CrashNotificationDelegate : public NotificationDelegate { } private: + virtual ~CrashNotificationDelegate() {} + Profile* profile_; bool is_hosted_app_; std::string extension_id_; diff --git a/chrome/browser/chrome_quota_permission_context.cc b/chrome/browser/chrome_quota_permission_context.cc index 48ac49d..1586340 100644 --- a/chrome/browser/chrome_quota_permission_context.cc +++ b/chrome/browser/chrome_quota_permission_context.cc @@ -109,11 +109,7 @@ bool RequestQuotaInfoBarDelegate::Cancel() { } // anonymous namespace -ChromeQuotaPermissionContext::ChromeQuotaPermissionContext() { -} - -ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() { -} +ChromeQuotaPermissionContext::ChromeQuotaPermissionContext() {} void ChromeQuotaPermissionContext::RequestQuotaPermission( const GURL& origin_url, @@ -172,3 +168,5 @@ void ChromeQuotaPermissionContext::DispatchCallbackOnIOThread( callback.Run(response); } + +ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {} diff --git a/chrome/browser/chrome_quota_permission_context.h b/chrome/browser/chrome_quota_permission_context.h index 3bb8596..895d4af 100644 --- a/chrome/browser/chrome_quota_permission_context.h +++ b/chrome/browser/chrome_quota_permission_context.h @@ -11,7 +11,6 @@ class ChromeQuotaPermissionContext : public content::QuotaPermissionContext { public: ChromeQuotaPermissionContext(); - virtual ~ChromeQuotaPermissionContext(); // The callback will be dispatched on the IO thread. virtual void RequestQuotaPermission( @@ -25,6 +24,9 @@ class ChromeQuotaPermissionContext : public content::QuotaPermissionContext { void DispatchCallbackOnIOThread( const PermissionCallback& callback, QuotaPermissionResponse response); + + private: + virtual ~ChromeQuotaPermissionContext(); }; #endif // CHROME_BROWSER_CHROME_QUOTA_PERMISSION_CONTEXT_H_ diff --git a/chrome/browser/content_settings/cookie_settings.cc b/chrome/browser/content_settings/cookie_settings.cc index 742cc73..ff27e34 100644 --- a/chrome/browser/content_settings/cookie_settings.cc +++ b/chrome/browser/content_settings/cookie_settings.cc @@ -98,9 +98,6 @@ CookieSettings::CookieSettings( pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this); } -CookieSettings::~CookieSettings() { -} - ContentSetting CookieSettings::GetDefaultCookieSetting(std::string* provider_id) const { return host_content_settings_map_->GetDefaultContentSetting( @@ -227,6 +224,8 @@ ContentSetting CookieSettings::GetCookieSetting( return content_settings::ValueToContentSetting(value.get()); } +CookieSettings::~CookieSettings() {} + bool CookieSettings::ShouldBlockThirdPartyCookies() const { base::AutoLock auto_lock(lock_); return block_third_party_cookies_; diff --git a/chrome/browser/content_settings/cookie_settings.h b/chrome/browser/content_settings/cookie_settings.h index 59996ef..3e3feb3 100644 --- a/chrome/browser/content_settings/cookie_settings.h +++ b/chrome/browser/content_settings/cookie_settings.h @@ -37,8 +37,6 @@ class CookieSettings HostContentSettingsMap* host_content_settings_map, PrefService* prefs); - virtual ~CookieSettings(); - // Returns the default content setting (CONTENT_SETTING_ALLOW, // CONTENT_SETTING_BLOCK, or CONTENT_SETTING_SESSION_ONLY) for cookies. If // |provider_id| is not NULL, the id of the provider which provided the @@ -136,6 +134,8 @@ class CookieSettings }; private: + virtual ~CookieSettings(); + // Returns true if the "block third party cookies" preference is set. // // This method may be called on any thread. diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.cc b/chrome/browser/custom_handlers/protocol_handler_registry.cc index d81af98..ab8753a 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry.cc @@ -27,172 +27,224 @@ using content::BrowserThread; using content::ChildProcessSecurityPolicy; -// ProtocolHandlerRegistry ----------------------------------------------------- +namespace { -ProtocolHandlerRegistry::ProtocolHandlerRegistry(Profile* profile, - Delegate* delegate) - : profile_(profile), - delegate_(delegate), - enabled_(true), - enabled_io_(enabled_), - is_loading_(false) { +// If true default protocol handlers will be removed if the OS level +// registration for a protocol is no longer Chrome. +bool ShouldRemoveHandlersNotInOS() { +#if defined(OS_LINUX) + // We don't do this on Linux as the OS registration there is not reliable, + // and Chrome OS doesn't have any notion of OS registration. + // TODO(benwells): When Linux support is more reliable remove this + // difference (http://crbug.com/88255). + return false; +#else + return ShellIntegration::CanSetAsDefaultProtocolClient(); +#endif } -ProtocolHandlerRegistry::~ProtocolHandlerRegistry() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DCHECK(default_client_observers_.empty()); -} +} // namespace -void ProtocolHandlerRegistry::Finalize() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - delegate_.reset(NULL); - // We free these now in case there are any outstanding workers running. If - // we didn't free them they could respond to workers and try to update the - // protocol handler registry after it was deleted. - // Observers remove themselves from this list when they are deleted; so - // we delete the last item until none are left in the list. - while (!default_client_observers_.empty()) { - delete default_client_observers_.back(); +static const ProtocolHandler& LookupHandler( + const ProtocolHandlerRegistry::ProtocolHandlerMap& handler_map, + const std::string& scheme) { + ProtocolHandlerRegistry::ProtocolHandlerMap::const_iterator p = + handler_map.find(scheme); + if (p != handler_map.end()) { + return p->second; } + return ProtocolHandler::EmptyProtocolHandler(); } -const ProtocolHandlerRegistry::ProtocolHandlerList* -ProtocolHandlerRegistry::GetHandlerList( - const std::string& scheme) const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - ProtocolHandlerMultiMap::const_iterator p = protocol_handlers_.find(scheme); - if (p == protocol_handlers_.end()) { - return NULL; - } - return &p->second; +// DefaultClientObserver ------------------------------------------------------ + +ProtocolHandlerRegistry::DefaultClientObserver::DefaultClientObserver( + ProtocolHandlerRegistry* registry) + : worker_(NULL), + registry_(registry) { + DCHECK(registry_); } -ProtocolHandlerRegistry::ProtocolHandlerList -ProtocolHandlerRegistry::GetHandlersFor( - const std::string& scheme) const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - ProtocolHandlerMultiMap::const_iterator p = protocol_handlers_.find(scheme); - if (p == protocol_handlers_.end()) { - return ProtocolHandlerList(); +ProtocolHandlerRegistry::DefaultClientObserver::~DefaultClientObserver() { + if (worker_) + worker_->ObserverDestroyed(); + + DefaultClientObserverList::iterator iter = std::find( + registry_->default_client_observers_.begin(), + registry_->default_client_observers_.end(), this); + registry_->default_client_observers_.erase(iter); +} + +void +ProtocolHandlerRegistry::DefaultClientObserver::SetDefaultWebClientUIState( + ShellIntegration::DefaultWebClientUIState state) { + if (worker_) { + if (ShouldRemoveHandlersNotInOS() && + (state == ShellIntegration::STATE_NOT_DEFAULT)) { + registry_->ClearDefault(worker_->protocol()); + } + } else { + NOTREACHED(); } - return p->second; } -ProtocolHandlerRegistry::ProtocolHandlerList -ProtocolHandlerRegistry::GetIgnoredHandlers() { - return ignored_protocol_handlers_; +void ProtocolHandlerRegistry::DefaultClientObserver::SetWorker( + ShellIntegration::DefaultProtocolClientWorker* worker) { + worker_ = worker; } -void ProtocolHandlerRegistry::RegisterProtocolHandler( - const ProtocolHandler& handler) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(CanSchemeBeOverridden(handler.protocol())); - DCHECK(!handler.IsEmpty()); - if (IsRegistered(handler)) { - return; +// Delegate -------------------------------------------------------------------- + +ProtocolHandlerRegistry::Delegate::~Delegate() {} + +void ProtocolHandlerRegistry::Delegate::RegisterExternalHandler( + const std::string& protocol) { + ChildProcessSecurityPolicy* policy = + ChildProcessSecurityPolicy::GetInstance(); + if (!policy->IsWebSafeScheme(protocol)) { + policy->RegisterWebSafeScheme(protocol); } - if (enabled_ && !delegate_->IsExternalHandlerRegistered(handler.protocol())) - delegate_->RegisterExternalHandler(handler.protocol()); - InsertHandler(handler); } -void ProtocolHandlerRegistry::InsertHandler(const ProtocolHandler& handler) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - ProtocolHandlerMultiMap::iterator p = - protocol_handlers_.find(handler.protocol()); +void ProtocolHandlerRegistry::Delegate::DeregisterExternalHandler( + const std::string& protocol) { +} - if (p != protocol_handlers_.end()) { - p->second.push_back(handler); - return; - } +bool ProtocolHandlerRegistry::Delegate::IsExternalHandlerRegistered( + const std::string& protocol) { + // NOTE(koz): This function is safe to call from any thread, despite living + // in ProfileIOData. + return ProfileIOData::IsHandledProtocol(protocol); +} - ProtocolHandlerList new_list; - new_list.push_back(handler); - protocol_handlers_[handler.protocol()] = new_list; +ShellIntegration::DefaultProtocolClientWorker* +ProtocolHandlerRegistry::Delegate::CreateShellWorker( + ShellIntegration::DefaultWebClientObserver* observer, + const std::string& protocol) { + return new ShellIntegration::DefaultProtocolClientWorker(observer, protocol); } -void ProtocolHandlerRegistry::IgnoreProtocolHandler( +ProtocolHandlerRegistry::DefaultClientObserver* +ProtocolHandlerRegistry::Delegate::CreateShellObserver( + ProtocolHandlerRegistry* registry) { + return new DefaultClientObserver(registry); +} + +void ProtocolHandlerRegistry::Delegate::RegisterWithOSAsDefaultClient( + const std::string& protocol, ProtocolHandlerRegistry* registry) { + DefaultClientObserver* observer = CreateShellObserver(registry); + // The worker pointer is reference counted. While it is running the + // message loops of the FILE and UI thread will hold references to it + // and it will be automatically freed once all its tasks have finished. + scoped_refptr<ShellIntegration::DefaultProtocolClientWorker> worker; + worker = CreateShellWorker(observer, protocol); + observer->SetWorker(worker); + registry->default_client_observers_.push_back(observer); + worker->StartSetAsDefault(); +} + +// ProtocolHandlerRegistry ----------------------------------------------------- + +ProtocolHandlerRegistry::ProtocolHandlerRegistry(Profile* profile, + Delegate* delegate) + : profile_(profile), + delegate_(delegate), + enabled_(true), + enabled_io_(enabled_), + is_loading_(false) { +} + +bool ProtocolHandlerRegistry::SilentlyHandleRegisterHandlerRequest( + const ProtocolHandler& handler) { + if (handler.IsEmpty() || !CanSchemeBeOverridden(handler.protocol())) + return true; + + if (!enabled() || IsRegistered(handler) || HasIgnoredEquivalent(handler)) + return true; + + if (AttemptReplace(handler)) + return true; + + return false; +} + +void ProtocolHandlerRegistry::OnAcceptRegisterProtocolHandler( const ProtocolHandler& handler) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - ignored_protocol_handlers_.push_back(handler); + RegisterProtocolHandler(handler); + SetDefault(handler); + Save(); + NotifyChanged(); } -void ProtocolHandlerRegistry::Enable() { +void ProtocolHandlerRegistry::OnDenyRegisterProtocolHandler( + const ProtocolHandler& handler) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (enabled_) { - return; - } - enabled_ = true; - BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind(&ProtocolHandlerRegistry::EnableIO, this)); - ProtocolHandlerMap::const_iterator p; - for (p = default_handlers_.begin(); p != default_handlers_.end(); ++p) { - delegate_->RegisterExternalHandler(p->first); - } + RegisterProtocolHandler(handler); Save(); NotifyChanged(); } -void ProtocolHandlerRegistry::Disable() { +void ProtocolHandlerRegistry::OnIgnoreRegisterProtocolHandler( + const ProtocolHandler& handler) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!enabled_) { - return; - } - enabled_ = false; - BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind(&ProtocolHandlerRegistry::DisableIO, this)); - ProtocolHandlerMap::const_iterator p; - for (p = default_handlers_.begin(); p != default_handlers_.end(); ++p) { - delegate_->DeregisterExternalHandler(p->first); - } + IgnoreProtocolHandler(handler); Save(); NotifyChanged(); } -std::vector<const DictionaryValue*> -ProtocolHandlerRegistry::GetHandlersFromPref(const char* pref_name) const { +bool ProtocolHandlerRegistry::AttemptReplace(const ProtocolHandler& handler) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - std::vector<const DictionaryValue*> result; - PrefService* prefs = profile_->GetPrefs(); - if (!prefs->HasPrefPath(pref_name)) { - return result; + ProtocolHandler old_default = GetHandlerFor(handler.protocol()); + bool make_new_handler_default = handler.IsSameOrigin(old_default); + ProtocolHandlerList to_replace(GetReplacedHandlers(handler)); + if (to_replace.empty()) + return false; + for (ProtocolHandlerList::iterator p = to_replace.begin(); + p != to_replace.end(); ++p) { + RemoveHandler(*p); } + if (make_new_handler_default) { + OnAcceptRegisterProtocolHandler(handler); + } else { + InsertHandler(handler); + NotifyChanged(); + } + return true; +} - const ListValue* handlers = prefs->GetList(pref_name); - if (handlers) { - for (size_t i = 0; i < handlers->GetSize(); ++i) { - DictionaryValue* dict; - if (!handlers->GetDictionary(i, &dict)) - continue; - if (ProtocolHandler::IsValidDict(dict)) { - result.push_back(dict); - } +ProtocolHandlerRegistry::ProtocolHandlerList +ProtocolHandlerRegistry::GetReplacedHandlers( + const ProtocolHandler& handler) const { + ProtocolHandlerList replaced_handlers; + const ProtocolHandlerList* handlers = GetHandlerList(handler.protocol()); + if (!handlers) + return replaced_handlers; + for (ProtocolHandlerList::const_iterator p = handlers->begin(); + p != handlers->end(); p++) { + if (handler.IsSameOrigin(*p)) { + replaced_handlers.push_back(*p); } } - return result; + return replaced_handlers; } -namespace { - -// If true default protocol handlers will be removed if the OS level -// registration for a protocol is no longer Chrome. -bool ShouldRemoveHandlersNotInOS() { -#if defined(OS_LINUX) - // We don't do this on Linux as the OS registration there is not reliable, - // and Chrome OS doesn't have any notion of OS registration. - // TODO(benwells): When Linux support is more reliable remove this - // difference (http://crbug.com/88255). - return false; -#else - return ShellIntegration::CanSetAsDefaultProtocolClient(); -#endif +void ProtocolHandlerRegistry::ClearDefault(const std::string& scheme) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + default_handlers_.erase(scheme); + BrowserThread::PostTask( + BrowserThread::IO, + FROM_HERE, + base::Bind(&ProtocolHandlerRegistry::ClearDefaultIO, this, scheme)); + Save(); + NotifyChanged(); } -} // namespace +bool ProtocolHandlerRegistry::IsDefault( + const ProtocolHandler& handler) const { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + return GetHandlerFor(handler.protocol()) == handler; +} void ProtocolHandlerRegistry::Load() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -243,30 +295,38 @@ void ProtocolHandlerRegistry::Load() { } } -void ProtocolHandlerRegistry::Save() { +int ProtocolHandlerRegistry::GetHandlerIndex(const std::string& scheme) const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (is_loading_) { - return; + const ProtocolHandler& handler = GetHandlerFor(scheme); + if (handler.IsEmpty()) + return -1; + const ProtocolHandlerList* handlers = GetHandlerList(scheme); + if (!handlers) + return -1; + + ProtocolHandlerList::const_iterator p; + int i; + for (i = 0, p = handlers->begin(); p != handlers->end(); ++p, ++i) { + if (*p == handler) + return i; } - scoped_ptr<Value> registered_protocol_handlers(EncodeRegisteredHandlers()); - scoped_ptr<Value> ignored_protocol_handlers(EncodeIgnoredHandlers()); - scoped_ptr<Value> enabled(Value::CreateBooleanValue(enabled_)); - profile_->GetPrefs()->Set(prefs::kRegisteredProtocolHandlers, - *registered_protocol_handlers); - profile_->GetPrefs()->Set(prefs::kIgnoredProtocolHandlers, - *ignored_protocol_handlers); - profile_->GetPrefs()->Set(prefs::kCustomHandlersEnabled, *enabled); + return -1; } -bool ProtocolHandlerRegistry::CanSchemeBeOverridden( +ProtocolHandlerRegistry::ProtocolHandlerList +ProtocolHandlerRegistry::GetHandlersFor( const std::string& scheme) const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - const ProtocolHandlerList* handlers = GetHandlerList(scheme); - // If we already have a handler for this scheme, we can add more. - if (handlers != NULL && !handlers->empty()) - return true; - // Don't override a scheme if it already has an external handler. - return !delegate_->IsExternalHandlerRegistered(scheme); + ProtocolHandlerMultiMap::const_iterator p = protocol_handlers_.find(scheme); + if (p == protocol_handlers_.end()) { + return ProtocolHandlerList(); + } + return p->second; +} + +ProtocolHandlerRegistry::ProtocolHandlerList +ProtocolHandlerRegistry::GetIgnoredHandlers() { + return ignored_protocol_handlers_; } void ProtocolHandlerRegistry::GetRegisteredProtocols( @@ -279,20 +339,15 @@ void ProtocolHandlerRegistry::GetRegisteredProtocols( } } -void ProtocolHandlerRegistry::RemoveIgnoredHandler( - const ProtocolHandler& handler) { +bool ProtocolHandlerRegistry::CanSchemeBeOverridden( + const std::string& scheme) const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - bool should_notify = false; - ProtocolHandlerList::iterator p = std::find( - ignored_protocol_handlers_.begin(), ignored_protocol_handlers_.end(), - handler); - if (p != ignored_protocol_handlers_.end()) { - ignored_protocol_handlers_.erase(p); - Save(); - should_notify = true; - } - if (should_notify) - NotifyChanged(); + const ProtocolHandlerList* handlers = GetHandlerList(scheme); + // If we already have a handler for this scheme, we can add more. + if (handlers != NULL && !handlers->empty()) + return true; + // Don't override a scheme if it already has an external handler. + return !delegate_->IsExternalHandlerRegistered(scheme); } bool ProtocolHandlerRegistry::IsRegistered( @@ -306,6 +361,18 @@ bool ProtocolHandlerRegistry::IsRegistered( handlers->end(); } +bool ProtocolHandlerRegistry::IsIgnored(const ProtocolHandler& handler) const { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + ProtocolHandlerList::const_iterator i; + for (i = ignored_protocol_handlers_.begin(); + i != ignored_protocol_handlers_.end(); ++i) { + if (*i == handler) { + return true; + } + } + return false; +} + bool ProtocolHandlerRegistry::HasRegisteredEquivalent( const ProtocolHandler& handler) const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -322,29 +389,33 @@ bool ProtocolHandlerRegistry::HasRegisteredEquivalent( return false; } -bool ProtocolHandlerRegistry::IsIgnored(const ProtocolHandler& handler) const { +bool ProtocolHandlerRegistry::HasIgnoredEquivalent( + const ProtocolHandler& handler) const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); ProtocolHandlerList::const_iterator i; for (i = ignored_protocol_handlers_.begin(); i != ignored_protocol_handlers_.end(); ++i) { - if (*i == handler) { + if (handler.IsEquivalent(*i)) { return true; } } return false; } -bool ProtocolHandlerRegistry::HasIgnoredEquivalent( - const ProtocolHandler& handler) const { +void ProtocolHandlerRegistry::RemoveIgnoredHandler( + const ProtocolHandler& handler) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - ProtocolHandlerList::const_iterator i; - for (i = ignored_protocol_handlers_.begin(); - i != ignored_protocol_handlers_.end(); ++i) { - if (handler.IsEquivalent(*i)) { - return true; - } + bool should_notify = false; + ProtocolHandlerList::iterator p = std::find( + ignored_protocol_handlers_.begin(), ignored_protocol_handlers_.end(), + handler); + if (p != ignored_protocol_handlers_.end()) { + ignored_protocol_handlers_.erase(p); + Save(); + should_notify = true; } - return false; + if (should_notify) + NotifyChanged(); } bool ProtocolHandlerRegistry::IsHandledProtocol( @@ -353,6 +424,12 @@ bool ProtocolHandlerRegistry::IsHandledProtocol( return enabled_ && !GetHandlerFor(scheme).IsEmpty(); } +bool ProtocolHandlerRegistry::IsHandledProtocolIO( + const std::string& scheme) const { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + return enabled_io_ && !LookupHandler(default_handlers_io_, scheme).IsEmpty(); +} + void ProtocolHandlerRegistry::RemoveHandler( const ProtocolHandler& handler) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -391,120 +468,76 @@ void ProtocolHandlerRegistry::RemoveDefaultHandler(const std::string& scheme) { RemoveHandler(current_default); } -static const ProtocolHandler& LookupHandler( - const ProtocolHandlerRegistry::ProtocolHandlerMap& handler_map, - const std::string& scheme) { - ProtocolHandlerRegistry::ProtocolHandlerMap::const_iterator p = - handler_map.find(scheme); - if (p != handler_map.end()) { - return p->second; - } - return ProtocolHandler::EmptyProtocolHandler(); -} - -Value* ProtocolHandlerRegistry::EncodeRegisteredHandlers() { +const ProtocolHandler& ProtocolHandlerRegistry::GetHandlerFor( + const std::string& scheme) const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - ListValue* protocol_handlers = new ListValue(); - for (ProtocolHandlerMultiMap::iterator i = protocol_handlers_.begin(); - i != protocol_handlers_.end(); ++i) { - for (ProtocolHandlerList::iterator j = i->second.begin(); - j != i->second.end(); ++j) { - DictionaryValue* encoded = j->Encode(); - if (IsDefault(*j)) { - encoded->Set("default", Value::CreateBooleanValue(true)); - } - protocol_handlers->Append(encoded); - } - } - return protocol_handlers; + return LookupHandler(default_handlers_, scheme); } -Value* ProtocolHandlerRegistry::EncodeIgnoredHandlers() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - ListValue* handlers = new ListValue(); - for (ProtocolHandlerList::iterator i = ignored_protocol_handlers_.begin(); - i != ignored_protocol_handlers_.end(); ++i) { - handlers->Append(i->Encode()); +net::URLRequestJob* ProtocolHandlerRegistry::MaybeCreateJob( + net::URLRequest* request) const { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + ProtocolHandler handler = LookupHandler(default_handlers_io_, + request->url().scheme()); + if (handler.IsEmpty()) { + return NULL; } - return handlers; -} - -bool ProtocolHandlerRegistry::SilentlyHandleRegisterHandlerRequest( - const ProtocolHandler& handler) { - if (handler.IsEmpty() || !CanSchemeBeOverridden(handler.protocol())) - return true; - - if (!enabled() || IsRegistered(handler) || HasIgnoredEquivalent(handler)) - return true; - - if (AttemptReplace(handler)) - return true; - - return false; -} - -void ProtocolHandlerRegistry::OnAcceptRegisterProtocolHandler( - const ProtocolHandler& handler) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - RegisterProtocolHandler(handler); - SetDefault(handler); - Save(); - NotifyChanged(); + GURL translated_url(handler.TranslateUrl(request->url())); + if (!translated_url.is_valid()) { + return NULL; + } + return new net::URLRequestRedirectJob(request, translated_url); } -void ProtocolHandlerRegistry::OnDenyRegisterProtocolHandler( - const ProtocolHandler& handler) { +void ProtocolHandlerRegistry::Enable() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - RegisterProtocolHandler(handler); + if (enabled_) { + return; + } + enabled_ = true; + BrowserThread::PostTask( + BrowserThread::IO, + FROM_HERE, + base::Bind(&ProtocolHandlerRegistry::EnableIO, this)); + ProtocolHandlerMap::const_iterator p; + for (p = default_handlers_.begin(); p != default_handlers_.end(); ++p) { + delegate_->RegisterExternalHandler(p->first); + } Save(); NotifyChanged(); } -void ProtocolHandlerRegistry::OnIgnoreRegisterProtocolHandler( - const ProtocolHandler& handler) { +void ProtocolHandlerRegistry::Disable() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - IgnoreProtocolHandler(handler); + if (!enabled_) { + return; + } + enabled_ = false; + BrowserThread::PostTask( + BrowserThread::IO, + FROM_HERE, + base::Bind(&ProtocolHandlerRegistry::DisableIO, this)); + ProtocolHandlerMap::const_iterator p; + for (p = default_handlers_.begin(); p != default_handlers_.end(); ++p) { + delegate_->DeregisterExternalHandler(p->first); + } Save(); NotifyChanged(); } -bool ProtocolHandlerRegistry::AttemptReplace(const ProtocolHandler& handler) { +void ProtocolHandlerRegistry::Finalize() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - ProtocolHandler old_default = GetHandlerFor(handler.protocol()); - bool make_new_handler_default = handler.IsSameOrigin(old_default); - ProtocolHandlerList to_replace(GetReplacedHandlers(handler)); - if (to_replace.empty()) - return false; - for (ProtocolHandlerList::iterator p = to_replace.begin(); - p != to_replace.end(); ++p) { - RemoveHandler(*p); - } - if (make_new_handler_default) { - OnAcceptRegisterProtocolHandler(handler); - } else { - InsertHandler(handler); - NotifyChanged(); - } - return true; -} - -ProtocolHandlerRegistry::ProtocolHandlerList -ProtocolHandlerRegistry::GetReplacedHandlers( - const ProtocolHandler& handler) const { - ProtocolHandlerList replaced_handlers; - const ProtocolHandlerList* handlers = GetHandlerList(handler.protocol()); - if (!handlers) - return replaced_handlers; - for (ProtocolHandlerList::const_iterator p = handlers->begin(); - p != handlers->end(); p++) { - if (handler.IsSameOrigin(*p)) { - replaced_handlers.push_back(*p); - } + delegate_.reset(NULL); + // We free these now in case there are any outstanding workers running. If + // we didn't free them they could respond to workers and try to update the + // protocol handler registry after it was deleted. + // Observers remove themselves from this list when they are deleted; so + // we delete the last item until none are left in the list. + while (!default_client_observers_.empty()) { + delete default_client_observers_.back(); } - return replaced_handlers; } - // static void ProtocolHandlerRegistry::RegisterPrefs(PrefService* pref_service) { pref_service->RegisterListPref(prefs::kRegisteredProtocolHandlers, @@ -515,62 +548,9 @@ void ProtocolHandlerRegistry::RegisterPrefs(PrefService* pref_service) { PrefService::UNSYNCABLE_PREF); } -void ProtocolHandlerRegistry::SetDefault(const ProtocolHandler& handler) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - ProtocolHandlerMap::const_iterator p = default_handlers_.find( - handler.protocol()); - // If we're not loading, and we are setting a default for a new protocol, - // register with the OS. - if (!is_loading_ && p == default_handlers_.end()) - delegate_->RegisterWithOSAsDefaultClient(handler.protocol(), this); - default_handlers_.erase(handler.protocol()); - default_handlers_.insert(std::make_pair(handler.protocol(), handler)); - PromoteHandler(handler); - BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind(&ProtocolHandlerRegistry::SetDefaultIO, this, handler)); -} - -void ProtocolHandlerRegistry::ClearDefault(const std::string& scheme) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - default_handlers_.erase(scheme); - BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind(&ProtocolHandlerRegistry::ClearDefaultIO, this, scheme)); - Save(); - NotifyChanged(); -} - -bool ProtocolHandlerRegistry::IsDefault( - const ProtocolHandler& handler) const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - return GetHandlerFor(handler.protocol()) == handler; -} - -const ProtocolHandler& ProtocolHandlerRegistry::GetHandlerFor( - const std::string& scheme) const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - return LookupHandler(default_handlers_, scheme); -} - -int ProtocolHandlerRegistry::GetHandlerIndex(const std::string& scheme) const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - const ProtocolHandler& handler = GetHandlerFor(scheme); - if (handler.IsEmpty()) - return -1; - const ProtocolHandlerList* handlers = GetHandlerList(scheme); - if (!handlers) - return -1; - - ProtocolHandlerList::const_iterator p; - int i; - for (i = 0, p = handlers->begin(); p != handlers->end(); ++p, ++i) { - if (*p == handler) - return i; - } - return -1; +ProtocolHandlerRegistry::~ProtocolHandlerRegistry() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + DCHECK(default_client_observers_.empty()); } void ProtocolHandlerRegistry::PromoteHandler(const ProtocolHandler& handler) { @@ -583,16 +563,6 @@ void ProtocolHandlerRegistry::PromoteHandler(const ProtocolHandler& handler) { list.insert(list.begin(), handler); } -void ProtocolHandlerRegistry::NotifyChanged() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, - content::Source<Profile>(profile_), - content::NotificationService::NoDetails()); -} - -// IO thread methods ----------------------------------------------------------- - void ProtocolHandlerRegistry::ClearDefaultIO(const std::string& scheme) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); default_handlers_io_.erase(scheme); @@ -604,110 +574,137 @@ void ProtocolHandlerRegistry::SetDefaultIO(const ProtocolHandler& handler) { default_handlers_io_.insert(std::make_pair(handler.protocol(), handler)); } -bool ProtocolHandlerRegistry::IsHandledProtocolIO( - const std::string& scheme) const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - return enabled_io_ && !LookupHandler(default_handlers_io_, scheme).IsEmpty(); +void ProtocolHandlerRegistry::Save() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + if (is_loading_) { + return; + } + scoped_ptr<Value> registered_protocol_handlers(EncodeRegisteredHandlers()); + scoped_ptr<Value> ignored_protocol_handlers(EncodeIgnoredHandlers()); + scoped_ptr<Value> enabled(Value::CreateBooleanValue(enabled_)); + profile_->GetPrefs()->Set(prefs::kRegisteredProtocolHandlers, + *registered_protocol_handlers); + profile_->GetPrefs()->Set(prefs::kIgnoredProtocolHandlers, + *ignored_protocol_handlers); + profile_->GetPrefs()->Set(prefs::kCustomHandlersEnabled, *enabled); } -net::URLRequestJob* ProtocolHandlerRegistry::MaybeCreateJob( - net::URLRequest* request) const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - ProtocolHandler handler = LookupHandler(default_handlers_io_, - request->url().scheme()); - if (handler.IsEmpty()) { - return NULL; - } - GURL translated_url(handler.TranslateUrl(request->url())); - if (!translated_url.is_valid()) { +const ProtocolHandlerRegistry::ProtocolHandlerList* +ProtocolHandlerRegistry::GetHandlerList( + const std::string& scheme) const { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + ProtocolHandlerMultiMap::const_iterator p = protocol_handlers_.find(scheme); + if (p == protocol_handlers_.end()) { return NULL; } - return new net::URLRequestRedirectJob(request, translated_url); + return &p->second; } -// Delegate -------------------------------------------------------------------- - -ProtocolHandlerRegistry::Delegate::~Delegate() { +void ProtocolHandlerRegistry::SetDefault(const ProtocolHandler& handler) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + ProtocolHandlerMap::const_iterator p = default_handlers_.find( + handler.protocol()); + // If we're not loading, and we are setting a default for a new protocol, + // register with the OS. + if (!is_loading_ && p == default_handlers_.end()) + delegate_->RegisterWithOSAsDefaultClient(handler.protocol(), this); + default_handlers_.erase(handler.protocol()); + default_handlers_.insert(std::make_pair(handler.protocol(), handler)); + PromoteHandler(handler); + BrowserThread::PostTask( + BrowserThread::IO, + FROM_HERE, + base::Bind(&ProtocolHandlerRegistry::SetDefaultIO, this, handler)); } -void ProtocolHandlerRegistry::Delegate::RegisterExternalHandler( - const std::string& protocol) { - ChildProcessSecurityPolicy* policy = - ChildProcessSecurityPolicy::GetInstance(); - if (!policy->IsWebSafeScheme(protocol)) { - policy->RegisterWebSafeScheme(protocol); - } -} +void ProtocolHandlerRegistry::InsertHandler(const ProtocolHandler& handler) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + ProtocolHandlerMultiMap::iterator p = + protocol_handlers_.find(handler.protocol()); -void ProtocolHandlerRegistry::Delegate::DeregisterExternalHandler( - const std::string& protocol) { -} + if (p != protocol_handlers_.end()) { + p->second.push_back(handler); + return; + } -ShellIntegration::DefaultProtocolClientWorker* -ProtocolHandlerRegistry::Delegate::CreateShellWorker( - ShellIntegration::DefaultWebClientObserver* observer, - const std::string& protocol) { - return new ShellIntegration::DefaultProtocolClientWorker(observer, protocol); + ProtocolHandlerList new_list; + new_list.push_back(handler); + protocol_handlers_[handler.protocol()] = new_list; } -ProtocolHandlerRegistry::DefaultClientObserver* -ProtocolHandlerRegistry::Delegate::CreateShellObserver( - ProtocolHandlerRegistry* registry) { - return new DefaultClientObserver(registry); +Value* ProtocolHandlerRegistry::EncodeRegisteredHandlers() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + ListValue* protocol_handlers = new ListValue(); + for (ProtocolHandlerMultiMap::iterator i = protocol_handlers_.begin(); + i != protocol_handlers_.end(); ++i) { + for (ProtocolHandlerList::iterator j = i->second.begin(); + j != i->second.end(); ++j) { + DictionaryValue* encoded = j->Encode(); + if (IsDefault(*j)) { + encoded->Set("default", Value::CreateBooleanValue(true)); + } + protocol_handlers->Append(encoded); + } + } + return protocol_handlers; } -void ProtocolHandlerRegistry::Delegate::RegisterWithOSAsDefaultClient( - const std::string& protocol, ProtocolHandlerRegistry* registry) { - DefaultClientObserver* observer = CreateShellObserver(registry); - // The worker pointer is reference counted. While it is running the - // message loops of the FILE and UI thread will hold references to it - // and it will be automatically freed once all its tasks have finished. - scoped_refptr<ShellIntegration::DefaultProtocolClientWorker> worker; - worker = CreateShellWorker(observer, protocol); - observer->SetWorker(worker); - registry->default_client_observers_.push_back(observer); - worker->StartSetAsDefault(); +Value* ProtocolHandlerRegistry::EncodeIgnoredHandlers() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + ListValue* handlers = new ListValue(); + for (ProtocolHandlerList::iterator i = ignored_protocol_handlers_.begin(); + i != ignored_protocol_handlers_.end(); ++i) { + handlers->Append(i->Encode()); + } + return handlers; } -bool ProtocolHandlerRegistry::Delegate::IsExternalHandlerRegistered( - const std::string& protocol) { - // NOTE(koz): This function is safe to call from any thread, despite living - // in ProfileIOData. - return ProfileIOData::IsHandledProtocol(protocol); +void ProtocolHandlerRegistry::NotifyChanged() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + content::NotificationService::current()->Notify( + chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, + content::Source<Profile>(profile_), + content::NotificationService::NoDetails()); } -// DefaultClientObserver ------------------------------------------------------ - -ProtocolHandlerRegistry::DefaultClientObserver::DefaultClientObserver( - ProtocolHandlerRegistry* registry) - : worker_(NULL), registry_(registry) { - DCHECK(registry_); +void ProtocolHandlerRegistry::RegisterProtocolHandler( + const ProtocolHandler& handler) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(CanSchemeBeOverridden(handler.protocol())); + DCHECK(!handler.IsEmpty()); + if (IsRegistered(handler)) { + return; + } + if (enabled_ && !delegate_->IsExternalHandlerRegistered(handler.protocol())) + delegate_->RegisterExternalHandler(handler.protocol()); + InsertHandler(handler); } -ProtocolHandlerRegistry::DefaultClientObserver::~DefaultClientObserver() { - if (worker_) { - worker_->ObserverDestroyed(); - }; - DefaultClientObserverList::iterator iter = std::find( - registry_->default_client_observers_.begin(), - registry_->default_client_observers_.end(), this); - registry_->default_client_observers_.erase(iter); -} +std::vector<const DictionaryValue*> +ProtocolHandlerRegistry::GetHandlersFromPref(const char* pref_name) const { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + std::vector<const DictionaryValue*> result; + PrefService* prefs = profile_->GetPrefs(); + if (!prefs->HasPrefPath(pref_name)) { + return result; + } -void -ProtocolHandlerRegistry::DefaultClientObserver::SetDefaultWebClientUIState( - ShellIntegration::DefaultWebClientUIState state) { - if (worker_) { - if (ShouldRemoveHandlersNotInOS() && - (state == ShellIntegration::STATE_NOT_DEFAULT)) { - registry_->ClearDefault(worker_->protocol()); + const ListValue* handlers = prefs->GetList(pref_name); + if (handlers) { + for (size_t i = 0; i < handlers->GetSize(); ++i) { + DictionaryValue* dict; + if (!handlers->GetDictionary(i, &dict)) + continue; + if (ProtocolHandler::IsValidDict(dict)) { + result.push_back(dict); + } } - } else { - NOTREACHED(); } + return result; } -void ProtocolHandlerRegistry::DefaultClientObserver::SetWorker( - ShellIntegration::DefaultProtocolClientWorker* worker) { - worker_ = worker; +void ProtocolHandlerRegistry::IgnoreProtocolHandler( + const ProtocolHandler& handler) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + ignored_protocol_handlers_.push_back(handler); } diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.h b/chrome/browser/custom_handlers/protocol_handler_registry.h index edfb7ab..508a44c 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry.h +++ b/chrome/browser/custom_handlers/protocol_handler_registry.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,6 +12,7 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" +#include "base/sequenced_task_runner_helpers.h" #include "base/values.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/shell_integration.h" @@ -84,7 +85,6 @@ class ProtocolHandlerRegistry typedef std::vector<DefaultClientObserver*> DefaultClientObserverList; ProtocolHandlerRegistry(Profile* profile, Delegate* delegate); - ~ProtocolHandlerRegistry(); // Called when a site tries to register as a protocol handler. If the request // can be handled silently by the registry - either to ignore the request @@ -192,7 +192,13 @@ class ProtocolHandlerRegistry bool enabled() const { return enabled_; } private: - friend class base::RefCountedThreadSafe<ProtocolHandlerRegistry>; + friend class base::DeleteHelper<ProtocolHandlerRegistry>; + friend struct content::BrowserThread::DeleteOnThread< + content::BrowserThread::IO>; + friend class ProtocolHandlerRegistryTest; + friend class RegisterProtocolHandlerBrowserTest; + + ~ProtocolHandlerRegistry(); // Puts the given handler at the top of the list of handlers for its // protocol. @@ -249,9 +255,6 @@ class ProtocolHandlerRegistry // Ignores future requests to register the given protocol handler. void IgnoreProtocolHandler(const ProtocolHandler& handler); - // Register - void IgnoreHandlerFromValue(const DictionaryValue* value); - // Map from protocols (strings) to protocol handlers. ProtocolHandlerMultiMap protocol_handlers_; @@ -282,9 +285,6 @@ class ProtocolHandlerRegistry // Copy of default_handlers_ that is only accessed on the IO thread. ProtocolHandlerMap default_handlers_io_; - friend class ProtocolHandlerRegistryTest; - friend class RegisterProtocolHandlerBrowserTest; - DISALLOW_COPY_AND_ASSIGN(ProtocolHandlerRegistry); }; #endif // CHROME_BROWSER_CUSTOM_HANDLERS_PROTOCOL_HANDLER_REGISTRY_H_ diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc index 67820c4..f5afb11 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc @@ -117,6 +117,8 @@ class FakeProtocolClientWorker force_failure_(force_failure) {} private: + virtual ~FakeProtocolClientWorker() {} + virtual ShellIntegration::DefaultWebClientState CheckIsDefault() { if (force_failure_) { return ShellIntegration::NOT_DEFAULT_WEB_CLIENT; diff --git a/chrome/browser/debugger/devtools_sanity_unittest.cc b/chrome/browser/debugger/devtools_sanity_unittest.cc index 784d418..9d6e10d 100644 --- a/chrome/browser/debugger/devtools_sanity_unittest.cc +++ b/chrome/browser/debugger/devtools_sanity_unittest.cc @@ -276,10 +276,15 @@ class WorkerDevToolsSanityTest : public InProcessBrowserTest { } protected: - struct WorkerData : public base::RefCountedThreadSafe<WorkerData> { + class WorkerData : public base::RefCountedThreadSafe<WorkerData> { + public: WorkerData() : worker_process_id(0), worker_route_id(0) {} int worker_process_id; int worker_route_id; + + private: + friend class base::RefCountedThreadSafe<WorkerData>; + ~WorkerData() {} }; class WorkerCreationObserver : public WorkerServiceObserver { diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc index adb38f9..05b48d6 100644 --- a/chrome/browser/download/download_browsertest.cc +++ b/chrome/browser/download/download_browsertest.cc @@ -93,6 +93,9 @@ class PickSuggestedFileDelegate : public ChromeDownloadManagerDelegate { if (download_manager_) download_manager_->FileSelected(suggested_path, download_id); } + + protected: + virtual ~PickSuggestedFileDelegate() {} }; // Get History Information. diff --git a/chrome/browser/download/download_extension_api.h b/chrome/browser/download/download_extension_api.h index b024664..8eba05e 100644 --- a/chrome/browser/download/download_extension_api.h +++ b/chrome/browser/download/download_extension_api.h @@ -83,12 +83,14 @@ class DownloadsFunctionInterface { class SyncDownloadsFunction : public SyncExtensionFunction, public DownloadsFunctionInterface { - public: - virtual bool RunImpl() OVERRIDE; - protected: explicit SyncDownloadsFunction(DownloadsFunctionName function); virtual ~SyncDownloadsFunction(); + + // ExtensionFunction: + virtual bool RunImpl() OVERRIDE; + + // DownloadsFunctionInterface: virtual DownloadsFunctionName function() const OVERRIDE; private: @@ -99,12 +101,14 @@ class SyncDownloadsFunction : public SyncExtensionFunction, class AsyncDownloadsFunction : public AsyncExtensionFunction, public DownloadsFunctionInterface { - public: - virtual bool RunImpl() OVERRIDE; - protected: explicit AsyncDownloadsFunction(DownloadsFunctionName function); virtual ~AsyncDownloadsFunction(); + + // ExtensionFunction: + virtual bool RunImpl() OVERRIDE; + + // DownloadsFunctionInterface: virtual DownloadsFunctionName function() const OVERRIDE; private: @@ -115,11 +119,14 @@ class AsyncDownloadsFunction : public AsyncExtensionFunction, class DownloadsDownloadFunction : public AsyncDownloadsFunction { public: - DownloadsDownloadFunction(); - virtual ~DownloadsDownloadFunction(); DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.download"); + DownloadsDownloadFunction(); + protected: + virtual ~DownloadsDownloadFunction(); + + // DownloadsFunctionInterface: virtual bool ParseArgs() OVERRIDE; virtual bool RunInternal() OVERRIDE; @@ -140,6 +147,7 @@ class DownloadsDownloadFunction : public AsyncDownloadsFunction { int render_process_host_id; int render_view_host_routing_id; }; + void BeginDownloadOnIOThread(); void OnStarted(content::DownloadId dl_id, net::Error error); @@ -150,11 +158,14 @@ class DownloadsDownloadFunction : public AsyncDownloadsFunction { class DownloadsSearchFunction : public SyncDownloadsFunction { public: - DownloadsSearchFunction(); - virtual ~DownloadsSearchFunction(); DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.search"); + DownloadsSearchFunction(); + protected: + virtual ~DownloadsSearchFunction(); + + // DownloadsFunctionInterface: virtual bool ParseArgs() OVERRIDE; virtual bool RunInternal() OVERRIDE; @@ -170,11 +181,14 @@ class DownloadsSearchFunction : public SyncDownloadsFunction { class DownloadsPauseFunction : public SyncDownloadsFunction { public: - DownloadsPauseFunction(); - virtual ~DownloadsPauseFunction(); DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.pause"); + DownloadsPauseFunction(); + protected: + virtual ~DownloadsPauseFunction(); + + // DownloadsFunctionInterface: virtual bool ParseArgs() OVERRIDE; virtual bool RunInternal() OVERRIDE; @@ -185,11 +199,14 @@ class DownloadsPauseFunction : public SyncDownloadsFunction { class DownloadsResumeFunction : public SyncDownloadsFunction { public: - DownloadsResumeFunction(); - virtual ~DownloadsResumeFunction(); DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.resume"); + DownloadsResumeFunction(); + protected: + virtual ~DownloadsResumeFunction(); + + // DownloadsFunctionInterface: virtual bool ParseArgs() OVERRIDE; virtual bool RunInternal() OVERRIDE; @@ -200,11 +217,14 @@ class DownloadsResumeFunction : public SyncDownloadsFunction { class DownloadsCancelFunction : public SyncDownloadsFunction { public: - DownloadsCancelFunction(); - virtual ~DownloadsCancelFunction(); DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.cancel"); + DownloadsCancelFunction(); + protected: + virtual ~DownloadsCancelFunction(); + + // DownloadsFunctionInterface: virtual bool ParseArgs() OVERRIDE; virtual bool RunInternal() OVERRIDE; @@ -215,11 +235,14 @@ class DownloadsCancelFunction : public SyncDownloadsFunction { class DownloadsEraseFunction : public AsyncDownloadsFunction { public: - DownloadsEraseFunction(); - virtual ~DownloadsEraseFunction(); DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.erase"); + DownloadsEraseFunction(); + protected: + virtual ~DownloadsEraseFunction(); + + // DownloadsFunctionInterface: virtual bool ParseArgs() OVERRIDE; virtual bool RunInternal() OVERRIDE; @@ -229,11 +252,14 @@ class DownloadsEraseFunction : public AsyncDownloadsFunction { class DownloadsSetDestinationFunction : public AsyncDownloadsFunction { public: - DownloadsSetDestinationFunction(); - virtual ~DownloadsSetDestinationFunction(); DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.setDestination"); + DownloadsSetDestinationFunction(); + protected: + virtual ~DownloadsSetDestinationFunction(); + + // DownloadsFunctionInterface: virtual bool ParseArgs() OVERRIDE; virtual bool RunInternal() OVERRIDE; @@ -243,11 +269,14 @@ class DownloadsSetDestinationFunction : public AsyncDownloadsFunction { class DownloadsAcceptDangerFunction : public AsyncDownloadsFunction { public: - DownloadsAcceptDangerFunction(); - virtual ~DownloadsAcceptDangerFunction(); DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.acceptDanger"); + DownloadsAcceptDangerFunction(); + protected: + virtual ~DownloadsAcceptDangerFunction(); + + // DownloadsFunctionInterface: virtual bool ParseArgs() OVERRIDE; virtual bool RunInternal() OVERRIDE; @@ -257,11 +286,14 @@ class DownloadsAcceptDangerFunction : public AsyncDownloadsFunction { class DownloadsShowFunction : public AsyncDownloadsFunction { public: - DownloadsShowFunction(); - virtual ~DownloadsShowFunction(); DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.show"); + DownloadsShowFunction(); + protected: + virtual ~DownloadsShowFunction(); + + // DownloadsFunctionInterface: virtual bool ParseArgs() OVERRIDE; virtual bool RunInternal() OVERRIDE; @@ -271,11 +303,14 @@ class DownloadsShowFunction : public AsyncDownloadsFunction { class DownloadsDragFunction : public AsyncDownloadsFunction { public: - DownloadsDragFunction(); - virtual ~DownloadsDragFunction(); DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.drag"); + DownloadsDragFunction(); + protected: + virtual ~DownloadsDragFunction(); + + // DownloadsFunctionInterface: virtual bool ParseArgs() OVERRIDE; virtual bool RunInternal() OVERRIDE; @@ -285,12 +320,15 @@ class DownloadsDragFunction : public AsyncDownloadsFunction { class DownloadsGetFileIconFunction : public AsyncDownloadsFunction { public: + DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.getFileIcon"); + DownloadsGetFileIconFunction(); - virtual ~DownloadsGetFileIconFunction(); void SetIconExtractorForTesting(DownloadFileIconExtractor* extractor); - DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.getFileIcon"); protected: + virtual ~DownloadsGetFileIconFunction(); + + // DownloadsFunctionInterface: virtual bool ParseArgs() OVERRIDE; virtual bool RunInternal() OVERRIDE; diff --git a/chrome/browser/external_protocol/external_protocol_handler_unittest.cc b/chrome/browser/external_protocol/external_protocol_handler_unittest.cc index 14ced2f..167c1e0 100644 --- a/chrome/browser/external_protocol/external_protocol_handler_unittest.cc +++ b/chrome/browser/external_protocol/external_protocol_handler_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,6 +21,8 @@ class FakeExternalProtocolHandlerWorker os_state_(os_state) {} private: + virtual ~FakeExternalProtocolHandlerWorker() {} + virtual ShellIntegration::DefaultWebClientState CheckIsDefault() { return os_state_; } diff --git a/chrome/browser/geolocation/chrome_access_token_store.cc b/chrome/browser/geolocation/chrome_access_token_store.cc index 7827e3d..23297bc 100644 --- a/chrome/browser/geolocation/chrome_access_token_store.cc +++ b/chrome/browser/geolocation/chrome_access_token_store.cc @@ -43,6 +43,10 @@ class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> { } private: + friend class base::RefCountedThreadSafe<TokenLoadingJob>; + + ~TokenLoadingJob() {} + void PerformWorkOnUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DictionaryPrefUpdate update(g_browser_process->local_state(), @@ -87,11 +91,7 @@ void ChromeAccessTokenStore::RegisterPrefs(PrefService* prefs) { prefs->RegisterDictionaryPref(prefs::kGeolocationAccessToken); } -ChromeAccessTokenStore::ChromeAccessTokenStore() { -} - -ChromeAccessTokenStore::~ChromeAccessTokenStore() { -} +ChromeAccessTokenStore::ChromeAccessTokenStore() {} void ChromeAccessTokenStore::LoadAccessTokens( const LoadAccessTokensCallbackType& callback) { @@ -99,7 +99,10 @@ void ChromeAccessTokenStore::LoadAccessTokens( job->Run(); } -void SetAccessTokenOnUIThread(const GURL& server_url, const string16& token) { +ChromeAccessTokenStore::~ChromeAccessTokenStore() {} + +static void SetAccessTokenOnUIThread(const GURL& server_url, + const string16& token) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DictionaryPrefUpdate update(g_browser_process->local_state(), prefs::kGeolocationAccessToken); diff --git a/chrome/browser/geolocation/chrome_access_token_store.h b/chrome/browser/geolocation/chrome_access_token_store.h index dacd0ec..c6f140c 100644 --- a/chrome/browser/geolocation/chrome_access_token_store.h +++ b/chrome/browser/geolocation/chrome_access_token_store.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,12 +17,13 @@ class ChromeAccessTokenStore : public content::AccessTokenStore { static void RegisterPrefs(PrefService* prefs); ChromeAccessTokenStore(); - virtual ~ChromeAccessTokenStore(); virtual void LoadAccessTokens( const LoadAccessTokensCallbackType& request) OVERRIDE; private: + virtual ~ChromeAccessTokenStore(); + // AccessTokenStore virtual void SaveAccessToken( const GURL& server_url, const string16& access_token) OVERRIDE; diff --git a/chrome/browser/importer/external_process_importer_client.cc b/chrome/browser/importer/external_process_importer_client.cc index dbc25cf..e66b6e05 100644 --- a/chrome/browser/importer/external_process_importer_client.cc +++ b/chrome/browser/importer/external_process_importer_client.cc @@ -38,29 +38,6 @@ ExternalProcessImporterClient::ExternalProcessImporterClient( process_importer_host_->NotifyImportStarted(); } -ExternalProcessImporterClient::~ExternalProcessImporterClient() { -} - -void ExternalProcessImporterClient::CancelImportProcessOnIOThread() { - if (utility_process_host_) - utility_process_host_->Send(new ProfileImportProcessMsg_CancelImport()); -} - -void ExternalProcessImporterClient::NotifyItemFinishedOnIOThread( - importer::ImportItem import_item) { - utility_process_host_->Send( - new ProfileImportProcessMsg_ReportImportItemFinished(import_item)); -} - -void ExternalProcessImporterClient::Cleanup() { - if (cancelled_) - return; - - if (process_importer_host_) - process_importer_host_->NotifyImportEnded(); - Release(); -} - void ExternalProcessImporterClient::Start() { AddRef(); // balanced in Cleanup. BrowserThread::ID thread_id; @@ -72,46 +49,6 @@ void ExternalProcessImporterClient::Start() { thread_id)); } -void ExternalProcessImporterClient::StartProcessOnIOThread( - BrowserThread::ID thread_id) { - utility_process_host_ = - UtilityProcessHost::Create(this, thread_id)->AsWeakPtr(); - utility_process_host_->DisableSandbox(); - -#if defined(OS_MACOSX) - base::EnvironmentVector env; - std::string dylib_path = GetFirefoxDylibPath().value(); - if (!dylib_path.empty()) - env.push_back(std::make_pair("DYLD_FALLBACK_LIBRARY_PATH", dylib_path)); - utility_process_host_->SetEnv(env); -#endif - - // Dictionary of all localized strings that could be needed by the importer - // in the external process. - DictionaryValue localized_strings; - localized_strings.SetString( - base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX), - l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX)); - localized_strings.SetString( - base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI), - l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI)); - localized_strings.SetString( - base::IntToString(IDS_IMPORT_FROM_FIREFOX), - l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX)); - localized_strings.SetString( - base::IntToString(IDS_IMPORT_FROM_GOOGLE_TOOLBAR), - l10n_util::GetStringUTF8(IDS_IMPORT_FROM_GOOGLE_TOOLBAR)); - localized_strings.SetString( - base::IntToString(IDS_IMPORT_FROM_SAFARI), - l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI)); - localized_strings.SetString( - base::IntToString(IDS_BOOKMARK_BAR_FOLDER_NAME), - l10n_util::GetStringUTF8(IDS_BOOKMARK_BAR_FOLDER_NAME)); - - utility_process_host_->Send(new ProfileImportProcessMsg_StartImport( - source_profile_, items_, localized_strings)); -} - void ExternalProcessImporterClient::Cancel() { if (cancelled_) return; @@ -298,3 +235,65 @@ void ExternalProcessImporterClient::OnKeywordsImportReady( bridge_->SetKeywords(template_urls, unique_on_host_and_path); // The pointers in |template_urls| have now been deleted. } + +ExternalProcessImporterClient::~ExternalProcessImporterClient() {} + +void ExternalProcessImporterClient::Cleanup() { + if (cancelled_) + return; + + if (process_importer_host_) + process_importer_host_->NotifyImportEnded(); + Release(); +} + +void ExternalProcessImporterClient::CancelImportProcessOnIOThread() { + if (utility_process_host_) + utility_process_host_->Send(new ProfileImportProcessMsg_CancelImport()); +} + +void ExternalProcessImporterClient::NotifyItemFinishedOnIOThread( + importer::ImportItem import_item) { + utility_process_host_->Send( + new ProfileImportProcessMsg_ReportImportItemFinished(import_item)); +} + +void ExternalProcessImporterClient::StartProcessOnIOThread( + BrowserThread::ID thread_id) { + utility_process_host_ = + UtilityProcessHost::Create(this, thread_id)->AsWeakPtr(); + utility_process_host_->DisableSandbox(); + +#if defined(OS_MACOSX) + base::EnvironmentVector env; + std::string dylib_path = GetFirefoxDylibPath().value(); + if (!dylib_path.empty()) + env.push_back(std::make_pair("DYLD_FALLBACK_LIBRARY_PATH", dylib_path)); + utility_process_host_->SetEnv(env); +#endif + + // Dictionary of all localized strings that could be needed by the importer + // in the external process. + DictionaryValue localized_strings; + localized_strings.SetString( + base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX), + l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX)); + localized_strings.SetString( + base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI), + l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI)); + localized_strings.SetString( + base::IntToString(IDS_IMPORT_FROM_FIREFOX), + l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX)); + localized_strings.SetString( + base::IntToString(IDS_IMPORT_FROM_GOOGLE_TOOLBAR), + l10n_util::GetStringUTF8(IDS_IMPORT_FROM_GOOGLE_TOOLBAR)); + localized_strings.SetString( + base::IntToString(IDS_IMPORT_FROM_SAFARI), + l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI)); + localized_strings.SetString( + base::IntToString(IDS_BOOKMARK_BAR_FOLDER_NAME), + l10n_util::GetStringUTF8(IDS_BOOKMARK_BAR_FOLDER_NAME)); + + utility_process_host_->Send(new ProfileImportProcessMsg_StartImport( + source_profile_, items_, localized_strings)); +} diff --git a/chrome/browser/importer/external_process_importer_client.h b/chrome/browser/importer/external_process_importer_client.h index 1394588..ae13b81 100644 --- a/chrome/browser/importer/external_process_importer_client.h +++ b/chrome/browser/importer/external_process_importer_client.h @@ -39,7 +39,6 @@ class ExternalProcessImporterClient : public content::UtilityProcessHostClient { const importer::SourceProfile& source_profile, uint16 items, InProcessImporterBridge* bridge); - virtual ~ExternalProcessImporterClient(); // Launches the task to start the external process. void Start(); @@ -73,6 +72,9 @@ class ExternalProcessImporterClient : public content::UtilityProcessHostClient { void OnKeywordsImportReady(const std::vector<TemplateURL*>& template_urls, bool unique_on_host_and_path); + protected: + virtual ~ExternalProcessImporterClient(); + private: // Notifies the importerhost that import has finished, and calls Release(). void Cleanup(); diff --git a/chrome/browser/importer/external_process_importer_host.cc b/chrome/browser/importer/external_process_importer_host.cc index 4115189..d0397c2 100644 --- a/chrome/browser/importer/external_process_importer_host.cc +++ b/chrome/browser/importer/external_process_importer_host.cc @@ -23,6 +23,8 @@ void ExternalProcessImporterHost::Cancel() { NotifyImportEnded(); // Tells the observer that we're done, and releases us. } +ExternalProcessImporterHost::~ExternalProcessImporterHost() {} + void ExternalProcessImporterHost::StartImportSettings( const importer::SourceProfile& source_profile, Profile* target_profile, diff --git a/chrome/browser/importer/external_process_importer_host.h b/chrome/browser/importer/external_process_importer_host.h index c32ed7a..1b8be85 100644 --- a/chrome/browser/importer/external_process_importer_host.h +++ b/chrome/browser/importer/external_process_importer_host.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -27,6 +27,9 @@ class ExternalProcessImporterHost : public ImporterHost { // ImporterHost: virtual void Cancel() OVERRIDE; + protected: + virtual ~ExternalProcessImporterHost(); + private: // ImporterHost: virtual void StartImportSettings( diff --git a/chrome/browser/importer/firefox_importer_unittest_utils_mac.cc b/chrome/browser/importer/firefox_importer_unittest_utils_mac.cc index afe78e5..d609cc9 100644 --- a/chrome/browser/importer/firefox_importer_unittest_utils_mac.cc +++ b/chrome/browser/importer/firefox_importer_unittest_utils_mac.cc @@ -166,6 +166,10 @@ class CancellableQuitMsgLoop : public base::RefCounted<CancellableQuitMsgLoop> { MessageLoop::current()->Quit(); } bool cancelled_; + + private: + friend class base::RefCounted<CancellableQuitMsgLoop>; + ~CancellableQuitMsgLoop() {} }; // Spin until either a client response arrives or a timeout occurs. diff --git a/chrome/browser/intranet_redirect_detector.h b/chrome/browser/intranet_redirect_detector.h index 8af31c7..0f59d99 100644 --- a/chrome/browser/intranet_redirect_detector.h +++ b/chrome/browser/intranet_redirect_detector.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -94,6 +94,9 @@ class IntranetRedirectHostResolverProc : public net::HostResolverProc { net::HostResolverFlags host_resolver_flags, net::AddressList* addrlist, int* os_error) OVERRIDE; + + private: + virtual ~IntranetRedirectHostResolverProc() {} }; #endif // CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 73fbaa0..177fb74 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -79,6 +79,9 @@ class URLRequestContextWithUserAgent : public net::URLRequestContext { const GURL& url) const OVERRIDE { return content::GetUserAgent(url); } + + protected: + virtual ~URLRequestContextWithUserAgent() {} }; // Used for the "system" URLRequestContext. If this grows more complicated, then diff --git a/chrome/browser/memory_purger.cc b/chrome/browser/memory_purger.cc index 7c2fd9e..6e2c14f 100644 --- a/chrome/browser/memory_purger.cc +++ b/chrome/browser/memory_purger.cc @@ -46,9 +46,13 @@ class PurgeMemoryIOHelper void PurgeMemoryOnIOThread(); private: - typedef scoped_refptr<net::URLRequestContextGetter> RequestContextGetter; + friend class base::RefCountedThreadSafe<PurgeMemoryIOHelper>; + + virtual ~PurgeMemoryIOHelper() {} + typedef scoped_refptr<net::URLRequestContextGetter> RequestContextGetter; std::vector<RequestContextGetter> request_context_getters_; + scoped_refptr<SafeBrowsingService> safe_browsing_service_; DISALLOW_COPY_AND_ASSIGN(PurgeMemoryIOHelper); diff --git a/chrome/browser/metrics/field_trial_synchronizer.cc b/chrome/browser/metrics/field_trial_synchronizer.cc index a6ad4c5..b483359 100644 --- a/chrome/browser/metrics/field_trial_synchronizer.cc +++ b/chrome/browser/metrics/field_trial_synchronizer.cc @@ -15,19 +15,24 @@ using content::BrowserThread; +namespace { + +// This singleton instance should be constructed during the single threaded +// portion of main(). It initializes globals to provide support for all future +// calls. This object is created on the UI thread, and it is destroyed after +// all the other threads have gone away. +FieldTrialSynchronizer* g_field_trial_synchronizer = NULL; + +} // namespace + FieldTrialSynchronizer::FieldTrialSynchronizer() { - DCHECK(field_trial_synchronizer_ == NULL); - field_trial_synchronizer_ = this; + DCHECK(g_field_trial_synchronizer == NULL); + g_field_trial_synchronizer = this; base::FieldTrialList::AddObserver(this); experiments_helper::SetChildProcessLoggingExperimentList(); } -FieldTrialSynchronizer::~FieldTrialSynchronizer() { - base::FieldTrialList::RemoveObserver(this); - field_trial_synchronizer_ = NULL; -} - void FieldTrialSynchronizer::NotifyAllRenderers( const std::string& field_trial_name, const std::string& group_name) { @@ -55,6 +60,7 @@ void FieldTrialSynchronizer::OnFieldTrialGroupFinalized( experiments_helper::SetChildProcessLoggingExperimentList(); } -// static -FieldTrialSynchronizer* - FieldTrialSynchronizer::field_trial_synchronizer_ = NULL; +FieldTrialSynchronizer::~FieldTrialSynchronizer() { + base::FieldTrialList::RemoveObserver(this); + g_field_trial_synchronizer = NULL; +} diff --git a/chrome/browser/metrics/field_trial_synchronizer.h b/chrome/browser/metrics/field_trial_synchronizer.h index 00d5b80..7a2e366 100644 --- a/chrome/browser/metrics/field_trial_synchronizer.h +++ b/chrome/browser/metrics/field_trial_synchronizer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -35,8 +35,6 @@ class FieldTrialSynchronizer // is finalized in the browser process. FieldTrialSynchronizer(); - virtual ~FieldTrialSynchronizer(); - // Notify all renderer processes about the |group_name| that is finalized for // the given field trail (|field_trial_name|). This is called on UI thread. void NotifyAllRenderers(const std::string& field_trial_name, @@ -53,11 +51,8 @@ class FieldTrialSynchronizer const std::string& group_name) OVERRIDE; private: - // This singleton instance should be constructed during the single threaded - // portion of main(). It initializes globals to provide support for all future - // calls. This object is created on the UI thread, and it is destroyed after - // all the other threads have gone away. - static FieldTrialSynchronizer* field_trial_synchronizer_; + friend class base::RefCountedThreadSafe<FieldTrialSynchronizer>; + virtual ~FieldTrialSynchronizer(); DISALLOW_COPY_AND_ASSIGN(FieldTrialSynchronizer); }; diff --git a/chrome/browser/notifications/notification_test_util.cc b/chrome/browser/notifications/notification_test_util.cc index 540e296..1803c67 100644 --- a/chrome/browser/notifications/notification_test_util.cc +++ b/chrome/browser/notifications/notification_test_util.cc @@ -1,11 +1,12 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/notifications/notification_test_util.h" MockNotificationDelegate::MockNotificationDelegate(const std::string& id) - : id_(id) {} + : id_(id) { +} MockNotificationDelegate::~MockNotificationDelegate() {} diff --git a/chrome/browser/notifications/notification_test_util.h b/chrome/browser/notifications/notification_test_util.h index 9b6dd34..7ea3ac7 100644 --- a/chrome/browser/notifications/notification_test_util.h +++ b/chrome/browser/notifications/notification_test_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,7 +17,6 @@ class MockNotificationDelegate : public NotificationDelegate { public: explicit MockNotificationDelegate(const std::string& id); - virtual ~MockNotificationDelegate(); // NotificationDelegate interface. virtual void Display() OVERRIDE {} @@ -27,6 +26,8 @@ class MockNotificationDelegate : public NotificationDelegate { virtual std::string id() const OVERRIDE; private: + virtual ~MockNotificationDelegate(); + std::string id_; DISALLOW_COPY_AND_ASSIGN(MockNotificationDelegate); diff --git a/chrome/browser/pepper_gtalk_message_filter.cc b/chrome/browser/pepper_gtalk_message_filter.cc index cd18f55..f60f7d4 100644 --- a/chrome/browser/pepper_gtalk_message_filter.cc +++ b/chrome/browser/pepper_gtalk_message_filter.cc @@ -17,10 +17,7 @@ #include "ui/aura/window.h" #endif -PepperGtalkMessageFilter::PepperGtalkMessageFilter() { -} - -PepperGtalkMessageFilter::~PepperGtalkMessageFilter() {} +PepperGtalkMessageFilter::PepperGtalkMessageFilter() {} void PepperGtalkMessageFilter::OverrideThreadForMessage( const IPC::Message& message, @@ -40,6 +37,8 @@ bool PepperGtalkMessageFilter::OnMessageReceived(const IPC::Message& msg, return handled; } +PepperGtalkMessageFilter::~PepperGtalkMessageFilter() {} + void PepperGtalkMessageFilter::OnTalkGetPermission(uint32 plugin_dispatcher_id, PP_Resource resource) { diff --git a/chrome/browser/pepper_gtalk_message_filter.h b/chrome/browser/pepper_gtalk_message_filter.h index 8aa8de5..4f2d9fa 100644 --- a/chrome/browser/pepper_gtalk_message_filter.h +++ b/chrome/browser/pepper_gtalk_message_filter.h @@ -13,7 +13,6 @@ class PepperGtalkMessageFilter : public content::BrowserMessageFilter { public: PepperGtalkMessageFilter(); - virtual ~PepperGtalkMessageFilter(); // content::BrowserMessageFilter methods. virtual void OverrideThreadForMessage( @@ -23,6 +22,8 @@ class PepperGtalkMessageFilter : public content::BrowserMessageFilter { bool* message_was_ok) OVERRIDE; private: + virtual ~PepperGtalkMessageFilter(); + void OnTalkGetPermission(uint32 plugin_dispatcher_id, PP_Resource resource); diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc index 0b86363..7e1edf9 100644 --- a/chrome/browser/prerender/prerender_browsertest.cc +++ b/chrome/browser/prerender/prerender_browsertest.cc @@ -386,8 +386,6 @@ class FakeSafeBrowsingService : public SafeBrowsingService { FakeSafeBrowsingService() : result_(SAFE) {} - virtual ~FakeSafeBrowsingService() {} - // Called on the IO thread to check if the given url is safe or not. If we // can synchronously determine that the url is safe, CheckUrl returns true. // Otherwise it returns false, and "client" is called asynchronously with the @@ -414,6 +412,8 @@ class FakeSafeBrowsingService : public SafeBrowsingService { } private: + virtual ~FakeSafeBrowsingService() {} + void OnCheckBrowseURLDone(const GURL& gurl, Client* client) { SafeBrowsingService::SafeBrowsingCheck check; check.urls.push_back(gurl); diff --git a/chrome/browser/renderer_host/plugin_info_message_filter.cc b/chrome/browser/renderer_host/plugin_info_message_filter.cc index 379941c..5cc5178 100644 --- a/chrome/browser/renderer_host/plugin_info_message_filter.cc +++ b/chrome/browser/renderer_host/plugin_info_message_filter.cc @@ -57,8 +57,6 @@ PluginInfoMessageFilter::PluginInfoMessageFilter( weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } -PluginInfoMessageFilter::~PluginInfoMessageFilter() {} - bool PluginInfoMessageFilter::OnMessageReceived(const IPC::Message& message, bool* message_was_ok) { IPC_BEGIN_MESSAGE_MAP_EX(PluginInfoMessageFilter, message, *message_was_ok) @@ -79,6 +77,8 @@ void PluginInfoMessageFilter::OnDestruct() const { content::BrowserThread::DeleteOnUIThread::Destruct(this); } +PluginInfoMessageFilter::~PluginInfoMessageFilter() {} + struct PluginInfoMessageFilter::GetPluginInfo_Params { int render_view_id; GURL url; diff --git a/chrome/browser/renderer_host/plugin_info_message_filter.h b/chrome/browser/renderer_host/plugin_info_message_filter.h index f0f6e35..c7a6ff7 100644 --- a/chrome/browser/renderer_host/plugin_info_message_filter.h +++ b/chrome/browser/renderer_host/plugin_info_message_filter.h @@ -11,6 +11,7 @@ #include "base/compiler_specific.h" #include "base/memory/weak_ptr.h" +#include "base/sequenced_task_runner_helpers.h" #include "chrome/browser/prefs/pref_member.h" #include "chrome/common/content_settings.h" #include "content/public/browser/browser_message_filter.h" @@ -74,7 +75,6 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter { }; PluginInfoMessageFilter(int render_process_id, Profile* profile); - virtual ~PluginInfoMessageFilter(); // content::BrowserMessageFilter methods: virtual bool OnMessageReceived(const IPC::Message& message, @@ -82,6 +82,12 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter { virtual void OnDestruct() const OVERRIDE; private: + friend struct content::BrowserThread::DeleteOnThread< + content::BrowserThread::UI>; + friend class base::DeleteHelper<PluginInfoMessageFilter>; + + virtual ~PluginInfoMessageFilter(); + void OnGetPluginInfo(int render_view_id, const GURL& url, const GURL& top_origin_url, diff --git a/chrome/browser/rlz/rlz_extension_api.h b/chrome/browser/rlz/rlz_extension_api.h index 15c5835..6419951 100644 --- a/chrome/browser/rlz/rlz_extension_api.h +++ b/chrome/browser/rlz/rlz_extension_api.h @@ -15,23 +15,38 @@ #include "rlz/lib/lib_values.h" class RlzRecordProductEventFunction : public SyncExtensionFunction { - virtual bool RunImpl() OVERRIDE; + public: DECLARE_EXTENSION_FUNCTION_NAME("experimental.rlz.recordProductEvent") + + protected: + virtual ~RlzRecordProductEventFunction() {} + + // ExtensionFunction: + virtual bool RunImpl() OVERRIDE; }; class RlzGetAccessPointRlzFunction : public SyncExtensionFunction { - virtual bool RunImpl() OVERRIDE; + public: DECLARE_EXTENSION_FUNCTION_NAME("experimental.rlz.getAccessPointRlz") + + protected: + virtual ~RlzGetAccessPointRlzFunction() {} + + // ExtensionFunction: + virtual bool RunImpl() OVERRIDE; }; class RlzSendFinancialPingFunction : public AsyncExtensionFunction { public: + DECLARE_EXTENSION_FUNCTION_NAME("experimental.rlz.sendFinancialPing") + RlzSendFinancialPingFunction(); - virtual ~RlzSendFinancialPingFunction(); - DECLARE_EXTENSION_FUNCTION_NAME("experimental.rlz.sendFinancialPing") - // Making this function protected so that it can be overridden in tests. protected: + friend class MockRlzSendFinancialPingFunction; + virtual ~RlzSendFinancialPingFunction(); + + // ExtensionFunction: virtual bool RunImpl() OVERRIDE; private: @@ -48,8 +63,14 @@ class RlzSendFinancialPingFunction : public AsyncExtensionFunction { }; class RlzClearProductStateFunction : public SyncExtensionFunction { - virtual bool RunImpl() OVERRIDE; + public: DECLARE_EXTENSION_FUNCTION_NAME("experimental.rlz.clearProductState") + + protected: + virtual ~RlzClearProductStateFunction() {} + + // ExtensionFunction: + virtual bool RunImpl() OVERRIDE; }; #endif // defined(OS_WIN) || defined(OS_MACOSX) diff --git a/chrome/browser/rlz/rlz_extension_apitest.cc b/chrome/browser/rlz/rlz_extension_apitest.cc index 7a1810b..1679d90 100644 --- a/chrome/browser/rlz/rlz_extension_apitest.cc +++ b/chrome/browser/rlz/rlz_extension_apitest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,14 +19,19 @@ #endif class MockRlzSendFinancialPingFunction : public RlzSendFinancialPingFunction { - virtual bool RunImpl(); - - static int expected_count_; - public: static int expected_count() { return expected_count_; } + + protected: + virtual ~MockRlzSendFinancialPingFunction() {} + + // ExtensionFunction + virtual bool RunImpl() OVERRIDE; + + private: + static int expected_count_; }; int MockRlzSendFinancialPingFunction::expected_count_ = 0; diff --git a/chrome/browser/search_engines/search_provider_install_state_message_filter.cc b/chrome/browser/search_engines/search_provider_install_state_message_filter.cc index 25a8755..619382d 100644 --- a/chrome/browser/search_engines/search_provider_install_state_message_filter.cc +++ b/chrome/browser/search_engines/search_provider_install_state_message_filter.cc @@ -30,11 +30,6 @@ SearchProviderInstallStateMessageFilter:: DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); } -SearchProviderInstallStateMessageFilter:: -~SearchProviderInstallStateMessageFilter() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); -} - bool SearchProviderInstallStateMessageFilter::OnMessageReceived( const IPC::Message& message, bool* message_was_ok) { @@ -50,6 +45,11 @@ bool SearchProviderInstallStateMessageFilter::OnMessageReceived( return handled; } +SearchProviderInstallStateMessageFilter:: +~SearchProviderInstallStateMessageFilter() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); +} + search_provider::InstallState SearchProviderInstallStateMessageFilter::GetSearchProviderInstallState( const GURL& page_location, diff --git a/chrome/browser/search_engines/search_provider_install_state_message_filter.h b/chrome/browser/search_engines/search_provider_install_state_message_filter.h index f19aa9d..66e44b6 100644 --- a/chrome/browser/search_engines/search_provider_install_state_message_filter.h +++ b/chrome/browser/search_engines/search_provider_install_state_message_filter.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -20,13 +20,14 @@ class SearchProviderInstallStateMessageFilter // Unlike the other methods, the constructor is called on the UI thread. SearchProviderInstallStateMessageFilter(int render_process_id, Profile* profile); - virtual ~SearchProviderInstallStateMessageFilter(); // content::BrowserMessageFilter implementation. virtual bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok) OVERRIDE; private: + virtual ~SearchProviderInstallStateMessageFilter(); + // Figures out the install state for the search provider. search_provider::InstallState GetSearchProviderInstallState( const GURL& page_location, diff --git a/chrome/browser/ssl/ssl_client_auth_requestor_mock.cc b/chrome/browser/ssl/ssl_client_auth_requestor_mock.cc index bc9d17b..b179d11 100644 --- a/chrome/browser/ssl/ssl_client_auth_requestor_mock.cc +++ b/chrome/browser/ssl/ssl_client_auth_requestor_mock.cc @@ -16,5 +16,4 @@ SSLClientAuthRequestorMock::SSLClientAuthRequestorMock( request->context()->http_transaction_factory()->GetSession()) { } -SSLClientAuthRequestorMock::~SSLClientAuthRequestorMock() { -} +SSLClientAuthRequestorMock::~SSLClientAuthRequestorMock() {} diff --git a/chrome/browser/ssl/ssl_client_auth_requestor_mock.h b/chrome/browser/ssl/ssl_client_auth_requestor_mock.h index 05ee3d2..2f3eb12 100644 --- a/chrome/browser/ssl/ssl_client_auth_requestor_mock.h +++ b/chrome/browser/ssl/ssl_client_auth_requestor_mock.h @@ -22,13 +22,15 @@ class SSLClientAuthRequestorMock SSLClientAuthRequestorMock( net::URLRequest* request, net::SSLCertRequestInfo* cert_request_info); - // NOTE: we need a vtable or else gmock blows up. - virtual ~SSLClientAuthRequestorMock(); MOCK_METHOD1(CertificateSelected, void(net::X509Certificate* cert)); net::SSLCertRequestInfo* cert_request_info_; net::HttpNetworkSession* http_network_session_; + + protected: + friend class base::RefCountedThreadSafe<SSLClientAuthRequestorMock>; + virtual ~SSLClientAuthRequestorMock(); }; #endif // CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_REQUESTOR_MOCK_H_ diff --git a/chrome/browser/status_icons/desktop_notification_balloon.cc b/chrome/browser/status_icons/desktop_notification_balloon.cc index a0361d4..a03d2ff 100644 --- a/chrome/browser/status_icons/desktop_notification_balloon.cc +++ b/chrome/browser/status_icons/desktop_notification_balloon.cc @@ -32,7 +32,6 @@ class DummyNotificationDelegate : public NotificationDelegate { public: explicit DummyNotificationDelegate(const std::string& id) : id_(kNotificationPrefix + id) {} - virtual ~DummyNotificationDelegate() {} virtual void Display() OVERRIDE { MessageLoop::current()->PostDelayedTask( @@ -46,6 +45,8 @@ class DummyNotificationDelegate : public NotificationDelegate { virtual std::string id() const OVERRIDE { return id_; } private: + virtual ~DummyNotificationDelegate() {} + std::string id_; }; diff --git a/chrome/browser/user_style_sheet_watcher.cc b/chrome/browser/user_style_sheet_watcher.cc index 4f909c1..5f27d8f 100644 --- a/chrome/browser/user_style_sheet_watcher.cc +++ b/chrome/browser/user_style_sheet_watcher.cc @@ -47,7 +47,6 @@ const char kUserStyleSheetFile[] = "Custom.css"; class UserStyleSheetLoader : public FilePathWatcher::Delegate { public: UserStyleSheetLoader(); - virtual ~UserStyleSheetLoader() {} GURL user_style_sheet() const { return user_style_sheet_; @@ -64,6 +63,8 @@ class UserStyleSheetLoader : public FilePathWatcher::Delegate { virtual void OnFilePathChanged(const FilePath& path); private: + virtual ~UserStyleSheetLoader() {} + // Called on the UI thread after the stylesheet has loaded. void SetStyleSheet(const GURL& url); diff --git a/chrome/browser/webdata/web_data_service_unittest.cc b/chrome/browser/webdata/web_data_service_unittest.cc index 1c19008..4cb1927 100644 --- a/chrome/browser/webdata/web_data_service_unittest.cc +++ b/chrome/browser/webdata/web_data_service_unittest.cc @@ -57,6 +57,8 @@ ACTION_P(SignalEvent, event) { class AutofillDBThreadObserverHelper : public DBThreadObserverHelper { protected: + virtual ~AutofillDBThreadObserverHelper() {} + virtual void RegisterObservers() { registrar_.Add(&observer_, chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, |