| 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_request_impl.h" | 5 #include "chrome/browser/permissions/permission_request_impl.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" | 8 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
| 9 #include "chrome/browser/permissions/permission_uma_util.h" | 9 #include "chrome/browser/permissions/permission_uma_util.h" |
| 10 #include "chrome/browser/permissions/permission_util.h" |
| 10 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
| 11 #include "components/url_formatter/elide_url.h" | 12 #include "components/url_formatter/elide_url.h" |
| 12 #include "grit/theme_resources.h" | 13 #include "grit/theme_resources.h" |
| 13 #include "net/base/escape.h" | 14 #include "net/base/escape.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/gfx/vector_icons_public.h" | 16 #include "ui/gfx/vector_icons_public.h" |
| 16 | 17 |
| 17 PermissionRequestImpl::PermissionRequestImpl( | 18 PermissionRequestImpl::PermissionRequestImpl( |
| 18 const GURL& request_origin, | 19 const GURL& request_origin, |
| 19 content::PermissionType permission_type, | 20 content::PermissionType permission_type, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 114 } |
| 114 return l10n_util::GetStringUTF16(message_id); | 115 return l10n_util::GetStringUTF16(message_id); |
| 115 } | 116 } |
| 116 | 117 |
| 117 GURL PermissionRequestImpl::GetOrigin() const { | 118 GURL PermissionRequestImpl::GetOrigin() const { |
| 118 return request_origin_; | 119 return request_origin_; |
| 119 } | 120 } |
| 120 | 121 |
| 121 void PermissionRequestImpl::PermissionGranted() { | 122 void PermissionRequestImpl::PermissionGranted() { |
| 122 RegisterActionTaken(); | 123 RegisterActionTaken(); |
| 123 permission_decided_callback_.Run(true, CONTENT_SETTING_ALLOW); | 124 permission_decided_callback_.Run(persist(), CONTENT_SETTING_ALLOW); |
| 124 } | 125 } |
| 125 | 126 |
| 126 void PermissionRequestImpl::PermissionDenied() { | 127 void PermissionRequestImpl::PermissionDenied() { |
| 127 RegisterActionTaken(); | 128 RegisterActionTaken(); |
| 128 permission_decided_callback_.Run(true, CONTENT_SETTING_BLOCK); | 129 permission_decided_callback_.Run(persist(), CONTENT_SETTING_BLOCK); |
| 129 } | 130 } |
| 130 | 131 |
| 131 void PermissionRequestImpl::Cancelled() { | 132 void PermissionRequestImpl::Cancelled() { |
| 132 RegisterActionTaken(); | 133 RegisterActionTaken(); |
| 133 permission_decided_callback_.Run(false, CONTENT_SETTING_DEFAULT); | 134 permission_decided_callback_.Run(false, CONTENT_SETTING_DEFAULT); |
| 134 } | 135 } |
| 135 | 136 |
| 136 void PermissionRequestImpl::RequestFinished() { | 137 void PermissionRequestImpl::RequestFinished() { |
| 137 is_finished_ = true; | 138 is_finished_ = true; |
| 138 delete_callback_.Run(); | 139 delete_callback_.Run(); |
| 139 } | 140 } |
| 140 | 141 |
| 142 bool PermissionRequestImpl::ShouldShowPersistenceToggle() const { |
| 143 return (permission_type_ == content::PermissionType::GEOLOCATION) && |
| 144 PermissionUtil::ShouldShowPersistenceToggle(); |
| 145 } |
| 146 |
| 141 PermissionRequestType PermissionRequestImpl::GetPermissionRequestType() | 147 PermissionRequestType PermissionRequestImpl::GetPermissionRequestType() |
| 142 const { | 148 const { |
| 143 switch (permission_type_) { | 149 switch (permission_type_) { |
| 144 case content::PermissionType::GEOLOCATION: | 150 case content::PermissionType::GEOLOCATION: |
| 145 return PermissionRequestType::PERMISSION_GEOLOCATION; | 151 return PermissionRequestType::PERMISSION_GEOLOCATION; |
| 146 #if defined(ENABLE_NOTIFICATIONS) | 152 #if defined(ENABLE_NOTIFICATIONS) |
| 147 case content::PermissionType::NOTIFICATIONS: | 153 case content::PermissionType::NOTIFICATIONS: |
| 148 return PermissionRequestType::PERMISSION_NOTIFICATIONS; | 154 return PermissionRequestType::PERMISSION_NOTIFICATIONS; |
| 149 #endif | 155 #endif |
| 150 case content::PermissionType::MIDI_SYSEX: | 156 case content::PermissionType::MIDI_SYSEX: |
| 151 return PermissionRequestType::PERMISSION_MIDI_SYSEX; | 157 return PermissionRequestType::PERMISSION_MIDI_SYSEX; |
| 152 case content::PermissionType::PUSH_MESSAGING: | 158 case content::PermissionType::PUSH_MESSAGING: |
| 153 return PermissionRequestType::PERMISSION_PUSH_MESSAGING; | 159 return PermissionRequestType::PERMISSION_PUSH_MESSAGING; |
| 154 #if defined(OS_CHROMEOS) | 160 #if defined(OS_CHROMEOS) |
| 155 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: | 161 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: |
| 156 return PermissionRequestType::PERMISSION_PROTECTED_MEDIA_IDENTIFIER; | 162 return PermissionRequestType::PERMISSION_PROTECTED_MEDIA_IDENTIFIER; |
| 157 #endif | 163 #endif |
| 158 default: | 164 default: |
| 159 NOTREACHED(); | 165 NOTREACHED(); |
| 160 return PermissionRequestType::UNKNOWN; | 166 return PermissionRequestType::UNKNOWN; |
| 161 } | 167 } |
| 162 } | 168 } |
| 163 | 169 |
| 164 PermissionRequestGestureType PermissionRequestImpl::GetGestureType() | 170 PermissionRequestGestureType PermissionRequestImpl::GetGestureType() |
| 165 const { | 171 const { |
| 166 return has_gesture_ ? PermissionRequestGestureType::GESTURE | 172 return has_gesture_ ? PermissionRequestGestureType::GESTURE |
| 167 : PermissionRequestGestureType::NO_GESTURE; | 173 : PermissionRequestGestureType::NO_GESTURE; |
| 168 } | 174 } |
| OLD | NEW |