| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/permissions/permission_manager.h" | 5 #include "chrome/browser/permissions/permission_manager.h" |
| 6 | 6 |
| 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 7 #include "chrome/browser/permissions/permission_manager_factory.h" | 8 #include "chrome/browser/permissions/permission_manager_factory.h" |
| 8 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
| 9 #include "components/content_settings/core/browser/host_content_settings_map.h" | 10 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 10 #include "content/public/browser/permission_type.h" | 11 #include "content/public/browser/permission_type.h" |
| 11 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 using content::PermissionType; | 15 using content::PermissionType; |
| 15 using content::PermissionStatus; | 16 using content::PermissionStatus; |
| 16 | 17 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 43 other_url_("https://foo.com"), | 44 other_url_("https://foo.com"), |
| 44 callback_called_(false), | 45 callback_called_(false), |
| 45 callback_result_(content::PERMISSION_STATUS_ASK) { | 46 callback_result_(content::PERMISSION_STATUS_ASK) { |
| 46 } | 47 } |
| 47 | 48 |
| 48 PermissionManager* GetPermissionManager() { | 49 PermissionManager* GetPermissionManager() { |
| 49 return profile_.GetPermissionManager(); | 50 return profile_.GetPermissionManager(); |
| 50 } | 51 } |
| 51 | 52 |
| 52 HostContentSettingsMap* GetHostContentSettingsMap() { | 53 HostContentSettingsMap* GetHostContentSettingsMap() { |
| 53 return profile_.GetHostContentSettingsMap(); | 54 return HostContentSettingsMapFactory::GetForProfile(&profile_); |
| 54 } | 55 } |
| 55 | 56 |
| 56 void CheckPermissionStatus(PermissionType type, | 57 void CheckPermissionStatus(PermissionType type, |
| 57 PermissionStatus expected) { | 58 PermissionStatus expected) { |
| 58 EXPECT_EQ(expected, GetPermissionManager()->GetPermissionStatus( | 59 EXPECT_EQ(expected, GetPermissionManager()->GetPermissionStatus( |
| 59 type, url_.GetOrigin(), url_.GetOrigin())); | 60 type, url_.GetOrigin(), url_.GetOrigin())); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void SetPermission(ContentSettingsType type, ContentSetting value) { | 63 void SetPermission(ContentSettingsType type, ContentSetting value) { |
| 63 profile_.GetHostContentSettingsMap()->SetContentSetting( | 64 HostContentSettingsMapFactory::GetForProfile(&profile_)->SetContentSetting( |
| 64 ContentSettingsPattern::FromURLNoWildcard(url_), | 65 ContentSettingsPattern::FromURLNoWildcard(url_), |
| 65 ContentSettingsPattern::FromURLNoWildcard(url_), | 66 ContentSettingsPattern::FromURLNoWildcard(url_), |
| 66 type, std::string(), value); | 67 type, std::string(), value); |
| 67 } | 68 } |
| 68 | 69 |
| 69 const GURL& url() const { | 70 const GURL& url() const { |
| 70 return url_; | 71 return url_; |
| 71 } | 72 } |
| 72 | 73 |
| 73 const GURL& other_url() const { | 74 const GURL& other_url() const { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 ContentSettingsPattern::FromURLNoWildcard(url()), | 341 ContentSettingsPattern::FromURLNoWildcard(url()), |
| 341 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 342 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 342 std::string(), | 343 std::string(), |
| 343 CONTENT_SETTING_ASK); | 344 CONTENT_SETTING_ASK); |
| 344 | 345 |
| 345 EXPECT_TRUE(callback_called()); | 346 EXPECT_TRUE(callback_called()); |
| 346 EXPECT_EQ(content::PERMISSION_STATUS_ASK, callback_result()); | 347 EXPECT_EQ(content::PERMISSION_STATUS_ASK, callback_result()); |
| 347 | 348 |
| 348 GetPermissionManager()->UnsubscribePermissionStatusChange(subscription_id); | 349 GetPermissionManager()->UnsubscribePermissionStatusChange(subscription_id); |
| 349 } | 350 } |
| OLD | NEW |