diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-10 01:38:38 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-10 01:38:38 +0000 |
commit | 2ee6bcfa32076c43fd8070952a27707cf9f16534 (patch) | |
tree | bd7a6735ca43263c842f7f5c64c417bebc5ce156 | |
parent | 9deeb3fc56f5271fce654ca06618a044d295c490 (diff) | |
download | chromium_src-2ee6bcfa32076c43fd8070952a27707cf9f16534.zip chromium_src-2ee6bcfa32076c43fd8070952a27707cf9f16534.tar.gz chromium_src-2ee6bcfa32076c43fd8070952a27707cf9f16534.tar.bz2 |
A few cleanup changes to the GoogleURLTracker classes:
* Fix a few incorrect comments.
* Rename "infobar" to "delegate" or "infobar delegate" in various places for
better accuracy/clarity.
* Be more paranoid about not trying to remove an infobar after it navigates the
current page. I don't think this would actually cause problems since the
infobar wouldn't normally be removed until the load commits (asynchronously),
but the new code seems more guaranteed to be safe.
BUG=none
TEST=none
R=isherman@chromium.org
Review URL: https://codereview.chromium.org/18209013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210702 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/google/google_url_tracker.cc | 18 | ||||
-rw-r--r-- | chrome/browser/google/google_url_tracker.h | 3 | ||||
-rw-r--r-- | chrome/browser/google/google_url_tracker_infobar_delegate.cc | 28 | ||||
-rw-r--r-- | chrome/browser/google/google_url_tracker_map_entry.cc | 18 | ||||
-rw-r--r-- | chrome/browser/google/google_url_tracker_map_entry.h | 10 | ||||
-rw-r--r-- | chrome/browser/google/google_url_tracker_unittest.cc | 128 |
6 files changed, 108 insertions, 97 deletions
diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc index 2472417..c2568ea 100644 --- a/chrome/browser/google/google_url_tracker.cc +++ b/chrome/browser/google/google_url_tracker.cc @@ -303,12 +303,12 @@ void GoogleURLTracker::OnNavigationPending( infobar_service, new GoogleURLTrackerMapEntry(this, infobar_service, navigation_controller))); - } else if (i->second->has_infobar()) { + } else if (i->second->has_infobar_delegate()) { // This is a new search on a tab where we already have an infobar. - i->second->infobar()->set_pending_id(pending_id); + i->second->infobar_delegate()->set_pending_id(pending_id); } } else if (i != entry_map_.end()){ - if (i->second->has_infobar()) { + if (i->second->has_infobar_delegate()) { // This is a non-search navigation on a tab with an infobar. If there was // a previous pending search on this tab, this means it won't commit, so // undo anything we did in response to seeing that. Note that if there @@ -319,7 +319,7 @@ void GoogleURLTracker::OnNavigationPending( // owner to expire the infobar if need be. If it doesn't commit, then // simply leaving the infobar as-is will have been the right thing. UnregisterForEntrySpecificNotifications(*i->second, false); - i->second->infobar()->set_pending_id(0); + i->second->infobar_delegate()->set_pending_id(0); } else { // Non-search navigation on a tab with an entry that has not yet created // an infobar. This means the original search won't commit, so delete the @@ -340,13 +340,13 @@ void GoogleURLTracker::OnNavigationCommitted(InfoBarService* infobar_service, DCHECK(search_url.is_valid()); UnregisterForEntrySpecificNotifications(*map_entry, true); - if (map_entry->has_infobar()) { - map_entry->infobar()->Update(search_url); + if (map_entry->has_infobar_delegate()) { + map_entry->infobar_delegate()->Update(search_url); } else { GoogleURLTrackerInfoBarDelegate* infobar_delegate = infobar_creator_.Run(infobar_service, this, search_url); if (infobar_delegate) - map_entry->SetInfoBar(infobar_delegate); + map_entry->SetInfoBarDelegate(infobar_delegate); else map_entry->Close(false); } @@ -389,12 +389,12 @@ void GoogleURLTracker::UnregisterForEntrySpecificNotifications( map_entry.navigation_controller(), false); } else { DCHECK(!must_be_listening_for_commit); - DCHECK(map_entry.has_infobar()); + DCHECK(map_entry.has_infobar_delegate()); } const bool registered_for_tab_destruction = nav_helper_->IsListeningForTabDestruction( map_entry.navigation_controller()); - DCHECK_NE(registered_for_tab_destruction, map_entry.has_infobar()); + DCHECK_NE(registered_for_tab_destruction, map_entry.has_infobar_delegate()); if (registered_for_tab_destruction) { nav_helper_->SetListeningForTabDestruction( map_entry.navigation_controller(), false); diff --git a/chrome/browser/google/google_url_tracker.h b/chrome/browser/google/google_url_tracker.h index d71e7e7..5f2c85e 100644 --- a/chrome/browser/google/google_url_tracker.h +++ b/chrome/browser/google/google_url_tracker.h @@ -105,8 +105,7 @@ class GoogleURLTracker : public net::URLFetcherDelegate, // |pending_id| is the unique ID of the newly pending NavigationEntry. // If there is already a visible GoogleURLTracker infobar for this tab, this // function resets its associated pending entry ID to the new ID. Otherwise - // this function creates a (still-invisible) InfoBarDelegate for the - // associated tab. + // this function creates a map entry for the associated tab. virtual void OnNavigationPending( content::NavigationController* navigation_controller, InfoBarService* infobar_service, diff --git a/chrome/browser/google/google_url_tracker_infobar_delegate.cc b/chrome/browser/google/google_url_tracker_infobar_delegate.cc index df1f8b8..d88d66c 100644 --- a/chrome/browser/google/google_url_tracker_infobar_delegate.cc +++ b/chrome/browser/google/google_url_tracker_infobar_delegate.cc @@ -44,21 +44,28 @@ void GoogleURLTrackerInfoBarDelegate::Update(const GURL& search_url) { } void GoogleURLTrackerInfoBarDelegate::Close(bool redo_search) { + // It's not obvious whether calling OpenURL() with a search URL would + // auto-close us or not. If it did, we wouldn't want to try to + // RemoveInfoBar() afterwards. So for safety, we always call RemoveInfoBar() + // directly, and then navigate if necessary afterwards. + GURL new_search_url; if (redo_search) { // Re-do the user's search on the new domain. DCHECK(search_url_.is_valid()); url_canon::Replacements<char> replacements; const std::string& host(google_url_tracker_->fetched_google_url().host()); replacements.SetHost(host.data(), url_parse::Component(0, host.length())); - GURL new_search_url(search_url_.ReplaceComponents(replacements)); - if (new_search_url.is_valid()) { - web_contents()->OpenURL(content::OpenURLParams( - new_search_url, content::Referrer(), CURRENT_TAB, - content::PAGE_TRANSITION_GENERATED, false)); - } + new_search_url = search_url_.ReplaceComponents(replacements); } owner()->RemoveInfoBar(this); + // WARNING: |this| may be deleted at this point! Do not access any members! + + if (new_search_url.is_valid()) { + web_contents()->OpenURL(content::OpenURLParams( + new_search_url, content::Referrer(), CURRENT_TAB, + content::PAGE_TRANSITION_GENERATED, false)); + } } GoogleURLTrackerInfoBarDelegate::GoogleURLTrackerInfoBarDelegate( @@ -99,12 +106,13 @@ string16 GoogleURLTrackerInfoBarDelegate::GetLinkText() const { bool GoogleURLTrackerInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { - content::OpenURLParams params(google_util::AppendGoogleLocaleParam(GURL( - "https://www.google.com/support/chrome/bin/answer.py?answer=1618699")), + web_contents()->OpenURL(content::OpenURLParams( + google_util::AppendGoogleLocaleParam(GURL( + "https://www.google.com/support/chrome/bin/answer.py?" + "answer=1618699")), content::Referrer(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, - content::PAGE_TRANSITION_LINK, false); - web_contents()->OpenURL(params); + content::PAGE_TRANSITION_LINK, false)); return false; } diff --git a/chrome/browser/google/google_url_tracker_map_entry.cc b/chrome/browser/google/google_url_tracker_map_entry.cc index 5a2d617..ea70685 100644 --- a/chrome/browser/google/google_url_tracker_map_entry.cc +++ b/chrome/browser/google/google_url_tracker_map_entry.cc @@ -18,7 +18,7 @@ GoogleURLTrackerMapEntry::GoogleURLTrackerMapEntry( const content::NavigationController* navigation_controller) : google_url_tracker_(google_url_tracker), infobar_service_(infobar_service), - infobar_(NULL), + infobar_delegate_(NULL), navigation_controller_(navigation_controller) { } @@ -29,25 +29,27 @@ void GoogleURLTrackerMapEntry::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { + DCHECK(infobar_delegate_); DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); DCHECK_EQ(infobar_service_, content::Source<InfoBarService>(source).ptr()); - if (content::Details<InfoBarRemovedDetails>(details)->first == infobar_) { + if (content::Details<InfoBarRemovedDetails>(details)->first == + infobar_delegate_) { google_url_tracker_->DeleteMapEntryForService(infobar_service_); // WARNING: At this point |this| has been deleted! } } -void GoogleURLTrackerMapEntry::SetInfoBar( - GoogleURLTrackerInfoBarDelegate* infobar) { - DCHECK(!infobar_); - infobar_ = infobar; +void GoogleURLTrackerMapEntry::SetInfoBarDelegate( + GoogleURLTrackerInfoBarDelegate* infobar_delegate) { + DCHECK(!infobar_delegate_); + infobar_delegate_ = infobar_delegate; registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, content::Source<InfoBarService>(infobar_service_)); } void GoogleURLTrackerMapEntry::Close(bool redo_search) { - if (infobar_) { - infobar_->Close(redo_search); + if (infobar_delegate_) { + infobar_delegate_->Close(redo_search); } else { // WARNING: |infobar_service_| may point to a deleted object. Do not // dereference it! See GoogleURLTracker::OnTabClosed(). diff --git a/chrome/browser/google/google_url_tracker_map_entry.h b/chrome/browser/google/google_url_tracker_map_entry.h index 2a190f8..2e035a7 100644 --- a/chrome/browser/google/google_url_tracker_map_entry.h +++ b/chrome/browser/google/google_url_tracker_map_entry.h @@ -24,9 +24,11 @@ class GoogleURLTrackerMapEntry : public content::NotificationObserver { const content::NavigationController* navigation_controller); virtual ~GoogleURLTrackerMapEntry(); - bool has_infobar() const { return !!infobar_; } - GoogleURLTrackerInfoBarDelegate* infobar() { return infobar_; } - void SetInfoBar(GoogleURLTrackerInfoBarDelegate* infobar); + bool has_infobar_delegate() const { return !!infobar_delegate_; } + GoogleURLTrackerInfoBarDelegate* infobar_delegate() { + return infobar_delegate_; + } + void SetInfoBarDelegate(GoogleURLTrackerInfoBarDelegate* infobar_delegate); const content::NavigationController* navigation_controller() const { return navigation_controller_; @@ -45,7 +47,7 @@ class GoogleURLTrackerMapEntry : public content::NotificationObserver { content::NotificationRegistrar registrar_; GoogleURLTracker* const google_url_tracker_; const InfoBarService* const infobar_service_; - GoogleURLTrackerInfoBarDelegate* infobar_; + GoogleURLTrackerInfoBarDelegate* infobar_delegate_; const content::NavigationController* const navigation_controller_; DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerMapEntry); diff --git a/chrome/browser/google/google_url_tracker_unittest.cc b/chrome/browser/google/google_url_tracker_unittest.cc index 8f999a7..c573d94 100644 --- a/chrome/browser/google/google_url_tracker_unittest.cc +++ b/chrome/browser/google/google_url_tracker_unittest.cc @@ -231,7 +231,7 @@ class GoogleURLTrackerTest : public testing::Test { void CommitSearch(intptr_t unique_id, const GURL& search_url); void CloseTab(intptr_t unique_id); GoogleURLTrackerMapEntry* GetMapEntry(intptr_t unique_id); - GoogleURLTrackerInfoBarDelegate* GetInfoBar(intptr_t unique_id); + GoogleURLTrackerInfoBarDelegate* GetInfoBarDelegate(intptr_t unique_id); void ExpectDefaultURLs() const; void ExpectListeningForCommit(intptr_t unique_id, bool listening); bool observer_notified() const { return observer_.notified(); } @@ -241,7 +241,7 @@ class GoogleURLTrackerTest : public testing::Test { // Since |infobar_service| is really a magic number rather than an actual // object, we don't add the created infobar to it. Instead we will simulate // any helper<->infobar interaction necessary. The returned object will be - // cleaned up in CloseTab(). + // cleaned up in OnInfoBarClosed(). GoogleURLTrackerInfoBarDelegate* CreateTestInfoBar( InfoBarService* infobar_service, GoogleURLTracker* google_url_tracker, @@ -273,7 +273,7 @@ void GoogleURLTrackerTest::OnInfoBarClosed(InfoBarDelegate* infobar, google_url_tracker_->entry_map_.find(infobar_service); ASSERT_FALSE(i == google_url_tracker_->entry_map_.end()); GoogleURLTrackerMapEntry* map_entry = i->second; - ASSERT_EQ(infobar, map_entry->infobar()); + ASSERT_EQ(infobar, map_entry->infobar_delegate()); map_entry->Observe(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, content::Source<InfoBarService>(infobar_service), content::Details<InfoBarRemovedDetails>(&removed_details)); @@ -386,14 +386,14 @@ void GoogleURLTrackerTest::CommitNonSearch(intptr_t unique_id) { // The infobar should be showing; otherwise the pending non-search should // have closed it. - ASSERT_TRUE(map_entry->has_infobar()); + ASSERT_TRUE(map_entry->has_infobar_delegate()); // The pending_id should have been reset to 0 when the non-search became // pending. - EXPECT_EQ(0, map_entry->infobar()->pending_id()); + EXPECT_EQ(0, map_entry->infobar_delegate()->pending_id()); // Committing the navigation would close the infobar. - map_entry->infobar()->Close(false); + map_entry->infobar_delegate()->Close(false); } void GoogleURLTrackerTest::CommitSearch(intptr_t unique_id, @@ -402,8 +402,7 @@ void GoogleURLTrackerTest::CommitSearch(intptr_t unique_id, if (nav_helper_->IsListeningForNavigationCommit( reinterpret_cast<content::NavigationController*>(unique_id))) { google_url_tracker_->OnNavigationCommitted( - reinterpret_cast<InfoBarService*>(unique_id), - search_url); + reinterpret_cast<InfoBarService*>(unique_id), search_url); } } @@ -415,9 +414,9 @@ void GoogleURLTrackerTest::CloseTab(intptr_t unique_id) { google_url_tracker_->OnTabClosed(nav_controller); } else { // Closing a tab with an infobar showing would close the infobar. - GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBar(unique_id); - if (infobar) - infobar->Close(false); + GoogleURLTrackerInfoBarDelegate* delegate = GetInfoBarDelegate(unique_id); + if (delegate) + delegate->Close(false); } } @@ -429,10 +428,10 @@ GoogleURLTrackerMapEntry* GoogleURLTrackerTest::GetMapEntry( return (i == google_url_tracker_->entry_map_.end()) ? NULL : i->second; } -GoogleURLTrackerInfoBarDelegate* GoogleURLTrackerTest::GetInfoBar( +GoogleURLTrackerInfoBarDelegate* GoogleURLTrackerTest::GetInfoBarDelegate( intptr_t unique_id) { GoogleURLTrackerMapEntry* map_entry = GetMapEntry(unique_id); - return map_entry ? map_entry->infobar() : NULL; + return map_entry ? map_entry->infobar_delegate() : NULL; } void GoogleURLTrackerTest::ExpectDefaultURLs() const { @@ -493,6 +492,7 @@ void TestInfoBarDelegate::Update(const GURL& search_url) { void TestInfoBarDelegate::Close(bool redo_search) { test_harness_->OnInfoBarClosed(this, infobar_service_); + // WARNING: At this point |this| has been deleted! } } // namespace @@ -739,7 +739,7 @@ TEST_F(GoogleURLTrackerTest, TabClosedOnPendingSearch) { SetNavigationPending(1, true); GoogleURLTrackerMapEntry* map_entry = GetMapEntry(1); ASSERT_FALSE(map_entry == NULL); - EXPECT_FALSE(map_entry->has_infobar()); + EXPECT_FALSE(map_entry->has_infobar_delegate()); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_FALSE(observer_notified()); @@ -759,7 +759,7 @@ TEST_F(GoogleURLTrackerTest, TabClosedOnCommittedSearch) { SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); - EXPECT_FALSE(GetInfoBar(1) == NULL); + EXPECT_FALSE(GetInfoBarDelegate(1) == NULL); CloseTab(1); EXPECT_TRUE(GetMapEntry(1) == NULL); @@ -776,7 +776,7 @@ TEST_F(GoogleURLTrackerTest, InfoBarClosed) { SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); - GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBar(1); + GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBarDelegate(1); ASSERT_FALSE(infobar == NULL); infobar->Close(false); @@ -794,7 +794,7 @@ TEST_F(GoogleURLTrackerTest, InfoBarRefused) { SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); - GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBar(1); + GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBarDelegate(1); ASSERT_FALSE(infobar == NULL); infobar->Cancel(); @@ -812,7 +812,7 @@ TEST_F(GoogleURLTrackerTest, InfoBarAccepted) { SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); - GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBar(1); + GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBarDelegate(1); ASSERT_FALSE(infobar == NULL); infobar->Accept(); @@ -833,7 +833,7 @@ TEST_F(GoogleURLTrackerTest, FetchesCanAutomaticallyCloseInfoBars) { MockSearchDomainCheckResponse("http://www.google.co.uk/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.com/search?q=test")); - EXPECT_FALSE(GetInfoBar(1) == NULL); + EXPECT_FALSE(GetInfoBarDelegate(1) == NULL); NotifyIPAddressChanged(); MockSearchDomainCheckResponse(google_url().spec()); EXPECT_EQ(google_url(), GetLastPromptedGoogleURL()); @@ -844,7 +844,7 @@ TEST_F(GoogleURLTrackerTest, FetchesCanAutomaticallyCloseInfoBars) { MockSearchDomainCheckResponse("http://www.google.co.uk/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.com/search?q=test")); - EXPECT_FALSE(GetInfoBar(1) == NULL); + EXPECT_FALSE(GetInfoBarDelegate(1) == NULL); NotifyIPAddressChanged(); url_canon::Replacements<char> replacements; const std::string& scheme("https"); @@ -861,7 +861,7 @@ TEST_F(GoogleURLTrackerTest, FetchesCanAutomaticallyCloseInfoBars) { MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.com/search?q=test")); - EXPECT_FALSE(GetInfoBar(1) == NULL); + EXPECT_FALSE(GetInfoBarDelegate(1) == NULL); NotifyIPAddressChanged(); MockSearchDomainCheckResponse("http://www.google.co.uk/"); EXPECT_EQ(new_google_url, google_url()); @@ -873,7 +873,7 @@ TEST_F(GoogleURLTrackerTest, FetchesCanAutomaticallyCloseInfoBars) { MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.com/search?q=test")); - EXPECT_FALSE(GetInfoBar(1) == NULL); + EXPECT_FALSE(GetInfoBarDelegate(1) == NULL); NotifyIPAddressChanged(); MockSearchDomainCheckResponse("https://www.google.co.uk/"); EXPECT_EQ(new_google_url, google_url()); @@ -885,7 +885,7 @@ TEST_F(GoogleURLTrackerTest, FetchesCanAutomaticallyCloseInfoBars) { MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.com/search?q=test")); - EXPECT_FALSE(GetInfoBar(1) == NULL); + EXPECT_FALSE(GetInfoBarDelegate(1) == NULL); NotifyIPAddressChanged(); MockSearchDomainCheckResponse("https://www.google.co.in/"); EXPECT_EQ(new_google_url, google_url()); @@ -902,15 +902,15 @@ TEST_F(GoogleURLTrackerTest, ResetInfoBarGoogleURLs) { MockSearchDomainCheckResponse("http://www.google.co.uk/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.com/search?q=test")); - GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBar(1); - ASSERT_FALSE(infobar == NULL); + GoogleURLTrackerInfoBarDelegate* delegate = GetInfoBarDelegate(1); + ASSERT_FALSE(delegate == NULL); EXPECT_EQ(GURL("http://www.google.co.uk/"), fetched_google_url()); // If while an infobar is showing we fetch a new URL that differs from the // infobar's only by scheme, the infobar should stay showing. NotifyIPAddressChanged(); MockSearchDomainCheckResponse("https://www.google.co.uk/"); - EXPECT_EQ(infobar, GetInfoBar(1)); + EXPECT_EQ(delegate, GetInfoBarDelegate(1)); EXPECT_EQ(GURL("https://www.google.co.uk/"), fetched_google_url()); } @@ -924,7 +924,7 @@ TEST_F(GoogleURLTrackerTest, NavigationsAfterPendingSearch) { SetNavigationPending(1, true); GoogleURLTrackerMapEntry* map_entry = GetMapEntry(1); ASSERT_FALSE(map_entry == NULL); - EXPECT_FALSE(map_entry->has_infobar()); + EXPECT_FALSE(map_entry->has_infobar_delegate()); SetNavigationPending(1, false); EXPECT_TRUE(GetMapEntry(1) == NULL); @@ -932,15 +932,15 @@ TEST_F(GoogleURLTrackerTest, NavigationsAfterPendingSearch) { SetNavigationPending(1, true); map_entry = GetMapEntry(1); ASSERT_FALSE(map_entry == NULL); - EXPECT_FALSE(map_entry->has_infobar()); + EXPECT_FALSE(map_entry->has_infobar_delegate()); SetNavigationPending(1, true); ASSERT_EQ(map_entry, GetMapEntry(1)); - EXPECT_FALSE(map_entry->has_infobar()); + EXPECT_FALSE(map_entry->has_infobar_delegate()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); // Committing this search should show an infobar. CommitSearch(1, GURL("http://www.google.co.uk/search?q=test2")); - EXPECT_TRUE(map_entry->has_infobar()); + EXPECT_TRUE(map_entry->has_infobar_delegate()); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); EXPECT_FALSE(observer_notified()); @@ -954,20 +954,20 @@ TEST_F(GoogleURLTrackerTest, NavigationsAfterCommittedSearch) { MockSearchDomainCheckResponse("http://www.google.co.jp/"); SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); - GoogleURLTrackerInfoBarDelegate* infobar = GetInfoBar(1); - ASSERT_FALSE(infobar == NULL); + GoogleURLTrackerInfoBarDelegate* delegate = GetInfoBarDelegate(1); + ASSERT_FALSE(delegate == NULL); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); // A pending non-search on a visible infobar should basically do nothing. SetNavigationPending(1, false); - ASSERT_EQ(infobar, GetInfoBar(1)); - EXPECT_EQ(0, infobar->pending_id()); + ASSERT_EQ(delegate, GetInfoBarDelegate(1)); + EXPECT_EQ(0, delegate->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); // As should another pending non-search after the first. SetNavigationPending(1, false); - ASSERT_EQ(infobar, GetInfoBar(1)); - EXPECT_EQ(0, infobar->pending_id()); + ASSERT_EQ(delegate, GetInfoBarDelegate(1)); + EXPECT_EQ(0, delegate->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); // Committing this non-search should close the infobar. The control flow in @@ -980,38 +980,38 @@ TEST_F(GoogleURLTrackerTest, NavigationsAfterCommittedSearch) { // for the search to commit. SetNavigationPending(1, true); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); - infobar = GetInfoBar(1); - ASSERT_FALSE(infobar == NULL); + delegate = GetInfoBarDelegate(1); + ASSERT_FALSE(delegate == NULL); SetNavigationPending(1, true); - ASSERT_EQ(infobar, GetInfoBar(1)); - EXPECT_EQ(1, infobar->pending_id()); + ASSERT_EQ(delegate, GetInfoBarDelegate(1)); + EXPECT_EQ(1, delegate->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); // But a non-search after this should cancel that state. SetNavigationPending(1, false); - ASSERT_EQ(infobar, GetInfoBar(1)); - EXPECT_EQ(0, infobar->pending_id()); + ASSERT_EQ(delegate, GetInfoBarDelegate(1)); + EXPECT_EQ(0, delegate->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); // Another pending search after the non-search should put us back into // "waiting for commit" mode. SetNavigationPending(1, true); - ASSERT_EQ(infobar, GetInfoBar(1)); - EXPECT_EQ(1, infobar->pending_id()); + ASSERT_EQ(delegate, GetInfoBarDelegate(1)); + EXPECT_EQ(1, delegate->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); // A second pending search after the first should not really change anything. SetNavigationPending(1, true); - ASSERT_EQ(infobar, GetInfoBar(1)); - EXPECT_EQ(1, infobar->pending_id()); + ASSERT_EQ(delegate, GetInfoBarDelegate(1)); + EXPECT_EQ(1, delegate->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); // Committing this search should change the visible infobar's search_url. CommitSearch(1, GURL("http://www.google.co.uk/search?q=test2")); - ASSERT_EQ(infobar, GetInfoBar(1)); + ASSERT_EQ(delegate, GetInfoBarDelegate(1)); EXPECT_EQ(GURL("http://www.google.co.uk/search?q=test2"), - infobar->search_url()); - EXPECT_EQ(0, infobar->pending_id()); + delegate->search_url()); + EXPECT_EQ(0, delegate->pending_id()); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), google_url()); EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); @@ -1027,35 +1027,35 @@ TEST_F(GoogleURLTrackerTest, MultipleMapEntries) { SetNavigationPending(1, true); GoogleURLTrackerMapEntry* map_entry = GetMapEntry(1); ASSERT_FALSE(map_entry == NULL); - EXPECT_FALSE(map_entry->has_infobar()); + EXPECT_FALSE(map_entry->has_infobar_delegate()); SetNavigationPending(2, true); CommitSearch(2, GURL("http://www.google.co.uk/search?q=test2")); - GoogleURLTrackerInfoBarDelegate* infobar2 = GetInfoBar(2); - ASSERT_FALSE(infobar2 == NULL); + GoogleURLTrackerInfoBarDelegate* delegate2 = GetInfoBarDelegate(2); + ASSERT_FALSE(delegate2 == NULL); EXPECT_EQ(GURL("http://www.google.co.uk/search?q=test2"), - infobar2->search_url()); + delegate2->search_url()); SetNavigationPending(3, true); GoogleURLTrackerMapEntry* map_entry3 = GetMapEntry(3); ASSERT_FALSE(map_entry3 == NULL); - EXPECT_FALSE(map_entry3->has_infobar()); + EXPECT_FALSE(map_entry3->has_infobar_delegate()); SetNavigationPending(4, true); CommitSearch(4, GURL("http://www.google.co.uk/search?q=test4")); - GoogleURLTrackerInfoBarDelegate* infobar4 = GetInfoBar(4); - ASSERT_FALSE(infobar4 == NULL); + GoogleURLTrackerInfoBarDelegate* delegate4 = GetInfoBarDelegate(4); + ASSERT_FALSE(delegate4 == NULL); EXPECT_EQ(GURL("http://www.google.co.uk/search?q=test4"), - infobar4->search_url()); + delegate4->search_url()); CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); - EXPECT_TRUE(map_entry->has_infobar()); + EXPECT_TRUE(map_entry->has_infobar_delegate()); - infobar2->Close(false); + delegate2->Close(false); EXPECT_TRUE(GetMapEntry(2) == NULL); EXPECT_FALSE(observer_notified()); - infobar4->Accept(); + delegate4->Accept(); EXPECT_TRUE(GetMapEntry(1) == NULL); EXPECT_TRUE(GetMapEntry(3) == NULL); EXPECT_TRUE(GetMapEntry(4) == NULL); @@ -1076,12 +1076,12 @@ TEST_F(GoogleURLTrackerTest, IgnoreIrrelevantNavigation) { CommitSearch(1, GURL("http://www.google.co.uk/search?q=test")); SetNavigationPending(2, true); CommitSearch(2, GURL("http://www.google.co.uk/search?q=test2")); - EXPECT_FALSE(GetInfoBar(1) == NULL); - GoogleURLTrackerInfoBarDelegate* infobar2 = GetInfoBar(2); - ASSERT_FALSE(infobar2 == NULL); + EXPECT_FALSE(GetInfoBarDelegate(1) == NULL); + GoogleURLTrackerInfoBarDelegate* delegate2 = GetInfoBarDelegate(2); + ASSERT_FALSE(delegate2 == NULL); SetNavigationPending(1, true); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); - infobar2->Close(false); + delegate2->Close(false); SetNavigationPending(1, false); ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); } |