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/macros.h" | 11 #include "base/macros.h" |
12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
13 #include "base/test/mock_entropy_provider.h" | 13 #include "base/test/mock_entropy_provider.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
16 #include "chrome/browser/infobars/infobar_service.h" | 16 #include "chrome/browser/infobars/infobar_service.h" |
17 #include "chrome/browser/permissions/permission_queue_controller.h" | 17 #include "chrome/browser/permissions/permission_queue_controller.h" |
18 #include "chrome/browser/permissions/permission_request_id.h" | 18 #include "chrome/browser/permissions/permission_request_id.h" |
| 19 #include "chrome/browser/permissions/permission_uma_util.h" |
19 #include "chrome/browser/permissions/permission_util.h" | 20 #include "chrome/browser/permissions/permission_util.h" |
20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 22 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
22 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
23 #include "components/content_settings/core/browser/host_content_settings_map.h" | 24 #include "components/content_settings/core/browser/host_content_settings_map.h" |
24 #include "components/content_settings/core/common/content_settings.h" | 25 #include "components/content_settings/core/common/content_settings.h" |
25 #include "components/content_settings/core/common/content_settings_types.h" | 26 #include "components/content_settings/core/common/content_settings_types.h" |
26 #include "components/variations/variations_associated_data.h" | 27 #include "components/variations/variations_associated_data.h" |
27 #include "content/public/browser/permission_type.h" | 28 #include "content/public/browser/permission_type.h" |
28 #include "content/public/browser/render_frame_host.h" | 29 #include "content/public/browser/render_frame_host.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // Accept or dismiss the permission bubble or infobar. | 111 // Accept or dismiss the permission bubble or infobar. |
111 void RespondToPermission(TestPermissionContext* context, | 112 void RespondToPermission(TestPermissionContext* context, |
112 const PermissionRequestID& id, | 113 const PermissionRequestID& id, |
113 const GURL& url, | 114 const GURL& url, |
114 ContentSetting response) { | 115 ContentSetting response) { |
115 DCHECK(response == CONTENT_SETTING_ALLOW || | 116 DCHECK(response == CONTENT_SETTING_ALLOW || |
116 response == CONTENT_SETTING_BLOCK || | 117 response == CONTENT_SETTING_BLOCK || |
117 response == CONTENT_SETTING_ASK); | 118 response == CONTENT_SETTING_ASK); |
118 #if defined(OS_ANDROID) | 119 #if defined(OS_ANDROID) |
119 bool update_content_setting = response != CONTENT_SETTING_ASK; | 120 bool update_content_setting = response != CONTENT_SETTING_ASK; |
120 bool allowed = response == CONTENT_SETTING_ALLOW; | 121 PermissionAction decision = DISMISSED; |
| 122 if (response == CONTENT_SETTING_ALLOW) |
| 123 decision = GRANTED; |
| 124 else if (response == CONTENT_SETTING_BLOCK) |
| 125 decision = DENIED; |
121 context->GetInfoBarController()->OnPermissionSet( | 126 context->GetInfoBarController()->OnPermissionSet( |
122 id, url, url, false /* user_gesture */, update_content_setting, | 127 id, url, url, false /* user_gesture */, update_content_setting, |
123 allowed); | 128 decision); |
124 #else | 129 #else |
125 PermissionRequestManager* manager = | 130 PermissionRequestManager* manager = |
126 PermissionRequestManager::FromWebContents(web_contents()); | 131 PermissionRequestManager::FromWebContents(web_contents()); |
127 switch (response) { | 132 switch (response) { |
128 case CONTENT_SETTING_ALLOW: | 133 case CONTENT_SETTING_ALLOW: |
129 manager->Accept(); | 134 manager->Accept(); |
130 break; | 135 break; |
131 case CONTENT_SETTING_BLOCK: | 136 case CONTENT_SETTING_BLOCK: |
132 manager->Deny(); | 137 manager->Deny(); |
133 break; | 138 break; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 TestParallelRequests(CONTENT_SETTING_ALLOW); | 422 TestParallelRequests(CONTENT_SETTING_ALLOW); |
418 } | 423 } |
419 | 424 |
420 TEST_F(PermissionContextBaseTests, TestParallelRequestsBlocked) { | 425 TEST_F(PermissionContextBaseTests, TestParallelRequestsBlocked) { |
421 TestParallelRequests(CONTENT_SETTING_BLOCK); | 426 TestParallelRequests(CONTENT_SETTING_BLOCK); |
422 } | 427 } |
423 | 428 |
424 TEST_F(PermissionContextBaseTests, TestParallelRequestsDismissed) { | 429 TEST_F(PermissionContextBaseTests, TestParallelRequestsDismissed) { |
425 TestParallelRequests(CONTENT_SETTING_ASK); | 430 TestParallelRequests(CONTENT_SETTING_ASK); |
426 } | 431 } |
OLD | NEW |