| 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 <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
| 14 #include "base/gtest_prod_util.h" |
| 14 #include "base/id_map.h" | 15 #include "base/id_map.h" |
| 15 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
| 16 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 17 #include "base/test/simple_test_clock.h" | 18 #include "base/test/simple_test_clock.h" |
| 18 #include "base/time/clock.h" | 19 #include "base/time/clock.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 21 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 21 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 22 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 22 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" | 23 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" |
| 23 #include "chrome/browser/infobars/infobar_service.h" | 24 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 183 |
| 183 void GeolocationPermissionContextTests::RequestGeolocationPermission( | 184 void GeolocationPermissionContextTests::RequestGeolocationPermission( |
| 184 content::WebContents* web_contents, | 185 content::WebContents* web_contents, |
| 185 const PermissionRequestID& id, | 186 const PermissionRequestID& id, |
| 186 const GURL& requesting_frame, | 187 const GURL& requesting_frame, |
| 187 bool user_gesture) { | 188 bool user_gesture) { |
| 188 geolocation_permission_context_->RequestPermission( | 189 geolocation_permission_context_->RequestPermission( |
| 189 web_contents, id, requesting_frame, user_gesture, | 190 web_contents, id, requesting_frame, user_gesture, |
| 190 base::Bind(&GeolocationPermissionContextTests::PermissionResponse, | 191 base::Bind(&GeolocationPermissionContextTests::PermissionResponse, |
| 191 base::Unretained(this), id)); | 192 base::Unretained(this), id)); |
| 192 content::RunAllBlockingPoolTasksUntilIdle(); | 193 content::RunAllBlockingPoolTasksUntilIdle(); |
| 193 } | 194 } |
| 194 | 195 |
| 195 void GeolocationPermissionContextTests::PermissionResponse( | 196 void GeolocationPermissionContextTests::PermissionResponse( |
| 196 const PermissionRequestID& id, | 197 const PermissionRequestID& id, |
| 197 ContentSetting content_setting) { | 198 ContentSetting content_setting) { |
| 198 responses_[id.render_process_id()] = | 199 responses_[id.render_process_id()] = |
| 199 std::make_pair(id.request_id(), content_setting == CONTENT_SETTING_ALLOW); | 200 std::make_pair(id.request_id(), content_setting == CONTENT_SETTING_ALLOW); |
| 200 } | 201 } |
| 201 | 202 |
| 202 void GeolocationPermissionContextTests::CheckPermissionMessageSent( | 203 void GeolocationPermissionContextTests::CheckPermissionMessageSent( |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 // it is the embedder. | 954 // it is the embedder. |
| 954 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), | 955 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), |
| 955 requesting_frame_0.GetOrigin(), | 956 requesting_frame_0.GetOrigin(), |
| 956 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 957 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 957 13); | 958 13); |
| 958 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 959 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
| 959 requesting_frame_0.GetOrigin(), | 960 requesting_frame_0.GetOrigin(), |
| 960 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 961 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
| 961 11); | 962 11); |
| 962 } | 963 } |
| OLD | NEW |