summaryrefslogtreecommitdiffstats
path: root/chrome/browser/geolocation
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-11 01:16:23 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-11 01:16:23 +0000
commit591a59fe61d07d04b99d333628e23c73f528fa6e (patch)
tree0c3208fa9cdb5286797f5a76f66ed24607502194 /chrome/browser/geolocation
parent0ec7e6de19679a0bb0254b71ccfc95c40ec99cf0 (diff)
downloadchromium_src-591a59fe61d07d04b99d333628e23c73f528fa6e.zip
chromium_src-591a59fe61d07d04b99d333628e23c73f528fa6e.tar.gz
chromium_src-591a59fe61d07d04b99d333628e23c73f528fa6e.tar.bz2
Switch InfoBarTabHelper to use WebContentsUserData.
BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11030045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161255 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation')
-rw-r--r--chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc52
-rw-r--r--chrome/browser/geolocation/geolocation_browsertest.cc7
-rw-r--r--chrome/browser/geolocation/geolocation_infobar_queue_controller.cc8
3 files changed, 34 insertions, 33 deletions
diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
index 29bfe1f..e7a8a79 100644
--- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
+++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tab_contents/test_tab_contents.h"
+#include "chrome/browser/view_type_utils.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/navigation_details.h"
@@ -106,16 +107,18 @@ class GeolocationPermissionContextTests : public TabContentsTestHarness {
return contents()->GetRenderProcessHost()->GetID();
}
int process_id_for_tab(int tab) {
- return extra_tabs_[tab]->web_contents()->GetRenderProcessHost()->GetID();
+ return extra_tabs_[tab]->GetRenderProcessHost()->GetID();
}
int render_id() { return contents()->GetRenderViewHost()->GetRoutingID(); }
int render_id_for_tab(int tab) {
- return extra_tabs_[tab]->web_contents()->
- GetRenderViewHost()->GetRoutingID();
+ return extra_tabs_[tab]->GetRenderViewHost()->GetRoutingID();
}
int bridge_id() const { return 42; } // Not relevant at this level.
InfoBarTabHelper* infobar_tab_helper() {
- return tab_contents()->infobar_tab_helper();
+ return InfoBarTabHelper::FromWebContents(web_contents());
+ }
+ InfoBarTabHelper* infobar_tab_helper_for_tab(int tab) {
+ return InfoBarTabHelper::FromWebContents(extra_tabs_[tab]);
}
void RequestGeolocationPermission(int render_process_id,
@@ -138,7 +141,7 @@ class GeolocationPermissionContextTests : public TabContentsTestHarness {
scoped_refptr<ChromeGeolocationPermissionContext>
geolocation_permission_context_;
ClosedDelegateTracker closed_delegate_tracker_;
- ScopedVector<TabContents> extra_tabs_;
+ ScopedVector<WebContents> extra_tabs_;
private:
// TabContentsTestHarness:
@@ -195,7 +198,7 @@ void GeolocationPermissionContextTests::CheckPermissionMessageSentForTab(
int bridge_id,
bool allowed) {
CheckPermissionMessageSentInternal(static_cast<MockRenderProcessHost*>(
- extra_tabs_[tab]->web_contents()->GetRenderProcessHost()),
+ extra_tabs_[tab]->GetRenderProcessHost()),
bridge_id, allowed);
}
@@ -216,7 +219,12 @@ void GeolocationPermissionContextTests::AddNewTab(const GURL& url) {
url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
RenderViewHostTester::For(new_tab->GetRenderViewHost())->
SendNavigate(extra_tabs_.size() + 1, url);
- extra_tabs_.push_back(TabContents::Factory::CreateTabContents(new_tab));
+
+ // Set up required helpers, and make this be as "tabby" as the code requires.
+ chrome::SetViewType(new_tab, chrome::VIEW_TYPE_TAB_CONTENTS);
+ InfoBarTabHelper::CreateForWebContents(new_tab);
+
+ extra_tabs_.push_back(new_tab);
}
void GeolocationPermissionContextTests::CheckTabContentsState(
@@ -472,14 +480,14 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) {
RequestGeolocationPermission(
process_id_for_tab(0), render_id_for_tab(0), bridge_id(), url_b);
- EXPECT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount());
+ EXPECT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount());
RequestGeolocationPermission(
process_id_for_tab(1), render_id_for_tab(1), bridge_id(), url_a);
- ASSERT_EQ(1U, extra_tabs_[1]->infobar_tab_helper()->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_tab_helper_for_tab(1)->GetInfoBarCount());
- ConfirmInfoBarDelegate* removed_infobar = extra_tabs_[1]->
- infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ ConfirmInfoBarDelegate* removed_infobar = infobar_tab_helper_for_tab(1)->
+ GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
// Accept the first tab.
ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()->
@@ -492,7 +500,7 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) {
EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0));
infobar_0->InfoBarClosed();
// Now the infobar for the tab with the same origin should have gone.
- EXPECT_EQ(0U, extra_tabs_[1]->infobar_tab_helper()->GetInfoBarCount());
+ EXPECT_EQ(0U, infobar_tab_helper_for_tab(1)->GetInfoBarCount());
CheckPermissionMessageSentForTab(1, bridge_id(), true);
EXPECT_TRUE(closed_delegate_tracker_.Contains(removed_infobar));
closed_delegate_tracker_.Clear();
@@ -500,11 +508,11 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) {
removed_infobar->InfoBarClosed();
// But the other tab should still have the info bar...
- ASSERT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount());
- ConfirmInfoBarDelegate* infobar_1 = extra_tabs_[0]->infobar_tab_helper()->
+ ASSERT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount());
+ ConfirmInfoBarDelegate* infobar_1 = infobar_tab_helper_for_tab(0)->
GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
infobar_1->Cancel();
- extra_tabs_[0]->infobar_tab_helper()->RemoveInfoBar(infobar_1);
+ infobar_tab_helper_for_tab(0)->RemoveInfoBar(infobar_1);
EXPECT_EQ(1U, closed_delegate_tracker_.size());
EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1));
infobar_1->InfoBarClosed();
@@ -523,22 +531,22 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
RequestGeolocationPermission(
process_id_for_tab(0), render_id_for_tab(0), bridge_id(), url_a);
- EXPECT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount());
+ EXPECT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount());
RequestGeolocationPermission(
process_id_for_tab(0), render_id_for_tab(0), bridge_id() + 1, url_b);
- ASSERT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount());
ConfirmInfoBarDelegate* removed_infobar =
infobar_tab_helper()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
// Accept the second tab.
- ConfirmInfoBarDelegate* infobar_0 = extra_tabs_[0]->infobar_tab_helper()->
+ ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper_for_tab(0)->
GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(infobar_0);
infobar_0->Accept();
CheckPermissionMessageSentForTab(0, bridge_id(), true);
- extra_tabs_[0]->infobar_tab_helper()->RemoveInfoBar(infobar_0);
+ infobar_tab_helper_for_tab(0)->RemoveInfoBar(infobar_0);
EXPECT_EQ(2U, closed_delegate_tracker_.size());
EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_0));
infobar_0->InfoBarClosed();
@@ -551,15 +559,15 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
removed_infobar->InfoBarClosed();
// And we should have the queued infobar displayed now.
- ASSERT_EQ(1U, extra_tabs_[0]->infobar_tab_helper()->GetInfoBarCount());
+ ASSERT_EQ(1U, infobar_tab_helper_for_tab(0)->GetInfoBarCount());
// Accept the second infobar.
- ConfirmInfoBarDelegate* infobar_1 = extra_tabs_[0]->infobar_tab_helper()->
+ ConfirmInfoBarDelegate* infobar_1 = infobar_tab_helper_for_tab(0)->
GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(infobar_1);
infobar_1->Accept();
CheckPermissionMessageSentForTab(0, bridge_id() + 1, true);
- extra_tabs_[0]->infobar_tab_helper()->RemoveInfoBar(infobar_1);
+ infobar_tab_helper_for_tab(0)->RemoveInfoBar(infobar_1);
EXPECT_EQ(1U, closed_delegate_tracker_.size());
EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1));
infobar_1->InfoBarClosed();
diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc
index 321dd60..af036f7 100644
--- a/chrome/browser/geolocation/geolocation_browsertest.cc
+++ b/chrome/browser/geolocation/geolocation_browsertest.cc
@@ -310,8 +310,7 @@ class GeolocationBrowserTest : public InProcessBrowserTest {
observer.Wait();
}
- TabContents* tab_contents = TabContents::FromWebContents(web_contents);
- tab_contents->infobar_tab_helper()->RemoveInfoBar(infobar_);
+ InfoBarTabHelper::FromWebContents(web_contents)->RemoveInfoBar(infobar_);
LOG(WARNING) << "infobar response set";
infobar_ = NULL;
EXPECT_GT(settings_state.state_map().size(), state_map_size);
@@ -567,8 +566,8 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest,
iframe_xpath_ = L"//iframe[@id='iframe_1']";
AddGeolocationWatch(true);
- InfoBarTabHelper* infobar_helper =
- chrome::GetActiveTabContents(current_browser_)->infobar_tab_helper();
+ InfoBarTabHelper* infobar_helper = InfoBarTabHelper::FromWebContents(
+ chrome::GetActiveWebContents(current_browser_));
size_t num_infobars_before_cancel = infobar_helper->GetInfoBarCount();
// Change the iframe, and ensure the infobar is gone.
IFrameLoader change_iframe_1(current_browser_, 1, current_url_);
diff --git a/chrome/browser/geolocation/geolocation_infobar_queue_controller.cc b/chrome/browser/geolocation/geolocation_infobar_queue_controller.cc
index ad8d49e..f991761 100644
--- a/chrome/browser/geolocation/geolocation_infobar_queue_controller.cc
+++ b/chrome/browser/geolocation/geolocation_infobar_queue_controller.cc
@@ -12,7 +12,6 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/tab_util.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/content_settings.h"
#include "chrome/common/pref_names.h"
@@ -454,12 +453,7 @@ InfoBarTabHelper* GeolocationInfoBarQueueController::GetInfoBarHelper(
int render_view_id) {
WebContents* web_contents =
tab_util::GetWebContentsByID(render_process_id, render_view_id);
- if (!web_contents)
- return NULL;
- TabContents* tab_contents = TabContents::FromWebContents(web_contents);
- if (!tab_contents)
- return NULL;
- return tab_contents->infobar_tab_helper();
+ return web_contents ? InfoBarTabHelper::FromWebContents(web_contents) : NULL;
}
bool GeolocationInfoBarQueueController::AlreadyShowingInfoBar(