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 22 matching lines...) Expand all Loading... |
33 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
34 #include "content/public/test/mock_render_process_host.h" | 34 #include "content/public/test/mock_render_process_host.h" |
35 #include "content/public/test/test_renderer_host.h" | 35 #include "content/public/test/test_renderer_host.h" |
36 #include "content/public/test/test_utils.h" | 36 #include "content/public/test/test_utils.h" |
37 #include "content/public/test/web_contents_tester.h" | 37 #include "content/public/test/web_contents_tester.h" |
38 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
39 | 39 |
40 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
41 #include "base/prefs/pref_service.h" | 41 #include "base/prefs/pref_service.h" |
42 #include "chrome/browser/android/mock_google_location_settings_helper.h" | 42 #include "chrome/browser/android/mock_google_location_settings_helper.h" |
| 43 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" |
43 #endif | 44 #endif |
44 | 45 |
45 #if defined(ENABLE_EXTENSIONS) | 46 #if defined(ENABLE_EXTENSIONS) |
46 #include "extensions/browser/view_type_utils.h" | 47 #include "extensions/browser/view_type_utils.h" |
47 #endif | 48 #endif |
48 | 49 |
49 using content::MockRenderProcessHost; | 50 using content::MockRenderProcessHost; |
50 | 51 |
51 | 52 |
52 // ClosedInfoBarTracker ------------------------------------------------------- | 53 // ClosedInfoBarTracker ------------------------------------------------------- |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 239 |
239 void GeolocationPermissionContextTests::SetUp() { | 240 void GeolocationPermissionContextTests::SetUp() { |
240 ChromeRenderViewHostTestHarness::SetUp(); | 241 ChromeRenderViewHostTestHarness::SetUp(); |
241 | 242 |
242 // Set up required helpers, and make this be as "tabby" as the code requires. | 243 // Set up required helpers, and make this be as "tabby" as the code requires. |
243 #if defined(ENABLE_EXTENSIONS) | 244 #if defined(ENABLE_EXTENSIONS) |
244 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_TAB_CONTENTS); | 245 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_TAB_CONTENTS); |
245 #endif | 246 #endif |
246 InfoBarService::CreateForWebContents(web_contents()); | 247 InfoBarService::CreateForWebContents(web_contents()); |
247 TabSpecificContentSettings::CreateForWebContents(web_contents()); | 248 TabSpecificContentSettings::CreateForWebContents(web_contents()); |
| 249 geolocation_permission_context_ = |
| 250 GeolocationPermissionContextFactory::GetForProfile(profile()); |
248 #if defined(OS_ANDROID) | 251 #if defined(OS_ANDROID) |
| 252 scoped_ptr<GoogleLocationSettingsHelper> helper( |
| 253 new MockGoogleLocationSettingsHelper()); |
| 254 static_cast<GeolocationPermissionContextAndroid*>( |
| 255 geolocation_permission_context_)-> |
| 256 SetGoogleLocationSettingsHelperForTesting(helper.Pass()); |
249 MockGoogleLocationSettingsHelper::SetLocationStatus(true, true); | 257 MockGoogleLocationSettingsHelper::SetLocationStatus(true, true); |
250 #endif | 258 #endif |
251 geolocation_permission_context_ = | |
252 GeolocationPermissionContextFactory::GetForProfile(profile()); | |
253 } | 259 } |
254 | 260 |
255 void GeolocationPermissionContextTests::TearDown() { | 261 void GeolocationPermissionContextTests::TearDown() { |
256 extra_tabs_.clear(); | 262 extra_tabs_.clear(); |
257 ChromeRenderViewHostTestHarness::TearDown(); | 263 ChromeRenderViewHostTestHarness::TearDown(); |
258 } | 264 } |
259 | 265 |
260 // Tests ---------------------------------------------------------------------- | 266 // Tests ---------------------------------------------------------------------- |
261 | 267 |
262 TEST_F(GeolocationPermissionContextTests, SinglePermission) { | 268 TEST_F(GeolocationPermissionContextTests, SinglePermission) { |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 // it is the embedder. | 780 // it is the embedder. |
775 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), | 781 EXPECT_EQ(map->GetLastUsage(requesting_frame_0.GetOrigin(), |
776 requesting_frame_0.GetOrigin(), | 782 requesting_frame_0.GetOrigin(), |
777 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 783 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
778 13); | 784 13); |
779 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), | 785 EXPECT_EQ(map->GetLastUsage(requesting_frame_1.GetOrigin(), |
780 requesting_frame_0.GetOrigin(), | 786 requesting_frame_0.GetOrigin(), |
781 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), | 787 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), |
782 11); | 788 11); |
783 } | 789 } |
OLD | NEW |