diff options
author | ivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-20 11:02:30 +0000 |
---|---|---|
committer | ivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-20 11:02:30 +0000 |
commit | 69bb9e6e26fcd3e93edb969fb43672bf33b7834b (patch) | |
tree | 60c3475eb880a5db7816cbbb195088862e3af681 | |
parent | ef61b8cf677b8877d99f02a6f2c82c692c5dea77 (diff) | |
download | chromium_src-69bb9e6e26fcd3e93edb969fb43672bf33b7834b.zip chromium_src-69bb9e6e26fcd3e93edb969fb43672bf33b7834b.tar.gz chromium_src-69bb9e6e26fcd3e93edb969fb43672bf33b7834b.tar.bz2 |
Converted Protector into a ProfileKeyedService.
BUG=None
TEST=browser_tests:ProtectorServiceTest.*,DefaultSearchProviderChangeTest.*
Review URL: https://chromiumcodereview.appspot.com/9258001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118434 0039d316-1c4b-4281-b951-d872f2087c98
22 files changed, 459 insertions, 271 deletions
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index 1abb295..86d870c 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.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. @@ -43,7 +43,7 @@ #include "chrome/browser/profiles/profile_impl.h" #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/protector/protector.h" +#include "chrome/browser/protector/protector_service.h" #include "chrome/browser/renderer_host/web_cache_manager.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/browser/search_engines/template_url_prepopulate_data.h" diff --git a/chrome/browser/protector/base_setting_change.cc b/chrome/browser/protector/base_setting_change.cc index a622db0..3ee61d4 100644 --- a/chrome/browser/protector/base_setting_change.cc +++ b/chrome/browser/protector/base_setting_change.cc @@ -5,23 +5,19 @@ #include "chrome/browser/protector/base_setting_change.h" #include "base/logging.h" -#include "chrome/browser/protector/protector.h" namespace protector { BaseSettingChange::BaseSettingChange() - : profile_(NULL), - protector_(NULL) { + : profile_(NULL) { } BaseSettingChange::~BaseSettingChange() { } -bool BaseSettingChange::Init(Protector* protector) { - DCHECK(protector); - protector_ = protector; - profile_ = protector->profile(); - DCHECK(profile_); +bool BaseSettingChange::Init(Profile* profile) { + DCHECK(profile); + profile_ = profile; return true; } diff --git a/chrome/browser/protector/base_setting_change.h b/chrome/browser/protector/base_setting_change.h index 14d83bd..8601ca3 100644 --- a/chrome/browser/protector/base_setting_change.h +++ b/chrome/browser/protector/base_setting_change.h @@ -17,8 +17,6 @@ class TemplateURL; namespace protector { -class Protector; - // Base class for setting change tracked by Protector. class BaseSettingChange { public: @@ -28,9 +26,9 @@ class BaseSettingChange { // Applies initial actions to the setting if needed. Must be called before // any other calls are made, including text getters. // Returns true if initialization was successful. - // Associates this change with |protector_| instance so overrides must - // call the base method. - virtual bool Init(Protector* protector); + // Associates this change with |profile| instance so overrides must call the + // base method. + virtual bool Init(Profile* profile); // Persists new setting if needed. virtual void Apply(); @@ -63,15 +61,12 @@ class BaseSettingChange { // Returns text for the button to discard the change with |Discard|. virtual string16 GetDiscardButtonText() const = 0; + protected: // Profile instance we've been associated with by an |Init| call. Profile* profile() { return profile_; } - // Protector instance we've been associated with by an |Init| call. - Protector* protector() { return protector_; } - private: Profile* profile_; - Protector* protector_; DISALLOW_COPY_AND_ASSIGN(BaseSettingChange); }; diff --git a/chrome/browser/protector/default_search_provider_change.cc b/chrome/browser/protector/default_search_provider_change.cc index 1ce6346..6bfed3b 100644 --- a/chrome/browser/protector/default_search_provider_change.cc +++ b/chrome/browser/protector/default_search_provider_change.cc @@ -12,7 +12,8 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/protector/base_setting_change.h" #include "chrome/browser/protector/histograms.h" -#include "chrome/browser/protector/protector.h" +#include "chrome/browser/protector/protector_service.h" +#include "chrome/browser/protector/protector_service_factory.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_prepopulate_data.h" #include "chrome/browser/search_engines/template_url_service.h" @@ -87,7 +88,7 @@ class DefaultSearchProviderChange : public BaseSettingChange, TemplateURL* backup_search_provider); // BaseSettingChange overrides: - virtual bool Init(Protector* protector) OVERRIDE; + virtual bool Init(Profile* profile) OVERRIDE; virtual void Apply() OVERRIDE; virtual void Discard() OVERRIDE; virtual void Timeout() OVERRIDE; @@ -168,8 +169,8 @@ DefaultSearchProviderChange::~DefaultSearchProviderChange() { GetTemplateURLService()->RemoveObserver(this); } -bool DefaultSearchProviderChange::Init(Protector* protector) { - if (!BaseSettingChange::Init(protector)) +bool DefaultSearchProviderChange::Init(Profile* profile) { + if (!BaseSettingChange::Init(profile)) return false; if (backup_search_provider_.get()) { @@ -222,7 +223,7 @@ bool DefaultSearchProviderChange::Init(Protector* protector) { new_id_ = new_search_provider_->id(); registrar_.Add( this, chrome::NOTIFICATION_TEMPLATE_URL_REMOVED, - content::Source<Profile>(profile()->GetOriginalProfile())); + content::Source<Profile>(profile->GetOriginalProfile())); } return true; @@ -330,8 +331,8 @@ void DefaultSearchProviderChange::OnTemplateURLServiceChanged() { VLOG(1) << "Default search provider has been changed by user"; default_search_provider_ = NULL; url_service->RemoveObserver(this); - // This will delete the Protector instance and |this|. - protector()->DismissChange(); + // Will delete this DefaultSearchProviderChange instance. + ProtectorServiceFactory::GetForProfile(profile())->DismissChange(); } } @@ -382,7 +383,7 @@ const TemplateURL* DefaultSearchProviderChange::SetDefaultSearchProvider( } void DefaultSearchProviderChange::OpenSearchEngineSettings() { - protector()->OpenTab( + ProtectorServiceFactory::GetForProfile(profile())->OpenTab( GURL(std::string(chrome::kChromeUISettingsURL) + chrome::kSearchEnginesSubPage)); } diff --git a/chrome/browser/protector/default_search_provider_change_browsertest.cc b/chrome/browser/protector/default_search_provider_change_browsertest.cc index 75dd5a4..206da5b 100644 --- a/chrome/browser/protector/default_search_provider_change_browsertest.cc +++ b/chrome/browser/protector/default_search_provider_change_browsertest.cc @@ -5,7 +5,8 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/protector/mock_protector.h" +#include "chrome/browser/protector/mock_protector_service.h" +#include "chrome/browser/protector/protector_service_factory.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_prepopulate_data.h" #include "chrome/browser/search_engines/template_url_service.h" @@ -41,8 +42,9 @@ const std::string http_example_net = "http://example.net/%s"; class DefaultSearchProviderChangeTest : public InProcessBrowserTest { public: - virtual void SetUpOnMainThread() { - mock_protector_.reset(new MockProtector(browser()->profile())); + virtual void SetUpOnMainThread() OVERRIDE { + mock_protector_service_ = + MockProtectorService::BuildForProfile(browser()->profile()); // Ensure that TemplateURLService is loaded. turl_service_ = @@ -53,6 +55,10 @@ class DefaultSearchProviderChangeTest : public InProcessBrowserTest { TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(NULL)); } + virtual void CleanUpOnMainThread() OVERRIDE { + EXPECT_CALL(*mock_protector_service_, Shutdown()); + } + TemplateURL* MakeTemplateURL(const string16& short_name, const string16& keyword, const std::string& search_url) { @@ -83,9 +89,9 @@ class DefaultSearchProviderChangeTest : public InProcessBrowserTest { turl_service_->Add(turl_copy); } - void AddAndSetDefault(TemplateURL* t_url) { - turl_service_->Add(t_url); - turl_service_->SetDefaultSearchProvider(t_url); + void AddAndSetDefault(TemplateURL* turl) { + turl_service_->Add(turl); + turl_service_->SetDefaultSearchProvider(turl); } string16 GetBubbleMessage(const string16& short_name = string16()) { @@ -113,11 +119,11 @@ class DefaultSearchProviderChangeTest : public InProcessBrowserTest { void ExpectSettingsOpened(const std::string& subpage) { GURL settings_url(chrome::kChromeUISettingsURL + subpage); - EXPECT_CALL(*mock_protector_.get(), OpenTab(settings_url)); + EXPECT_CALL(*mock_protector_service_, OpenTab(settings_url)); } protected: - scoped_ptr<MockProtector> mock_protector_; + MockProtectorService* mock_protector_service_; TemplateURLService* turl_service_; scoped_ptr<TemplateURL> prepopulated_url_; }; @@ -142,7 +148,7 @@ IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, BackupValid) { scoped_ptr<BaseSettingChange> change( CreateDefaultSearchProviderChange(current_url, backup_url)); ASSERT_TRUE(change.get()); - ASSERT_TRUE(change->Init(mock_protector_.get())); + ASSERT_TRUE(change->Init(browser()->profile())); // Verify that backup is active. EXPECT_EQ(FindTemplateURL(http_example_info), @@ -185,7 +191,7 @@ IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, BackupValidLongNames) { scoped_ptr<BaseSettingChange> change( CreateDefaultSearchProviderChange(current_url, backup_url_long)); ASSERT_TRUE(change.get()); - ASSERT_TRUE(change->Init(mock_protector_.get())); + ASSERT_TRUE(change->Init(browser()->profile())); // Verify text messages. EXPECT_EQ(GetBubbleMessage(), change->GetBubbleMessage()); @@ -202,7 +208,7 @@ IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, BackupValidLongNames) { scoped_ptr<BaseSettingChange> change( CreateDefaultSearchProviderChange(current_url_long, backup_url)); ASSERT_TRUE(change.get()); - ASSERT_TRUE(change->Init(mock_protector_.get())); + ASSERT_TRUE(change->Init(browser()->profile())); // Verify text messages. EXPECT_EQ(GetBubbleMessage(), change->GetBubbleMessage()); @@ -226,7 +232,7 @@ IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, BackupInvalid) { scoped_ptr<BaseSettingChange> change( CreateDefaultSearchProviderChange(current_url, NULL)); ASSERT_TRUE(change.get()); - ASSERT_TRUE(change->Init(mock_protector_.get())); + ASSERT_TRUE(change->Init(browser()->profile())); // Verify that the prepopulated default search is active. EXPECT_EQ(FindTemplateURL(prepopulated_url_->url()->url()), @@ -270,7 +276,7 @@ IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, scoped_ptr<BaseSettingChange> change( CreateDefaultSearchProviderChange(current_url, NULL)); ASSERT_TRUE(change.get()); - ASSERT_TRUE(change->Init(mock_protector_.get())); + ASSERT_TRUE(change->Init(browser()->profile())); // Verify that the prepopulated default search is active. EXPECT_EQ(FindTemplateURL(prepopulated_url_->url()->url()), @@ -307,7 +313,7 @@ IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, scoped_ptr<BaseSettingChange> change( CreateDefaultSearchProviderChange(NULL, backup_url)); ASSERT_TRUE(change.get()); - ASSERT_TRUE(change->Init(mock_protector_.get())); + ASSERT_TRUE(change->Init(browser()->profile())); // Verify that backup is active. EXPECT_EQ(FindTemplateURL(http_example_info), @@ -340,7 +346,7 @@ IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, scoped_ptr<BaseSettingChange> change( CreateDefaultSearchProviderChange(NULL, NULL)); ASSERT_TRUE(change.get()); - ASSERT_TRUE(change->Init(mock_protector_.get())); + ASSERT_TRUE(change->Init(browser()->profile())); // Verify that the prepopulated default search is active. EXPECT_EQ(FindTemplateURL(prepopulated_url_->url()->url()), @@ -372,7 +378,7 @@ IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, scoped_ptr<BaseSettingChange> change( CreateDefaultSearchProviderChange(current_url, NULL)); ASSERT_TRUE(change.get()); - ASSERT_TRUE(change->Init(mock_protector_.get())); + ASSERT_TRUE(change->Init(browser()->profile())); // Verify that the default search has not changed. EXPECT_EQ(current_url, turl_service_->GetDefaultSearchProvider()); @@ -407,14 +413,14 @@ IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, scoped_ptr<BaseSettingChange> change( CreateDefaultSearchProviderChange(current_url, backup_url)); ASSERT_TRUE(change.get()); - ASSERT_TRUE(change->Init(mock_protector_.get())); + ASSERT_TRUE(change->Init(browser()->profile())); // Verify that backup is active. EXPECT_EQ(FindTemplateURL(http_example_info), turl_service_->GetDefaultSearchProvider()); // Verify that changing search provider externally dismissed the change. - EXPECT_CALL(*mock_protector_.get(), DismissChange()); + EXPECT_CALL(*mock_protector_service_, DismissChange()); AddAndSetDefault(new_url); } @@ -433,7 +439,7 @@ IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, scoped_ptr<BaseSettingChange> change( CreateDefaultSearchProviderChange(current_url, backup_url)); ASSERT_TRUE(change.get()); - ASSERT_TRUE(change->Init(mock_protector_.get())); + ASSERT_TRUE(change->Init(browser()->profile())); // Verify that backup is active. EXPECT_EQ(FindTemplateURL(http_example_info), diff --git a/chrome/browser/protector/mock_protector.cc b/chrome/browser/protector/mock_protector.cc deleted file mode 100644 index 868ed93..0000000 --- a/chrome/browser/protector/mock_protector.cc +++ /dev/null @@ -1,17 +0,0 @@ -// 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/protector/mock_protector.h" - -#include "googleurl/src/gurl.h" - -namespace protector { - -MockProtector::MockProtector(Profile* profile) : Protector(profile) { -} - -MockProtector::~MockProtector() { -} - -} // namespace protector diff --git a/chrome/browser/protector/mock_protector.h b/chrome/browser/protector/mock_protector.h deleted file mode 100644 index 513d6a5..0000000 --- a/chrome/browser/protector/mock_protector.h +++ /dev/null @@ -1,31 +0,0 @@ -// 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. - -#ifndef CHROME_BROWSER_PROTECTOR_MOCK_PROTECTOR_H_ -#define CHROME_BROWSER_PROTECTOR_MOCK_PROTECTOR_H_ -#pragma once - -#include "chrome/browser/protector/protector.h" -#include "testing/gmock/include/gmock/gmock.h" - -namespace protector { - -class MockProtector : public Protector { - public: - explicit MockProtector(Profile* profile); - virtual ~MockProtector(); - - MOCK_METHOD1(ShowChange, void(BaseSettingChange*)); - MOCK_METHOD0(DismissChange, void()); - MOCK_METHOD1(OpenTab, void(const GURL&)); - - MOCK_METHOD0(OnApplyChange, void()); - MOCK_METHOD0(OnDiscardChange, void()); - MOCK_METHOD0(OnDecisionTimeout, void()); - MOCK_METHOD0(OnRemovedFromProfile, void()); -}; - -} // namespace protector - -#endif // CHROME_BROWSER_PROTECTOR_MOCK_PROTECTOR_H_ diff --git a/chrome/browser/protector/mock_protector_service.cc b/chrome/browser/protector/mock_protector_service.cc new file mode 100644 index 0000000..a8caacb --- /dev/null +++ b/chrome/browser/protector/mock_protector_service.cc @@ -0,0 +1,34 @@ +// 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/protector/mock_protector_service.h" + +#include "chrome/browser/protector/protector_service_factory.h" +#include "googleurl/src/gurl.h" + +namespace protector { + +namespace { + +ProfileKeyedService* BuildMockProtectorService(Profile* profile) { + return new MockProtectorService(profile); +} + +} // namespace + +// static +MockProtectorService* MockProtectorService::BuildForProfile(Profile* profile) { + return static_cast<MockProtectorService*>( + ProtectorServiceFactory::GetInstance()->SetTestingFactoryAndUse( + profile, BuildMockProtectorService)); +} + +MockProtectorService::MockProtectorService(Profile* profile) + : ProtectorService(profile) { +} + +MockProtectorService::~MockProtectorService() { +} + +} // namespace protector diff --git a/chrome/browser/protector/mock_protector_service.h b/chrome/browser/protector/mock_protector_service.h new file mode 100644 index 0000000..a32bb92 --- /dev/null +++ b/chrome/browser/protector/mock_protector_service.h @@ -0,0 +1,44 @@ +// 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. + +#ifndef CHROME_BROWSER_PROTECTOR_MOCK_PROTECTOR_SERVICE_H_ +#define CHROME_BROWSER_PROTECTOR_MOCK_PROTECTOR_SERVICE_H_ +#pragma once + +#include "chrome/browser/protector/protector_service.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace protector { + +class MockProtectorService : public ProtectorService { + public: + // Creates and returns the MockProtectorService instance associated with + // |profile|. Should be called before any calls to + // ProtectorServiceFactory::GetForProfile are made, otherwise a (non-mocked) + // ProtectorService instance will be associated with |profile|. + static MockProtectorService* BuildForProfile(Profile* profile); + + explicit MockProtectorService(Profile* profile); + virtual ~MockProtectorService(); + + MOCK_METHOD1(ShowChange, void(BaseSettingChange*)); + MOCK_CONST_METHOD0(IsShowingChange, bool()); + + MOCK_METHOD0(DismissChange, void()); + MOCK_METHOD0(ApplyChange, void()); + MOCK_METHOD0(DiscardChange, void()); + + MOCK_METHOD1(OpenTab, void(const GURL&)); + + MOCK_METHOD0(OnApplyChange, void()); + MOCK_METHOD0(OnDiscardChange, void()); + MOCK_METHOD0(OnDecisionTimeout, void()); + MOCK_METHOD0(OnRemovedFromProfile, void()); + + MOCK_METHOD0(Shutdown, void()); +}; + +} // namespace protector + +#endif // CHROME_BROWSER_PROTECTOR_MOCK_PROTECTOR_SERVICE_H_ diff --git a/chrome/browser/protector/mock_setting_change.cc b/chrome/browser/protector/mock_setting_change.cc index 63726ec..53bc9f3 100644 --- a/chrome/browser/protector/mock_setting_change.cc +++ b/chrome/browser/protector/mock_setting_change.cc @@ -30,10 +30,10 @@ MockSettingChange::MockSettingChange() { MockSettingChange::~MockSettingChange() { } -bool MockSettingChange::Init(Protector* protector) { - if (!BaseSettingChange::Init(protector)) +bool MockSettingChange::Init(Profile* profile) { + if (!BaseSettingChange::Init(profile)) return false; - return MockInit(protector); + return MockInit(profile); } } // namespace protector diff --git a/chrome/browser/protector/mock_setting_change.h b/chrome/browser/protector/mock_setting_change.h index 1d29801..3f151ea 100644 --- a/chrome/browser/protector/mock_setting_change.h +++ b/chrome/browser/protector/mock_setting_change.h @@ -17,9 +17,9 @@ class MockSettingChange : public BaseSettingChange { MockSettingChange(); virtual ~MockSettingChange(); - virtual bool Init(Protector* protector) OVERRIDE; + virtual bool Init(Profile* profile) OVERRIDE; - MOCK_METHOD1(MockInit, bool(Protector* protector)); + MOCK_METHOD1(MockInit, bool(Profile* profile)); MOCK_METHOD0(Apply, void()); MOCK_METHOD0(Discard, void()); MOCK_METHOD0(Timeout, void()); diff --git a/chrome/browser/protector/protector_browsertest.cc b/chrome/browser/protector/protector_browsertest.cc deleted file mode 100644 index 32b2474..0000000 --- a/chrome/browser/protector/protector_browsertest.cc +++ /dev/null @@ -1,114 +0,0 @@ -// 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 "base/memory/scoped_ptr.h" -#include "base/message_loop.h" -#include "chrome/app/chrome_command_ids.h" -#include "chrome/browser/protector/mock_setting_change.h" -#include "chrome/browser/protector/protector.h" -#include "chrome/browser/protector/settings_change_global_error.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/global_error.h" -#include "chrome/browser/ui/global_error_service.h" -#include "chrome/browser/ui/global_error_service_factory.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "chrome/test/base/ui_test_utils.h" - -using ::testing::Invoke; -using ::testing::NiceMock; -using ::testing::Return; - -namespace protector { - -class ProtectorTest : public InProcessBrowserTest { - public: - virtual void SetUpOnMainThread() { - // Protect owns the change and deletes himself. - protector_ = new Protector(browser()->profile()); - mock_change_ = new NiceMock<MockSettingChange>(); - } - - protected: - GlobalError* GetGlobalError() { - return protector_->error_.get(); - } - - void ExpectGlobalErrorActive(bool active) { - GlobalError* error = - GlobalErrorServiceFactory::GetForProfile(browser()->profile())-> - GetGlobalErrorByMenuItemCommandID(IDC_SHOW_SETTINGS_CHANGES); - EXPECT_EQ(active, static_cast<bool>(error)); - } - - Protector* protector_; - MockSettingChange* mock_change_; -}; - -IN_PROC_BROWSER_TEST_F(ProtectorTest, ChangeInitError) { - EXPECT_CALL(*mock_change_, MockInit(protector_)).WillOnce(Return(false)); - protector_->ShowChange(mock_change_); - ExpectGlobalErrorActive(false); - ui_test_utils::RunAllPendingInMessageLoop(); - ExpectGlobalErrorActive(false); -} - -IN_PROC_BROWSER_TEST_F(ProtectorTest, ShowAndDismiss) { - EXPECT_CALL(*mock_change_, MockInit(protector_)).WillOnce(Return(true)); - protector_->ShowChange(mock_change_); - ui_test_utils::RunAllPendingInMessageLoop(); - ASSERT_TRUE(GetGlobalError()); - ExpectGlobalErrorActive(true); - protector_->DismissChange(); - ui_test_utils::RunAllPendingInMessageLoop(); - ExpectGlobalErrorActive(false); -} - -IN_PROC_BROWSER_TEST_F(ProtectorTest, ShowAndApply) { - EXPECT_CALL(*mock_change_, MockInit(protector_)).WillOnce(Return(true)); - protector_->ShowChange(mock_change_); - ui_test_utils::RunAllPendingInMessageLoop(); - GlobalError* error = GetGlobalError(); - ASSERT_TRUE(error); - ExpectGlobalErrorActive(true); - EXPECT_CALL(*mock_change_, Apply()); - // Pressing Cancel applies the change. - error->BubbleViewCancelButtonPressed(); - error->BubbleViewDidClose(); - ui_test_utils::RunAllPendingInMessageLoop(); - ExpectGlobalErrorActive(false); -} - -IN_PROC_BROWSER_TEST_F(ProtectorTest, ShowAndDiscard) { - EXPECT_CALL(*mock_change_, MockInit(protector_)).WillOnce(Return(true)); - protector_->ShowChange(mock_change_); - ui_test_utils::RunAllPendingInMessageLoop(); - GlobalError* error = GetGlobalError(); - ASSERT_TRUE(error); - ExpectGlobalErrorActive(true); - EXPECT_CALL(*mock_change_, Discard()); - // Pressing Apply discards the change. - error->BubbleViewAcceptButtonPressed(); - error->BubbleViewDidClose(); - ui_test_utils::RunAllPendingInMessageLoop(); - ExpectGlobalErrorActive(false); -} - -IN_PROC_BROWSER_TEST_F(ProtectorTest, BubbleClosedInsideApply) { - EXPECT_CALL(*mock_change_, MockInit(protector_)).WillOnce(Return(true)); - protector_->ShowChange(mock_change_); - ui_test_utils::RunAllPendingInMessageLoop(); - GlobalError* error = GetGlobalError(); - ASSERT_TRUE(error); - ExpectGlobalErrorActive(true); - EXPECT_CALL(*mock_change_, Apply()). - WillOnce(Invoke(error, &GlobalError::BubbleViewDidClose)); - // Pressing Cancel applies the change. - error->BubbleViewCancelButtonPressed(); - ui_test_utils::RunAllPendingInMessageLoop(); - ExpectGlobalErrorActive(false); -} - -// TODO(ivankr): Timeout test. - -} // namespace protector diff --git a/chrome/browser/protector/protector.cc b/chrome/browser/protector/protector_service.cc index d80ce91..64733b0 100644 --- a/chrome/browser/protector/protector.cc +++ b/chrome/browser/protector/protector_service.cc @@ -2,9 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/protector/protector.h" +#include "chrome/browser/protector/protector_service.h" -#include "base/bind.h" #include "base/command_line.h" #include "base/logging.h" #include "chrome/browser/browser_process.h" @@ -15,64 +14,89 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" -#include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_source.h" #include "crypto/hmac.h" -using content::BrowserThread; - namespace protector { -Protector::Protector(Profile* profile) +ProtectorService::ProtectorService(Profile* profile) : profile_(profile) { } -Protector::~Protector() { +ProtectorService::~ProtectorService() { + DCHECK(!IsShowingChange()); // Should have been dismissed by Shutdown. } -void Protector::OpenTab(const GURL& url) { - if (!error_.get() || !error_->browser()) { - LOG(WARNING) << "Don't have browser to show tab in."; - return; - } - error_->browser()->ShowSingletonTab(url); -} - -void Protector::ShowChange(BaseSettingChange* change) { +void ProtectorService::ShowChange(BaseSettingChange* change) { DCHECK(change); change_.reset(change); DVLOG(1) << "Init change"; - if (!change->Init(this)) { - LOG(WARNING) << "Error while initializing, removing ourselves"; - BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); + if (!change->Init(profile_)) { + LOG(WARNING) << "Error while initializing, dismissing change"; + change_.reset(); return; } error_.reset(new SettingsChangeGlobalError(change, this)); error_->ShowForProfile(profile_); } -void Protector::DismissChange() { - DCHECK(error_.get()); +bool ProtectorService::IsShowingChange() const { + return change_.get() != NULL; +} + +void ProtectorService::ApplyChange() { + DCHECK(IsShowingChange()); + change_->Apply(); + DismissChange(); +} + +void ProtectorService::DiscardChange() { + DCHECK(IsShowingChange()); + change_->Discard(); + DismissChange(); +} + +void ProtectorService::DismissChange() { + DCHECK(IsShowingChange()); error_->RemoveFromProfile(); + DCHECK(!IsShowingChange()); +} + +void ProtectorService::OpenTab(const GURL& url) { + if (!error_.get() || !error_->browser()) { + LOG(WARNING) << "Don't have browser to show tab in."; + return; + } + error_->browser()->ShowSingletonTab(url); +} + +void ProtectorService::Shutdown() { + if (IsShowingChange()) + DismissChange(); } -void Protector::OnApplyChange() { +void ProtectorService::OnApplyChange() { DVLOG(1) << "Apply change"; + DCHECK(IsShowingChange()); change_->Apply(); } -void Protector::OnDiscardChange() { +void ProtectorService::OnDiscardChange() { DVLOG(1) << "Discard change"; + DCHECK(IsShowingChange()); change_->Discard(); } -void Protector::OnDecisionTimeout() { +void ProtectorService::OnDecisionTimeout() { DVLOG(1) << "Timeout"; + DCHECK(IsShowingChange()); change_->Timeout(); } -void Protector::OnRemovedFromProfile() { - BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); +void ProtectorService::OnRemovedFromProfile() { + DCHECK(IsShowingChange()); + error_.reset(); + change_.reset(); } diff --git a/chrome/browser/protector/protector.h b/chrome/browser/protector/protector_service.h index 3ded4a3..7d56166 100644 --- a/chrome/browser/protector/protector.h +++ b/chrome/browser/protector/protector_service.h @@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ -#define CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ +#ifndef CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_ +#define CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_ #pragma once #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop_helpers.h" +#include "chrome/browser/profiles/profile_keyed_service.h" #include "chrome/browser/protector/base_setting_change.h" #include "chrome/browser/protector/settings_change_global_error_delegate.h" @@ -23,18 +24,30 @@ namespace protector { class SettingsChangeGlobalError; // Presents a SettingChange to user and handles possible user actions. -// Deletes itself after a user action is taken or timeout expires. -class Protector : public SettingsChangeGlobalErrorDelegate { +class ProtectorService : public ProfileKeyedService, + public SettingsChangeGlobalErrorDelegate { public: - explicit Protector(Profile* profile); + explicit ProtectorService(Profile* profile); + virtual ~ProtectorService(); // Shows global error about the specified change. Owns |change|. + // TODO(ivankr): handle multiple subsequent changes. virtual void ShowChange(BaseSettingChange* change); - // Silently discards any change previously shown (without calling Discard), - // removes global error and deletes itself. + // Returns |true| if a change is currently active (shown by a ShowChange call + // and not yet applied or discarded). + virtual bool IsShowingChange() const; + + // Removes global error (including the bubbble if one is shown) and deletes + // the change instance (without calling Apply or Discard on it). virtual void DismissChange(); + // Persists the change that is currently active and removes global error. + virtual void ApplyChange(); + + // Discards the change that is currently active and removes global error. + virtual void DiscardChange(); + // Opens a tab with specified URL in the browser window we've shown error // bubble for. virtual void OpenTab(const GURL& url); @@ -42,20 +55,18 @@ class Protector : public SettingsChangeGlobalErrorDelegate { // Returns the Profile instance we've shown error bubble for. Profile* profile() { return profile_; } + private: + friend class ProtectorServiceTest; + + // ProfileKeyedService implementation. + virtual void Shutdown() OVERRIDE; + // SettingsChangeGlobalErrorDelegate implementation. virtual void OnApplyChange() OVERRIDE; virtual void OnDiscardChange() OVERRIDE; virtual void OnDecisionTimeout() OVERRIDE; virtual void OnRemovedFromProfile() OVERRIDE; - private: - friend class base::DeleteHelper<Protector>; - friend class MockProtector; - friend class ProtectorTest; - - // The object can only be allocated and destroyed on heap. - virtual ~Protector(); - // Pointer to error bubble controller. Indicates if we're showing change // notification to user. scoped_ptr<SettingsChangeGlobalError> error_; @@ -66,7 +77,7 @@ class Protector : public SettingsChangeGlobalErrorDelegate { // Profile which settings we are protecting. Profile* profile_; - DISALLOW_COPY_AND_ASSIGN(Protector); + DISALLOW_COPY_AND_ASSIGN(ProtectorService); }; // Signs string value with protector's key. @@ -83,4 +94,4 @@ bool IsEnabled(); } // namespace protector -#endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_H_ +#endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_ diff --git a/chrome/browser/protector/protector_service_browsertest.cc b/chrome/browser/protector/protector_service_browsertest.cc new file mode 100644 index 0000000..951dabb --- /dev/null +++ b/chrome/browser/protector/protector_service_browsertest.cc @@ -0,0 +1,149 @@ +// 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 "base/memory/scoped_ptr.h" +#include "base/message_loop.h" +#include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/protector/mock_setting_change.h" +#include "chrome/browser/protector/protector_service.h" +#include "chrome/browser/protector/protector_service_factory.h" +#include "chrome/browser/protector/settings_change_global_error.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/global_error.h" +#include "chrome/browser/ui/global_error_service.h" +#include "chrome/browser/ui/global_error_service_factory.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "chrome/test/base/ui_test_utils.h" + +using ::testing::Invoke; +using ::testing::NiceMock; +using ::testing::Return; + +namespace protector { + +class ProtectorServiceTest : public InProcessBrowserTest { + public: + virtual void SetUpOnMainThread() { + protector_service_ = + ProtectorServiceFactory::GetForProfile(browser()->profile()); + // ProtectService will own this change instance. + mock_change_ = new NiceMock<MockSettingChange>(); + } + + protected: + GlobalError* GetGlobalError() { + return protector_service_->error_.get(); + } + + void ExpectGlobalErrorActive(bool active) { + GlobalError* error = + GlobalErrorServiceFactory::GetForProfile(browser()->profile())-> + GetGlobalErrorByMenuItemCommandID(IDC_SHOW_SETTINGS_CHANGES); + EXPECT_EQ(active, error != NULL); + EXPECT_EQ(active, GetGlobalError() != NULL); + EXPECT_EQ(active, protector_service_->IsShowingChange()); + } + + ProtectorService* protector_service_; + MockSettingChange* mock_change_; +}; + +IN_PROC_BROWSER_TEST_F(ProtectorServiceTest, ChangeInitError) { + // Init fails and causes the change to be ignored. + EXPECT_CALL(*mock_change_, MockInit(browser()->profile())). + WillOnce(Return(false)); + protector_service_->ShowChange(mock_change_); + ExpectGlobalErrorActive(false); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(false); +} + +IN_PROC_BROWSER_TEST_F(ProtectorServiceTest, ShowAndDismiss) { + // Show the change and immediately dismiss it. + EXPECT_CALL(*mock_change_, MockInit(browser()->profile())). + WillOnce(Return(true)); + protector_service_->ShowChange(mock_change_); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(true); + protector_service_->DismissChange(); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(false); +} + +IN_PROC_BROWSER_TEST_F(ProtectorServiceTest, ShowAndApply) { + // Show the change and apply it. + EXPECT_CALL(*mock_change_, MockInit(browser()->profile())). + WillOnce(Return(true)); + protector_service_->ShowChange(mock_change_); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(true); + EXPECT_CALL(*mock_change_, Apply()); + protector_service_->ApplyChange(); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(false); +} + +IN_PROC_BROWSER_TEST_F(ProtectorServiceTest, ShowAndApplyManually) { + // Show the change and apply it, mimicking a button click. + EXPECT_CALL(*mock_change_, MockInit(browser()->profile())). + WillOnce(Return(true)); + protector_service_->ShowChange(mock_change_); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(true); + EXPECT_CALL(*mock_change_, Apply()); + // Pressing Cancel applies the change. + GlobalError* error = GetGlobalError(); + error->BubbleViewCancelButtonPressed(); + error->BubbleViewDidClose(); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(false); +} + +IN_PROC_BROWSER_TEST_F(ProtectorServiceTest, ShowAndDiscard) { + // Show the change and discard it. + EXPECT_CALL(*mock_change_, MockInit(browser()->profile())). + WillOnce(Return(true)); + protector_service_->ShowChange(mock_change_); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(true); + EXPECT_CALL(*mock_change_, Discard()); + protector_service_->DiscardChange(); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(false); +} + +IN_PROC_BROWSER_TEST_F(ProtectorServiceTest, ShowAndDiscardManually) { + // Show the change and discard it, mimicking a button click. + EXPECT_CALL(*mock_change_, MockInit(browser()->profile())). + WillOnce(Return(true)); + protector_service_->ShowChange(mock_change_); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(true); + EXPECT_CALL(*mock_change_, Discard()); + // Pressing Apply discards the change. + GlobalError* error = GetGlobalError(); + error->BubbleViewAcceptButtonPressed(); + error->BubbleViewDidClose(); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(false); +} + +IN_PROC_BROWSER_TEST_F(ProtectorServiceTest, BubbleClosedInsideApply) { + EXPECT_CALL(*mock_change_, MockInit(browser()->profile())). + WillOnce(Return(true)); + protector_service_->ShowChange(mock_change_); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(true); + GlobalError* error = GetGlobalError(); + EXPECT_CALL(*mock_change_, Apply()). + WillOnce(Invoke(error, &GlobalError::BubbleViewDidClose)); + // Pressing Cancel applies the change. + error->BubbleViewCancelButtonPressed(); + ui_test_utils::RunAllPendingInMessageLoop(); + ExpectGlobalErrorActive(false); +} + +// TODO(ivankr): Timeout test. + +} // namespace protector diff --git a/chrome/browser/protector/protector_service_factory.cc b/chrome/browser/protector/protector_service_factory.cc new file mode 100644 index 0000000..c11cbdc --- /dev/null +++ b/chrome/browser/protector/protector_service_factory.cc @@ -0,0 +1,43 @@ +// 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/protector/protector_service_factory.h" + +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_dependency_manager.h" +#include "chrome/browser/protector/protector_service.h" +#include "chrome/browser/search_engines/template_url_service_factory.h" + +namespace protector { + +// static +ProtectorService* ProtectorServiceFactory::GetForProfile(Profile* profile) { + return static_cast<ProtectorService*>( + GetInstance()->GetServiceForProfile(profile, true)); +} + +// static +ProtectorServiceFactory* ProtectorServiceFactory::GetInstance() { + return Singleton<ProtectorServiceFactory>::get(); +} + +ProtectorServiceFactory::ProtectorServiceFactory() + : ProfileKeyedServiceFactory(ProfileDependencyManager::GetInstance()) { + DependsOn(GlobalErrorServiceFactory::GetInstance()); + DependsOn(TemplateURLServiceFactory::GetInstance()); +} + +ProtectorServiceFactory::~ProtectorServiceFactory() { +} + +ProfileKeyedService* ProtectorServiceFactory::BuildServiceInstanceFor( + Profile* profile) const { + return new ProtectorService(profile); +} + +bool ProtectorServiceFactory::ServiceRedirectedInIncognito() { + return true; +} + +} // namespace protector diff --git a/chrome/browser/protector/protector_service_factory.h b/chrome/browser/protector/protector_service_factory.h new file mode 100644 index 0000000..e78186a --- /dev/null +++ b/chrome/browser/protector/protector_service_factory.h @@ -0,0 +1,41 @@ +// 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. + +#ifndef CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_FACTORY_H_ +#define CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_FACTORY_H_ +#pragma once + +#include "base/basictypes.h" +#include "base/memory/singleton.h" +#include "chrome/browser/profiles/profile_keyed_service_factory.h" +#include "chrome/browser/ui/global_error_service_factory.h" + +namespace protector { + +class ProtectorService; + +class ProtectorServiceFactory : public ProfileKeyedServiceFactory { + public: + // Returns the ProtectorService instance for |profile|. + static ProtectorService* GetForProfile(Profile* profile); + + static ProtectorServiceFactory* GetInstance(); + + private: + friend struct DefaultSingletonTraits<ProtectorServiceFactory>; + + ProtectorServiceFactory(); + virtual ~ProtectorServiceFactory(); + + // ProfileKeyedServiceFactory implementation. + virtual ProfileKeyedService* BuildServiceInstanceFor( + Profile* profile) const OVERRIDE; + virtual bool ServiceRedirectedInIncognito() OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(ProtectorServiceFactory); +}; + +} // namespace protector + +#endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_FACTORY_H_ diff --git a/chrome/browser/protector/settings_change_global_error.cc b/chrome/browser/protector/settings_change_global_error.cc index 5b57584..4d22142 100644 --- a/chrome/browser/protector/settings_change_global_error.cc +++ b/chrome/browser/protector/settings_change_global_error.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. @@ -116,6 +116,7 @@ void SettingsChangeGlobalError::BubbleViewCancelButtonPressed() { void SettingsChangeGlobalError::RemoveFromProfile() { if (profile_) GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(this); + // This will delete |this|. delegate_->OnRemovedFromProfile(); } diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc index 79677c5..d61aa68 100644 --- a/chrome/browser/search_engines/template_url_service.cc +++ b/chrome/browser/search_engines/template_url_service.cc @@ -23,7 +23,8 @@ #include "chrome/browser/prefs/pref_set_observer.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/protector/base_setting_change.h" -#include "chrome/browser/protector/protector.h" +#include "chrome/browser/protector/protector_service.h" +#include "chrome/browser/protector/protector_service_factory.h" #include "chrome/browser/rlz/rlz.h" #include "chrome/browser/search_engines/search_host_to_urls_map.h" #include "chrome/browser/search_engines/search_terms_data.h" @@ -624,11 +625,13 @@ void TemplateURLService::OnWebDataServiceRequestDone( if (is_default_search_hijacked && default_search_provider_ == hijacked_default_search_provider) { if (protector::IsEnabled()) { - // Protector instance will delete itself when it's needed no longer. - protector::Protector* protector = new protector::Protector(profile()); - protector->ShowChange(protector::CreateDefaultSearchProviderChange( - hijacked_default_search_provider, - backup_default_search_provider.release())); + protector::ProtectorService* protector_service = + protector::ProtectorServiceFactory::GetForProfile(profile()); + DCHECK(protector_service); + protector_service->ShowChange( + protector::CreateDefaultSearchProviderChange( + hijacked_default_search_provider, + backup_default_search_provider.release())); } else { // Protector is turned off: set the current default search to itself // to update the backup and sign it. Otherwise, change will be reported diff --git a/chrome/browser/webdata/keyword_table.cc b/chrome/browser/webdata/keyword_table.cc index beefc7b..0caf367 100644 --- a/chrome/browser/webdata/keyword_table.cc +++ b/chrome/browser/webdata/keyword_table.cc @@ -15,7 +15,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/history/history_database.h" #include "chrome/browser/protector/histograms.h" -#include "chrome/browser/protector/protector.h" +#include "chrome/browser/protector/protector_service.h" #include "chrome/browser/search_engines/template_url.h" #include "googleurl/src/gurl.h" #include "sql/statement.h" diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 80cbb84..565cbb2 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2047,8 +2047,10 @@ 'browser/protector/internal/keys_internal.cc', 'browser/protector/keys.cc', 'browser/protector/keys.h', - 'browser/protector/protector.cc', - 'browser/protector/protector.h', + 'browser/protector/protector_service.cc', + 'browser/protector/protector_service.h', + 'browser/protector/protector_service_factory.cc', + 'browser/protector/protector_service_factory.h', 'browser/protector/settings_change_global_error.cc', 'browser/protector/settings_change_global_error.h', 'browser/protector/settings_change_global_error_delegate.h', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index e640f4f..a92cd57 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -146,8 +146,8 @@ 'browser/prefs/pref_service_mock_builder.h', 'browser/prefs/testing_pref_store.cc', 'browser/prefs/testing_pref_store.h', - 'browser/protector/mock_protector.cc', - 'browser/protector/mock_protector.h', + 'browser/protector/mock_protector_service.cc', + 'browser/protector/mock_protector_service.h', 'browser/protector/mock_setting_change.cc', 'browser/protector/mock_setting_change.h', 'browser/search_engines/template_url_service_test_util.cc', @@ -2682,7 +2682,7 @@ 'browser/printing/print_preview_tab_controller_browsertest.cc', 'browser/profiles/profile_manager_browsertest.cc', 'browser/protector/default_search_provider_change_browsertest.cc', - 'browser/protector/protector_browsertest.cc', + 'browser/protector/protector_service_browsertest.cc', 'browser/rlz/rlz_extension_apitest.cc', 'browser/referrer_policy_browsertest.cc', 'browser/renderer_host/render_process_host_chrome_browsertest.cc', @@ -3057,8 +3057,8 @@ '../content/renderer/external_popup_menu_browsertest.cc', ], 'sources!': [ - # TODO(sail): re-enable this once http://crbug.com/109728 is fixed. - 'browser/protector/protector_browsertest.cc', + # TODO(ivankr): enable this once http://crbug.com/109728 is fixed. + 'browser/protector/protector_service_browsertest.cc', # TODO(hbono): This test depends on hunspell and we cannot run it on # Mac, which does not use hunspell by default. 'browser/spellchecker/spellcheck_host_browsertest.cc', |