OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/content_settings/permission_context_base.h" | 5 #include "chrome/browser/content_settings/permission_context_base.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/content_settings/host_content_settings_map.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map.h" |
9 #include "chrome/browser/content_settings/permission_queue_controller.h" | 9 #include "chrome/browser/content_settings/permission_queue_controller.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
13 #include "components/content_settings/core/common/content_settings.h" | 13 #include "components/content_settings/core/common/content_settings.h" |
14 #include "components/content_settings/core/common/content_settings_types.h" | 14 #include "components/content_settings/core/common/content_settings_types.h" |
15 #include "components/content_settings/core/common/permission_request_id.h" | 15 #include "components/content_settings/core/common/permission_request_id.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "content/public/test/mock_render_process_host.h" | 17 #include "content/public/test/mock_render_process_host.h" |
18 #include "content/public/test/web_contents_tester.h" | 18 #include "content/public/test/web_contents_tester.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 class PermissionContextBaseTests : public ChromeRenderViewHostTestHarness { | 21 class PermissionContextBaseTests : public ChromeRenderViewHostTestHarness { |
22 protected: | 22 protected: |
23 PermissionContextBaseTests() {} | 23 PermissionContextBaseTests() {} |
24 virtual ~PermissionContextBaseTests() {} | 24 virtual ~PermissionContextBaseTests() {} |
25 | 25 |
26 private: | 26 private: |
27 // ChromeRenderViewHostTestHarness: | 27 // ChromeRenderViewHostTestHarness: |
28 virtual void SetUp() OVERRIDE { | 28 virtual void SetUp() override { |
29 ChromeRenderViewHostTestHarness::SetUp(); | 29 ChromeRenderViewHostTestHarness::SetUp(); |
30 InfoBarService::CreateForWebContents(web_contents()); | 30 InfoBarService::CreateForWebContents(web_contents()); |
31 } | 31 } |
32 | 32 |
33 DISALLOW_COPY_AND_ASSIGN(PermissionContextBaseTests); | 33 DISALLOW_COPY_AND_ASSIGN(PermissionContextBaseTests); |
34 }; | 34 }; |
35 | 35 |
36 class TestPermissionContext : public PermissionContextBase { | 36 class TestPermissionContext : public PermissionContextBase { |
37 public: | 37 public: |
38 TestPermissionContext(Profile* profile, | 38 TestPermissionContext(Profile* profile, |
(...skipping 22 matching lines...) Expand all Loading... |
61 } | 61 } |
62 | 62 |
63 void TrackPermissionDecision(bool granted) { | 63 void TrackPermissionDecision(bool granted) { |
64 permission_set_ = true; | 64 permission_set_ = true; |
65 permission_granted_ = granted; | 65 permission_granted_ = granted; |
66 } | 66 } |
67 | 67 |
68 protected: | 68 protected: |
69 virtual void UpdateTabContext(const PermissionRequestID& id, | 69 virtual void UpdateTabContext(const PermissionRequestID& id, |
70 const GURL& requesting_origin, | 70 const GURL& requesting_origin, |
71 bool allowed) OVERRIDE { | 71 bool allowed) override { |
72 tab_context_updated_ = true; | 72 tab_context_updated_ = true; |
73 } | 73 } |
74 | 74 |
75 private: | 75 private: |
76 bool permission_set_; | 76 bool permission_set_; |
77 bool permission_granted_; | 77 bool permission_granted_; |
78 bool tab_context_updated_; | 78 bool tab_context_updated_; |
79 }; | 79 }; |
80 | 80 |
81 // Simulates clicking Accept. The permission should be granted and | 81 // Simulates clicking Accept. The permission should be granted and |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 EXPECT_TRUE(permission_context.permission_set()); | 132 EXPECT_TRUE(permission_context.permission_set()); |
133 EXPECT_FALSE(permission_context.permission_granted()); | 133 EXPECT_FALSE(permission_context.permission_granted()); |
134 EXPECT_TRUE(permission_context.tab_context_updated()); | 134 EXPECT_TRUE(permission_context.tab_context_updated()); |
135 | 135 |
136 ContentSetting setting = | 136 ContentSetting setting = |
137 profile()->GetHostContentSettingsMap()->GetContentSetting( | 137 profile()->GetHostContentSettingsMap()->GetContentSetting( |
138 url.GetOrigin(), url.GetOrigin(), | 138 url.GetOrigin(), url.GetOrigin(), |
139 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string()); | 139 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string()); |
140 EXPECT_EQ(CONTENT_SETTING_ASK , setting); | 140 EXPECT_EQ(CONTENT_SETTING_ASK , setting); |
141 }; | 141 }; |
OLD | NEW |