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/permissions/permission_context_base.h" | 5 #include "chrome/browser/permissions/permission_context_base.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/feature_list.h" | 11 #include "base/feature_list.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
14 #include "base/test/histogram_tester.h" | 14 #include "base/test/histogram_tester.h" |
15 #include "base/test/mock_entropy_provider.h" | 15 #include "base/test/mock_entropy_provider.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
18 #include "chrome/browser/infobars/infobar_service.h" | 18 #include "chrome/browser/infobars/infobar_service.h" |
19 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" | 19 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
20 #include "chrome/browser/permissions/permission_queue_controller.h" | 20 #include "chrome/browser/permissions/permission_queue_controller.h" |
21 #include "chrome/browser/permissions/permission_request_id.h" | 21 #include "chrome/browser/permissions/permission_request_id.h" |
22 #include "chrome/browser/permissions/permission_uma_util.h" | |
raymes
2016/08/16 03:39:29
nit: is this still needed?
dominickn
2016/08/16 04:15:42
Done.
| |
22 #include "chrome/browser/permissions/permission_util.h" | 23 #include "chrome/browser/permissions/permission_util.h" |
23 #include "chrome/common/chrome_features.h" | 24 #include "chrome/common/chrome_features.h" |
24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 26 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
26 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
27 #include "components/content_settings/core/browser/host_content_settings_map.h" | 28 #include "components/content_settings/core/browser/host_content_settings_map.h" |
28 #include "components/content_settings/core/common/content_settings.h" | 29 #include "components/content_settings/core/common/content_settings.h" |
29 #include "components/content_settings/core/common/content_settings_types.h" | 30 #include "components/content_settings/core/common/content_settings_types.h" |
30 #include "components/variations/variations_associated_data.h" | 31 #include "components/variations/variations_associated_data.h" |
31 #include "content/public/browser/permission_type.h" | 32 #include "content/public/browser/permission_type.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 // Accept or dismiss the permission bubble or infobar. | 128 // Accept or dismiss the permission bubble or infobar. |
128 void RespondToPermission(TestPermissionContext* context, | 129 void RespondToPermission(TestPermissionContext* context, |
129 const PermissionRequestID& id, | 130 const PermissionRequestID& id, |
130 const GURL& url, | 131 const GURL& url, |
131 ContentSetting response) { | 132 ContentSetting response) { |
132 DCHECK(response == CONTENT_SETTING_ALLOW || | 133 DCHECK(response == CONTENT_SETTING_ALLOW || |
133 response == CONTENT_SETTING_BLOCK || | 134 response == CONTENT_SETTING_BLOCK || |
134 response == CONTENT_SETTING_ASK); | 135 response == CONTENT_SETTING_ASK); |
135 #if defined(OS_ANDROID) | 136 #if defined(OS_ANDROID) |
136 bool update_content_setting = response != CONTENT_SETTING_ASK; | 137 bool update_content_setting = response != CONTENT_SETTING_ASK; |
137 bool allowed = response == CONTENT_SETTING_ALLOW; | 138 PermissionAction decision = DISMISSED; |
139 if (response == CONTENT_SETTING_ALLOW) | |
140 decision = GRANTED; | |
141 else if (response == CONTENT_SETTING_BLOCK) | |
142 decision = DENIED; | |
138 context->GetInfoBarController()->OnPermissionSet( | 143 context->GetInfoBarController()->OnPermissionSet( |
139 id, url, url, false /* user_gesture */, update_content_setting, | 144 id, url, url, false /* user_gesture */, update_content_setting, |
140 allowed); | 145 decision); |
141 #else | 146 #else |
142 PermissionRequestManager* manager = | 147 PermissionRequestManager* manager = |
143 PermissionRequestManager::FromWebContents(web_contents()); | 148 PermissionRequestManager::FromWebContents(web_contents()); |
144 switch (response) { | 149 switch (response) { |
145 case CONTENT_SETTING_ALLOW: | 150 case CONTENT_SETTING_ALLOW: |
146 manager->Accept(); | 151 manager->Accept(); |
147 break; | 152 break; |
148 case CONTENT_SETTING_BLOCK: | 153 case CONTENT_SETTING_BLOCK: |
149 manager->Deny(); | 154 manager->Deny(); |
150 break; | 155 break; |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 TestParallelRequests(CONTENT_SETTING_ALLOW); | 617 TestParallelRequests(CONTENT_SETTING_ALLOW); |
613 } | 618 } |
614 | 619 |
615 TEST_F(PermissionContextBaseTests, TestParallelRequestsBlocked) { | 620 TEST_F(PermissionContextBaseTests, TestParallelRequestsBlocked) { |
616 TestParallelRequests(CONTENT_SETTING_BLOCK); | 621 TestParallelRequests(CONTENT_SETTING_BLOCK); |
617 } | 622 } |
618 | 623 |
619 TEST_F(PermissionContextBaseTests, TestParallelRequestsDismissed) { | 624 TEST_F(PermissionContextBaseTests, TestParallelRequestsDismissed) { |
620 TestParallelRequests(CONTENT_SETTING_ASK); | 625 TestParallelRequests(CONTENT_SETTING_ASK); |
621 } | 626 } |
OLD | NEW |