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 |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "components/content_settings/core/browser/host_content_settings_map.h" | 29 #include "components/content_settings/core/browser/host_content_settings_map.h" |
30 #include "components/content_settings/core/common/permission_request_id.h" | 30 #include "components/content_settings/core/common/permission_request_id.h" |
31 #include "components/infobars/core/confirm_infobar_delegate.h" | 31 #include "components/infobars/core/confirm_infobar_delegate.h" |
32 #include "components/infobars/core/infobar.h" | 32 #include "components/infobars/core/infobar.h" |
33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
34 #include "content/public/browser/navigation_details.h" | 34 #include "content/public/browser/navigation_details.h" |
35 #include "content/public/browser/navigation_entry.h" | 35 #include "content/public/browser/navigation_entry.h" |
36 #include "content/public/browser/notification_observer.h" | 36 #include "content/public/browser/notification_observer.h" |
37 #include "content/public/browser/notification_registrar.h" | 37 #include "content/public/browser/notification_registrar.h" |
38 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
| 39 #include "content/public/browser/render_frame_host.h" |
39 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
40 #include "content/public/test/mock_render_process_host.h" | 41 #include "content/public/test/mock_render_process_host.h" |
41 #include "content/public/test/test_renderer_host.h" | 42 #include "content/public/test/test_renderer_host.h" |
42 #include "content/public/test/test_utils.h" | 43 #include "content/public/test/test_utils.h" |
43 #include "content/public/test/web_contents_tester.h" | 44 #include "content/public/test/web_contents_tester.h" |
44 #include "testing/gtest/include/gtest/gtest.h" | 45 #include "testing/gtest/include/gtest/gtest.h" |
45 | 46 |
46 #if defined(OS_ANDROID) | 47 #if defined(OS_ANDROID) |
47 #include "base/prefs/pref_service.h" | 48 #include "base/prefs/pref_service.h" |
48 #include "chrome/browser/android/mock_location_settings.h" | 49 #include "chrome/browser/android/mock_location_settings.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 156 |
156 // A map between renderer child id and a pair represending the bridge id and | 157 // A map between renderer child id and a pair represending the bridge id and |
157 // whether the requested permission was allowed. | 158 // whether the requested permission was allowed. |
158 base::hash_map<int, std::pair<int, bool> > responses_; | 159 base::hash_map<int, std::pair<int, bool> > responses_; |
159 }; | 160 }; |
160 | 161 |
161 PermissionRequestID GeolocationPermissionContextTests::RequestID( | 162 PermissionRequestID GeolocationPermissionContextTests::RequestID( |
162 int bridge_id) { | 163 int bridge_id) { |
163 return PermissionRequestID( | 164 return PermissionRequestID( |
164 web_contents()->GetRenderProcessHost()->GetID(), | 165 web_contents()->GetRenderProcessHost()->GetID(), |
165 web_contents()->GetRenderViewHost()->GetRoutingID(), | 166 web_contents()->GetMainFrame()->GetRoutingID(), |
166 bridge_id, | 167 bridge_id, |
167 GURL()); | 168 GURL()); |
168 } | 169 } |
169 | 170 |
170 PermissionRequestID GeolocationPermissionContextTests::RequestIDForTab( | 171 PermissionRequestID GeolocationPermissionContextTests::RequestIDForTab( |
171 int tab, | 172 int tab, |
172 int bridge_id) { | 173 int bridge_id) { |
173 return PermissionRequestID( | 174 return PermissionRequestID( |
174 extra_tabs_[tab]->GetRenderProcessHost()->GetID(), | 175 extra_tabs_[tab]->GetRenderProcessHost()->GetID(), |
175 extra_tabs_[tab]->GetRenderViewHost()->GetRoutingID(), | 176 extra_tabs_[tab]->GetMainFrame()->GetRoutingID(), |
176 bridge_id, | 177 bridge_id, |
177 GURL()); | 178 GURL()); |
178 } | 179 } |
179 | 180 |
180 void GeolocationPermissionContextTests::RequestGeolocationPermission( | 181 void GeolocationPermissionContextTests::RequestGeolocationPermission( |
181 content::WebContents* web_contents, | 182 content::WebContents* web_contents, |
182 const PermissionRequestID& id, | 183 const PermissionRequestID& id, |
183 const GURL& requesting_frame, | 184 const GURL& requesting_frame, |
184 bool user_gesture) { | 185 bool user_gesture) { |
185 geolocation_permission_context_->RequestPermission( | 186 geolocation_permission_context_->RequestPermission( |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 13); | 972 13); |
972 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 973 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
973 requesting_frame_0.GetOrigin(), | 974 requesting_frame_0.GetOrigin(), |
974 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 975 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
975 11); | 976 11); |
976 } | 977 } |
977 | 978 |
978 INSTANTIATE_TEST_CASE_P(GeolocationPermissionContextTestsWithAndWithoutBubbles, | 979 INSTANTIATE_TEST_CASE_P(GeolocationPermissionContextTestsWithAndWithoutBubbles, |
979 GeolocationPermissionContextParamTests, | 980 GeolocationPermissionContextParamTests, |
980 ::testing::Values(false, true)); | 981 ::testing::Values(false, true)); |
OLD | NEW |