| 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 28 matching lines...) Expand all Loading... |
| 39 #include "content/public/browser/notification_observer.h" | 39 #include "content/public/browser/notification_observer.h" |
| 40 #include "content/public/browser/notification_registrar.h" | 40 #include "content/public/browser/notification_registrar.h" |
| 41 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
| 42 #include "content/public/browser/render_frame_host.h" | 42 #include "content/public/browser/render_frame_host.h" |
| 43 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
| 44 #include "content/public/test/mock_render_process_host.h" | 44 #include "content/public/test/mock_render_process_host.h" |
| 45 #include "content/public/test/test_renderer_host.h" | 45 #include "content/public/test/test_renderer_host.h" |
| 46 #include "content/public/test/test_utils.h" | 46 #include "content/public/test/test_utils.h" |
| 47 #include "content/public/test/web_contents_tester.h" | 47 #include "content/public/test/web_contents_tester.h" |
| 48 #include "testing/gtest/include/gtest/gtest.h" | 48 #include "testing/gtest/include/gtest/gtest.h" |
| 49 #include "url/origin.h" |
| 49 | 50 |
| 50 #if BUILDFLAG(ANDROID_JAVA_UI) | 51 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 51 #include "chrome/browser/android/mock_location_settings.h" | 52 #include "chrome/browser/android/mock_location_settings.h" |
| 52 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" | 53 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" |
| 53 #include "components/prefs/pref_service.h" | 54 #include "components/prefs/pref_service.h" |
| 54 #else | 55 #else |
| 55 #include "chrome/browser/ui/website_settings/mock_permission_bubble_factory.h" | 56 #include "chrome/browser/ui/website_settings/mock_permission_bubble_factory.h" |
| 56 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 57 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
| 57 #endif | 58 #endif |
| 58 | 59 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 extra_tabs_[tab]->GetRenderProcessHost()->GetID(), | 189 extra_tabs_[tab]->GetRenderProcessHost()->GetID(), |
| 189 extra_tabs_[tab]->GetMainFrame()->GetRoutingID(), | 190 extra_tabs_[tab]->GetMainFrame()->GetRoutingID(), |
| 190 request_id); | 191 request_id); |
| 191 } | 192 } |
| 192 | 193 |
| 193 void GeolocationPermissionContextTests::RequestGeolocationPermission( | 194 void GeolocationPermissionContextTests::RequestGeolocationPermission( |
| 194 content::WebContents* web_contents, | 195 content::WebContents* web_contents, |
| 195 const PermissionRequestID& id, | 196 const PermissionRequestID& id, |
| 196 const GURL& requesting_frame) { | 197 const GURL& requesting_frame) { |
| 197 geolocation_permission_context_->RequestPermission( | 198 geolocation_permission_context_->RequestPermission( |
| 198 web_contents, id, requesting_frame, | 199 web_contents, id, url::Origin(requesting_frame), |
| 199 base::Bind(&GeolocationPermissionContextTests::PermissionResponse, | 200 base::Bind(&GeolocationPermissionContextTests::PermissionResponse, |
| 200 base::Unretained(this), id)); | 201 base::Unretained(this), id)); |
| 201 content::RunAllBlockingPoolTasksUntilIdle(); | 202 content::RunAllBlockingPoolTasksUntilIdle(); |
| 202 } | 203 } |
| 203 | 204 |
| 204 void GeolocationPermissionContextTests::PermissionResponse( | 205 void GeolocationPermissionContextTests::PermissionResponse( |
| 205 const PermissionRequestID& id, | 206 const PermissionRequestID& id, |
| 206 ContentSetting content_setting) { | 207 ContentSetting content_setting) { |
| 207 responses_[id.render_process_id()] = | 208 responses_[id.render_process_id()] = |
| 208 std::make_pair(id.request_id(), content_setting == CONTENT_SETTING_ALLOW); | 209 std::make_pair(id.request_id(), content_setting == CONTENT_SETTING_ALLOW); |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 // it is the embedder. | 971 // it is the embedder. |
| 971 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), | 972 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), |
| 972 requesting_frame_0.GetOrigin(), | 973 requesting_frame_0.GetOrigin(), |
| 973 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 974 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 974 13); | 975 13); |
| 975 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 976 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
| 976 requesting_frame_0.GetOrigin(), | 977 requesting_frame_0.GetOrigin(), |
| 977 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 978 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 978 11); | 979 11); |
| 979 } | 980 } |
| OLD | NEW |