diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-23 04:28:52 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-23 04:28:52 +0000 |
commit | c2134fbb74422221865520a4af5291784c08189b (patch) | |
tree | 08c1af7bcab0e26bb9e24f9c4539629118d53a9f /components | |
parent | 4f056a870937b82f28bbde8ff4172940a3ea87a4 (diff) | |
download | chromium_src-c2134fbb74422221865520a4af5291784c08189b.zip chromium_src-c2134fbb74422221865520a4af5291784c08189b.tar.gz chromium_src-c2134fbb74422221865520a4af5291784c08189b.tar.bz2 |
Disable VisitedLink in incognito mode
Fix regression introduced in r175906 where the default and incognito
profile shares the same VisitedLinkMaster. Before r175906, a separate
VisitedLinkMaster is created for incognito profile but since no
HistoryService is created for the incognito profile, the
VisitedLinkMaster never has urls added to it.
In this CL, just skip creating an VisitedLinkMaster for the incognito
profile in the first place.
BUG=171374
Review URL: https://chromiumcodereview.appspot.com/12039025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178245 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
3 files changed, 27 insertions, 16 deletions
diff --git a/components/visitedlink/browser/visitedlink_delegate.h b/components/visitedlink/browser/visitedlink_delegate.h index 700cff0..5591308 100644 --- a/components/visitedlink/browser/visitedlink_delegate.h +++ b/components/visitedlink/browser/visitedlink_delegate.h @@ -18,10 +18,6 @@ namespace components { // Delegate class that clients of VisitedLinkMaster must implement. class VisitedLinkDelegate { public: - // Returns true when the two BrowserContexts are equivalent. - virtual bool AreEquivalentContexts(content::BrowserContext* context1, - content::BrowserContext* context2) = 0; - // See RebuildTable. class URLEnumerator : public base::RefCountedThreadSafe<URLEnumerator> { public: diff --git a/components/visitedlink/browser/visitedlink_event_listener.cc b/components/visitedlink/browser/visitedlink_event_listener.cc index c9e8a51..a8d0b0f 100644 --- a/components/visitedlink/browser/visitedlink_event_listener.cc +++ b/components/visitedlink/browser/visitedlink_event_listener.cc @@ -181,8 +181,7 @@ void VisitedLinkEventListener::Observe( case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { content::RenderProcessHost* process = content::Source<content::RenderProcessHost>(source).ptr(); - if (!master_->GetDelegate()->AreEquivalentContexts( - browser_context_, process->GetBrowserContext())) + if (browser_context_ != process->GetBrowserContext()) return; // Happens on browser start up. diff --git a/components/visitedlink/test/visitedlink_unittest.cc b/components/visitedlink/test/visitedlink_unittest.cc index b9f2a0c..ef1851f 100644 --- a/components/visitedlink/test/visitedlink_unittest.cc +++ b/components/visitedlink/test/visitedlink_unittest.cc @@ -53,9 +53,6 @@ std::vector<VisitedLinkSlave*> g_slaves; class TestVisitedLinkDelegate : public VisitedLinkDelegate { public: - virtual bool AreEquivalentContexts( - content::BrowserContext* context1, - content::BrowserContext* context2) OVERRIDE; virtual void RebuildTable( const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE; @@ -66,12 +63,6 @@ class TestVisitedLinkDelegate : public VisitedLinkDelegate { URLs rebuild_urls_; }; -bool TestVisitedLinkDelegate::AreEquivalentContexts( - content::BrowserContext* context1, content::BrowserContext* context2) { - DCHECK_EQ(context1, context2); - return true; // Test only has one profile. -} - void TestVisitedLinkDelegate::RebuildTable( const scoped_refptr<URLEnumerator>& enumerator) { for (URLs::const_iterator itr = rebuild_urls_.begin(); @@ -510,7 +501,8 @@ class VisitCountingProfile : public TestingProfile { VisitCountingProfile() : add_count_(0), add_event_count_(0), - reset_event_count_(0) {} + reset_event_count_(0), + new_table_count_(0) {} void CountAddEvent(int by) { add_count_ += by; @@ -521,14 +513,20 @@ class VisitCountingProfile : public TestingProfile { reset_event_count_++; } + void CountNewTable() { + new_table_count_++; + } + int add_count() const { return add_count_; } int add_event_count() const { return add_event_count_; } int reset_event_count() const { return reset_event_count_; } + int new_table_count() const { return new_table_count_; } private: int add_count_; int add_event_count_; int reset_event_count_; + int new_table_count_; }; // Stub out as little as possible, borrowing from RenderProcessHost. @@ -565,6 +563,8 @@ class VisitRelayingRenderProcessHost : public MockRenderProcessHost { counting_profile->CountAddEvent(fingerprints.size()); } else if (msg->type() == ChromeViewMsg_VisitedLink_Reset::ID) { counting_profile->CountResetEvent(); + } else if (msg->type() == ChromeViewMsg_VisitedLink_NewTable::ID) { + counting_profile->CountNewTable(); } delete msg; @@ -760,4 +760,20 @@ TEST_F(VisitedLinkEventsTest, TabVisibility) { EXPECT_EQ(1, profile()->reset_event_count()); } +// Tests that VisitedLink ignores renderer process creation notification for a +// different profile. +TEST_F(VisitedLinkEventsTest, IgnoreRendererCreationFromDifferentContext) { + VisitCountingProfile different_context; + VisitRelayingRenderProcessHost different_process_host(&different_context); + + content::NotificationService::current()->Notify( + content::NOTIFICATION_RENDERER_PROCESS_CREATED, + content::Source<content::RenderProcessHost>(&different_process_host), + content::NotificationService::NoDetails()); + WaitForCoalescense(); + + EXPECT_EQ(0, different_context.new_table_count()); + +} + } // namespace components |