| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "chrome/browser/content_settings/host_content_settings_map.h" | 12 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 14 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" | 14 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
| 15 #include "chrome/browser/infobars/infobar.h" | 15 #include "chrome/browser/infobars/infobar.h" |
| 16 #include "chrome/browser/infobars/infobar_tab_helper.h" | 16 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 17 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 17 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 19 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 22 #include "content/browser/renderer_host/mock_render_process_host.h" | 22 #include "content/browser/renderer_host/mock_render_process_host.h" |
| 23 #include "content/browser/tab_contents/test_tab_contents.h" | 23 #include "content/browser/tab_contents/test_tab_contents.h" |
| 24 #include "content/public/browser/navigation_details.h" | 24 #include "content/public/browser/navigation_details.h" |
| 25 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
| 26 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 27 #include "content/test/mock_geolocation.h" | 27 #include "content/test/mock_geolocation.h" |
| 28 #include "content/test/test_browser_thread.h" | 28 #include "content/test/test_browser_thread.h" |
| 29 #include "content/test/test_renderer_host.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 31 |
| 31 using content::BrowserThread; | 32 using content::BrowserThread; |
| 33 using content::RenderViewHostTester; |
| 32 using content::WebContents; | 34 using content::WebContents; |
| 33 | 35 |
| 34 // ClosedDelegateTracker ------------------------------------------------------ | 36 // ClosedDelegateTracker ------------------------------------------------------ |
| 35 | 37 |
| 36 namespace { | 38 namespace { |
| 37 | 39 |
| 38 // We need to track which infobars were closed. | 40 // We need to track which infobars were closed. |
| 39 class ClosedDelegateTracker : public content::NotificationObserver { | 41 class ClosedDelegateTracker : public content::NotificationObserver { |
| 40 public: | 42 public: |
| 41 ClosedDelegateTracker(); | 43 ClosedDelegateTracker(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 EXPECT_EQ(bridge_id, responses_[process->GetID()].first); | 202 EXPECT_EQ(bridge_id, responses_[process->GetID()].first); |
| 201 EXPECT_EQ(allowed, responses_[process->GetID()].second); | 203 EXPECT_EQ(allowed, responses_[process->GetID()].second); |
| 202 responses_.erase(process->GetID()); | 204 responses_.erase(process->GetID()); |
| 203 } | 205 } |
| 204 | 206 |
| 205 void GeolocationPermissionContextTests::AddNewTab(const GURL& url) { | 207 void GeolocationPermissionContextTests::AddNewTab(const GURL& url) { |
| 206 WebContents* new_tab = | 208 WebContents* new_tab = |
| 207 WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); | 209 WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); |
| 208 new_tab->GetController().LoadURL( | 210 new_tab->GetController().LoadURL( |
| 209 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 211 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
| 210 static_cast<content::TestRenderViewHost*>(new_tab->GetRenderViewHost())-> | 212 RenderViewHostTester::For(new_tab->GetRenderViewHost())-> |
| 211 SendNavigate(extra_tabs_.size() + 1, url); | 213 SendNavigate(extra_tabs_.size() + 1, url); |
| 212 extra_tabs_.push_back(new TabContentsWrapper(new_tab)); | 214 extra_tabs_.push_back(new TabContentsWrapper(new_tab)); |
| 213 } | 215 } |
| 214 | 216 |
| 215 void GeolocationPermissionContextTests::CheckTabContentsState( | 217 void GeolocationPermissionContextTests::CheckTabContentsState( |
| 216 const GURL& requesting_frame, | 218 const GURL& requesting_frame, |
| 217 ContentSetting expected_content_setting) { | 219 ContentSetting expected_content_setting) { |
| 218 TabSpecificContentSettings* content_settings = | 220 TabSpecificContentSettings* content_settings = |
| 219 contents_wrapper()->content_settings(); | 221 contents_wrapper()->content_settings(); |
| 220 const GeolocationSettingsState::StateMap& state_map = | 222 const GeolocationSettingsState::StateMap& state_map = |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 ASSERT_FALSE(infobar_0->ShouldExpire(details)); | 590 ASSERT_FALSE(infobar_0->ShouldExpire(details)); |
| 589 // Commit the "GoBack()" above, and ensure the infobar is now expired. | 591 // Commit the "GoBack()" above, and ensure the infobar is now expired. |
| 590 contents()->CommitPendingNavigation(); | 592 contents()->CommitPendingNavigation(); |
| 591 details.entry = contents()->GetController().GetLastCommittedEntry(); | 593 details.entry = contents()->GetController().GetLastCommittedEntry(); |
| 592 ASSERT_TRUE(infobar_0->ShouldExpire(details)); | 594 ASSERT_TRUE(infobar_0->ShouldExpire(details)); |
| 593 | 595 |
| 594 // Delete the tab contents. | 596 // Delete the tab contents. |
| 595 DeleteContents(); | 597 DeleteContents(); |
| 596 infobar_0->InfoBarClosed(); | 598 infobar_0->InfoBarClosed(); |
| 597 } | 599 } |
| OLD | NEW |