| Index: chrome/browser/geolocation/geolocation_permission_context_unittest.cc
|
| diff --git a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
|
| index 9ae3a305414dee56dd96abfacef9508e28c93f37..220a158a05b1b83704ceeb8b1e623cb8b780564f 100644
|
| --- a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
|
| +++ b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
|
| @@ -103,6 +103,7 @@ void ClosedInfoBarTracker::Clear() {
|
| class GeolocationPermissionContextTests
|
| : public ChromeRenderViewHostTestHarness {
|
| protected:
|
| +
|
| // ChromeRenderViewHostTestHarness:
|
| virtual void SetUp() OVERRIDE;
|
| virtual void TearDown() OVERRIDE;
|
| @@ -119,10 +120,7 @@ class GeolocationPermissionContextTests
|
| void RequestGeolocationPermission(content::WebContents* web_contents,
|
| const PermissionRequestID& id,
|
| const GURL& requesting_frame);
|
| - void RequestGeolocationPermission(content::WebContents* web_contents,
|
| - const PermissionRequestID& id,
|
| - const GURL& requesting_frame,
|
| - base::Closure* cancel_callback);
|
| +
|
| void PermissionResponse(const PermissionRequestID& id,
|
| bool allowed);
|
| void CheckPermissionMessageSent(int bridge_id, bool allowed);
|
| @@ -134,7 +132,8 @@ class GeolocationPermissionContextTests
|
| void CheckTabContentsState(const GURL& requesting_frame,
|
| ContentSetting expected_content_setting);
|
|
|
| - scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_;
|
| + // owned by the browser context
|
| + GeolocationPermissionContext* geolocation_permission_context_;
|
| ClosedInfoBarTracker closed_infobar_tracker_;
|
| ScopedVector<content::WebContents> extra_tabs_;
|
|
|
| @@ -166,19 +165,10 @@ void GeolocationPermissionContextTests::RequestGeolocationPermission(
|
| content::WebContents* web_contents,
|
| const PermissionRequestID& id,
|
| const GURL& requesting_frame) {
|
| - RequestGeolocationPermission(web_contents, id, requesting_frame, NULL);
|
| -}
|
| -
|
| -void GeolocationPermissionContextTests::RequestGeolocationPermission(
|
| - content::WebContents* web_contents,
|
| - const PermissionRequestID& id,
|
| - const GURL& requesting_frame,
|
| - base::Closure* cancel_callback) {
|
| - geolocation_permission_context_->RequestGeolocationPermission(
|
| - web_contents, id.bridge_id(), requesting_frame, false,
|
| + geolocation_permission_context_->RequestPermission(
|
| + web_contents, id, requesting_frame, false,
|
| base::Bind(&GeolocationPermissionContextTests::PermissionResponse,
|
| - base::Unretained(this), id),
|
| - cancel_callback);
|
| + base::Unretained(this), id));
|
| content::BrowserThread::GetBlockingPool()->FlushForTesting();
|
| base::RunLoop().RunUntilIdle();
|
| }
|
| @@ -467,10 +457,10 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) {
|
|
|
| NavigateAndCommit(requesting_frame_0);
|
| EXPECT_EQ(0U, infobar_service()->infobar_count());
|
| +
|
| // Request permission for two frames.
|
| - base::Closure cancel_callback;
|
| RequestGeolocationPermission(
|
| - web_contents(), RequestID(0), requesting_frame_0, &cancel_callback);
|
| + web_contents(), RequestID(0), requesting_frame_0);
|
| RequestGeolocationPermission(
|
| web_contents(), RequestID(1), requesting_frame_1);
|
| ASSERT_EQ(1U, infobar_service()->infobar_count());
|
| @@ -481,9 +471,10 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) {
|
| ASSERT_TRUE(infobar_delegate_0);
|
| base::string16 text_0 = infobar_delegate_0->GetMessageText();
|
|
|
| - // Simulate the frame going away, ensure the infobar for this frame
|
| + // Simulate the first frame going away, ensure the infobar for this frame
|
| // is removed and the next pending infobar is created.
|
| - cancel_callback.Run();
|
| + geolocation_permission_context_->CancelPermissionRequest(web_contents(),
|
| + RequestID(0));
|
| EXPECT_EQ(1U, closed_infobar_tracker_.size());
|
| EXPECT_TRUE(closed_infobar_tracker_.Contains(infobar_0));
|
| closed_infobar_tracker_.Clear();
|
| @@ -656,37 +647,6 @@ TEST_F(GeolocationPermissionContextTests, TabDestroyed) {
|
| ASSERT_TRUE(closed_infobar_tracker_.Contains(infobar));
|
| }
|
|
|
| -TEST_F(GeolocationPermissionContextTests, InfoBarUsesCommittedEntry) {
|
| - GURL requesting_frame_0("http://www.example.com/geolocation");
|
| - GURL requesting_frame_1("http://www.example-2.com/geolocation");
|
| - NavigateAndCommit(requesting_frame_0);
|
| - NavigateAndCommit(requesting_frame_1);
|
| - EXPECT_EQ(0U, infobar_service()->infobar_count());
|
| - // Go back: navigate to a pending entry before requesting geolocation
|
| - // permission.
|
| - web_contents()->GetController().GoBack();
|
| - // Request permission for the committed frame (not the pending one).
|
| - RequestGeolocationPermission(
|
| - web_contents(), RequestID(0), requesting_frame_1);
|
| - // Ensure the infobar is created.
|
| - ASSERT_EQ(1U, infobar_service()->infobar_count());
|
| - infobars::InfoBarDelegate* infobar_delegate =
|
| - infobar_service()->infobar_at(0)->delegate();
|
| - ASSERT_TRUE(infobar_delegate);
|
| - // Ensure the infobar wouldn't expire for a navigation to the committed entry.
|
| - content::LoadCommittedDetails details;
|
| - details.entry = web_contents()->GetController().GetLastCommittedEntry();
|
| - EXPECT_FALSE(infobar_delegate->ShouldExpire(
|
| - InfoBarService::NavigationDetailsFromLoadCommittedDetails(details)));
|
| - // Ensure the infobar will expire when we commit the pending navigation.
|
| - details.entry = web_contents()->GetController().GetActiveEntry();
|
| - EXPECT_TRUE(infobar_delegate->ShouldExpire(
|
| - InfoBarService::NavigationDetailsFromLoadCommittedDetails(details)));
|
| -
|
| - // Delete the tab contents.
|
| - DeleteContents();
|
| -}
|
| -
|
| TEST_F(GeolocationPermissionContextTests, LastUsageAudited) {
|
| GURL requesting_frame("http://www.example.com/geolocation");
|
| NavigateAndCommit(requesting_frame);
|
| @@ -722,8 +682,8 @@ TEST_F(GeolocationPermissionContextTests, LastUsageAudited) {
|
| 10);
|
|
|
| test_clock->Advance(base::TimeDelta::FromSeconds(3));
|
| - RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame);
|
|
|
| + RequestGeolocationPermission(web_contents(), RequestID(0), requesting_frame);
|
| // Permission has been used three seconds later.
|
| EXPECT_EQ(map->GetLastUsage(requesting_frame.GetOrigin(),
|
| requesting_frame.GetOrigin(),
|
|
|