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 "chrome/browser/geolocation/geolocation_permission_context.h" | 5 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "content/public/browser/navigation_entry.h" | 41 #include "content/public/browser/navigation_entry.h" |
42 #include "content/public/browser/notification_observer.h" | 42 #include "content/public/browser/notification_observer.h" |
43 #include "content/public/browser/notification_registrar.h" | 43 #include "content/public/browser/notification_registrar.h" |
44 #include "content/public/browser/notification_service.h" | 44 #include "content/public/browser/notification_service.h" |
45 #include "content/public/browser/render_frame_host.h" | 45 #include "content/public/browser/render_frame_host.h" |
46 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
47 #include "content/public/test/mock_render_process_host.h" | 47 #include "content/public/test/mock_render_process_host.h" |
48 #include "content/public/test/test_renderer_host.h" | 48 #include "content/public/test/test_renderer_host.h" |
49 #include "content/public/test/test_utils.h" | 49 #include "content/public/test/test_utils.h" |
50 #include "content/public/test/web_contents_tester.h" | 50 #include "content/public/test/web_contents_tester.h" |
| 51 #include "extensions/features/features.h" |
51 #include "testing/gtest/include/gtest/gtest.h" | 52 #include "testing/gtest/include/gtest/gtest.h" |
52 | 53 |
53 #if BUILDFLAG(ANDROID_JAVA_UI) | 54 #if BUILDFLAG(ANDROID_JAVA_UI) |
54 #include "chrome/browser/android/mock_location_settings.h" | 55 #include "chrome/browser/android/mock_location_settings.h" |
55 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" | 56 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" |
56 #include "components/prefs/pref_service.h" | 57 #include "components/prefs/pref_service.h" |
57 #else | 58 #else |
58 #include "chrome/browser/permissions/permission_request_manager.h" | 59 #include "chrome/browser/permissions/permission_request_manager.h" |
59 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h" | 60 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h" |
60 #endif | 61 #endif |
61 | 62 |
62 #if defined(ENABLE_EXTENSIONS) | 63 #if BUILDFLAG(ENABLE_EXTENSIONS) |
63 #include "extensions/browser/view_type_utils.h" | 64 #include "extensions/browser/view_type_utils.h" |
64 #endif | 65 #endif |
65 | 66 |
66 using content::MockRenderProcessHost; | 67 using content::MockRenderProcessHost; |
67 | 68 |
68 | 69 |
69 // ClosedInfoBarTracker ------------------------------------------------------- | 70 // ClosedInfoBarTracker ------------------------------------------------------- |
70 | 71 |
71 // We need to track which infobars were closed. | 72 // We need to track which infobars were closed. |
72 class ClosedInfoBarTracker : public content::NotificationObserver { | 73 class ClosedInfoBarTracker : public content::NotificationObserver { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 241 |
241 void GeolocationPermissionContextTests::AddNewTab(const GURL& url) { | 242 void GeolocationPermissionContextTests::AddNewTab(const GURL& url) { |
242 content::WebContents* new_tab = CreateTestWebContents(); | 243 content::WebContents* new_tab = CreateTestWebContents(); |
243 new_tab->GetController().LoadURL( | 244 new_tab->GetController().LoadURL( |
244 url, content::Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 245 url, content::Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
245 content::NavigationEntry* entry = new_tab->GetController().GetPendingEntry(); | 246 content::NavigationEntry* entry = new_tab->GetController().GetPendingEntry(); |
246 content::RenderFrameHostTester::For(new_tab->GetMainFrame()) | 247 content::RenderFrameHostTester::For(new_tab->GetMainFrame()) |
247 ->SendNavigate(entry->GetUniqueID(), true, url); | 248 ->SendNavigate(entry->GetUniqueID(), true, url); |
248 | 249 |
249 // Set up required helpers, and make this be as "tabby" as the code requires. | 250 // Set up required helpers, and make this be as "tabby" as the code requires. |
250 #if defined(ENABLE_EXTENSIONS) | 251 #if BUILDFLAG(ENABLE_EXTENSIONS) |
251 extensions::SetViewType(new_tab, extensions::VIEW_TYPE_TAB_CONTENTS); | 252 extensions::SetViewType(new_tab, extensions::VIEW_TYPE_TAB_CONTENTS); |
252 #endif | 253 #endif |
253 | 254 |
254 #if BUILDFLAG(ANDROID_JAVA_UI) | 255 #if BUILDFLAG(ANDROID_JAVA_UI) |
255 InfoBarService::CreateForWebContents(new_tab); | 256 InfoBarService::CreateForWebContents(new_tab); |
256 #else | 257 #else |
257 SetupRequestManager(new_tab); | 258 SetupRequestManager(new_tab); |
258 #endif | 259 #endif |
259 | 260 |
260 extra_tabs_.push_back(base::WrapUnique(new_tab)); | 261 extra_tabs_.push_back(base::WrapUnique(new_tab)); |
(...skipping 12 matching lines...) Expand all Loading... |
273 state_map.find(requesting_frame.GetOrigin()); | 274 state_map.find(requesting_frame.GetOrigin()); |
274 ASSERT_FALSE(settings == state_map.end()) | 275 ASSERT_FALSE(settings == state_map.end()) |
275 << "geolocation state not found " << requesting_frame; | 276 << "geolocation state not found " << requesting_frame; |
276 EXPECT_EQ(expected_content_setting, settings->second); | 277 EXPECT_EQ(expected_content_setting, settings->second); |
277 } | 278 } |
278 | 279 |
279 void GeolocationPermissionContextTests::SetUp() { | 280 void GeolocationPermissionContextTests::SetUp() { |
280 ChromeRenderViewHostTestHarness::SetUp(); | 281 ChromeRenderViewHostTestHarness::SetUp(); |
281 | 282 |
282 // Set up required helpers, and make this be as "tabby" as the code requires. | 283 // Set up required helpers, and make this be as "tabby" as the code requires. |
283 #if defined(ENABLE_EXTENSIONS) | 284 #if BUILDFLAG(ENABLE_EXTENSIONS) |
284 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_TAB_CONTENTS); | 285 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_TAB_CONTENTS); |
285 #endif | 286 #endif |
286 InfoBarService::CreateForWebContents(web_contents()); | 287 InfoBarService::CreateForWebContents(web_contents()); |
287 TabSpecificContentSettings::CreateForWebContents(web_contents()); | 288 TabSpecificContentSettings::CreateForWebContents(web_contents()); |
288 geolocation_permission_context_ = static_cast<GeolocationPermissionContext*>( | 289 geolocation_permission_context_ = static_cast<GeolocationPermissionContext*>( |
289 PermissionManager::Get(profile())->GetPermissionContext( | 290 PermissionManager::Get(profile())->GetPermissionContext( |
290 content::PermissionType::GEOLOCATION)); | 291 content::PermissionType::GEOLOCATION)); |
291 #if BUILDFLAG(ANDROID_JAVA_UI) | 292 #if BUILDFLAG(ANDROID_JAVA_UI) |
292 static_cast<GeolocationPermissionContextAndroid*>( | 293 static_cast<GeolocationPermissionContextAndroid*>( |
293 geolocation_permission_context_) | 294 geolocation_permission_context_) |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 // it is the embedder. | 1001 // it is the embedder. |
1001 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), | 1002 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), |
1002 requesting_frame_0.GetOrigin(), | 1003 requesting_frame_0.GetOrigin(), |
1003 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 1004 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
1004 13); | 1005 13); |
1005 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 1006 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
1006 requesting_frame_0.GetOrigin(), | 1007 requesting_frame_0.GetOrigin(), |
1007 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 1008 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
1008 11); | 1009 11); |
1009 } | 1010 } |
OLD | NEW |