| 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/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 case content::PermissionType::PUSH_MESSAGING: | 48 case content::PermissionType::PUSH_MESSAGING: |
| 49 return gfx::VectorIconId::NOTIFICATIONS; | 49 return gfx::VectorIconId::NOTIFICATIONS; |
| 50 #endif | 50 #endif |
| 51 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
| 52 // TODO(xhwang): fix this icon, see crrev.com/863263007 | 52 // TODO(xhwang): fix this icon, see crrev.com/863263007 |
| 53 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: | 53 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: |
| 54 return gfx::VectorIconId::CHROME_PRODUCT; | 54 return gfx::VectorIconId::CHROME_PRODUCT; |
| 55 #endif | 55 #endif |
| 56 case content::PermissionType::MIDI_SYSEX: | 56 case content::PermissionType::MIDI_SYSEX: |
| 57 return gfx::VectorIconId::MIDI; | 57 return gfx::VectorIconId::MIDI; |
| 58 case content::PermissionType::PLUGINS: |
| 59 return gfx::VectorIconId::EXTENSION; |
| 58 default: | 60 default: |
| 59 NOTREACHED(); | 61 NOTREACHED(); |
| 60 return gfx::VectorIconId::VECTOR_ICON_NONE; | 62 return gfx::VectorIconId::VECTOR_ICON_NONE; |
| 61 } | 63 } |
| 62 #else // !defined(OS_MACOSX) && !defined(OS_ANDROID) | 64 #else // !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 63 return gfx::VectorIconId::VECTOR_ICON_NONE; | 65 return gfx::VectorIconId::VECTOR_ICON_NONE; |
| 64 #endif | 66 #endif |
| 65 } | 67 } |
| 66 | 68 |
| 67 int PermissionRequestImpl::GetIconId() const { | 69 int PermissionRequestImpl::GetIconId() const { |
| 68 int icon_id = IDR_INFOBAR_WARNING; | 70 int icon_id = IDR_INFOBAR_WARNING; |
| 69 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 71 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 70 switch (permission_type_) { | 72 switch (permission_type_) { |
| 71 case content::PermissionType::GEOLOCATION: | 73 case content::PermissionType::GEOLOCATION: |
| 72 icon_id = IDR_INFOBAR_GEOLOCATION; | 74 icon_id = IDR_INFOBAR_GEOLOCATION; |
| 73 break; | 75 break; |
| 74 #if defined(ENABLE_NOTIFICATIONS) | 76 #if defined(ENABLE_NOTIFICATIONS) |
| 75 case content::PermissionType::NOTIFICATIONS: | 77 case content::PermissionType::NOTIFICATIONS: |
| 76 case content::PermissionType::PUSH_MESSAGING: | 78 case content::PermissionType::PUSH_MESSAGING: |
| 77 icon_id = IDR_INFOBAR_DESKTOP_NOTIFICATIONS; | 79 icon_id = IDR_INFOBAR_DESKTOP_NOTIFICATIONS; |
| 78 break; | 80 break; |
| 79 #endif | 81 #endif |
| 80 case content::PermissionType::MIDI_SYSEX: | 82 case content::PermissionType::MIDI_SYSEX: |
| 81 icon_id = IDR_ALLOWED_MIDI_SYSEX; | 83 icon_id = IDR_ALLOWED_MIDI_SYSEX; |
| 82 break; | 84 break; |
| 85 case content::PermissionType::PLUGINS: |
| 86 icon_id = IDR_ALLOWED_PLUGINS; |
| 87 break; |
| 83 default: | 88 default: |
| 84 NOTREACHED(); | 89 NOTREACHED(); |
| 85 } | 90 } |
| 86 #endif | 91 #endif |
| 87 return icon_id; | 92 return icon_id; |
| 88 } | 93 } |
| 89 | 94 |
| 90 base::string16 PermissionRequestImpl::GetMessageTextFragment() const { | 95 base::string16 PermissionRequestImpl::GetMessageTextFragment() const { |
| 91 int message_id; | 96 int message_id; |
| 92 switch (permission_type_) { | 97 switch (permission_type_) { |
| 93 case content::PermissionType::GEOLOCATION: | 98 case content::PermissionType::GEOLOCATION: |
| 94 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT; | 99 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT; |
| 95 break; | 100 break; |
| 96 #if defined(ENABLE_NOTIFICATIONS) | 101 #if defined(ENABLE_NOTIFICATIONS) |
| 97 case content::PermissionType::NOTIFICATIONS: | 102 case content::PermissionType::NOTIFICATIONS: |
| 98 case content::PermissionType::PUSH_MESSAGING: | 103 case content::PermissionType::PUSH_MESSAGING: |
| 99 message_id = IDS_NOTIFICATION_PERMISSIONS_FRAGMENT; | 104 message_id = IDS_NOTIFICATION_PERMISSIONS_FRAGMENT; |
| 100 break; | 105 break; |
| 101 #endif | 106 #endif |
| 102 case content::PermissionType::MIDI_SYSEX: | 107 case content::PermissionType::MIDI_SYSEX: |
| 103 message_id = IDS_MIDI_SYSEX_PERMISSION_FRAGMENT; | 108 message_id = IDS_MIDI_SYSEX_PERMISSION_FRAGMENT; |
| 104 break; | 109 break; |
| 105 #if defined(OS_CHROMEOS) | 110 #if defined(OS_CHROMEOS) |
| 106 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: | 111 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: |
| 107 message_id = IDS_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_FRAGMENT; | 112 message_id = IDS_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_FRAGMENT; |
| 108 break; | 113 break; |
| 109 #endif | 114 #endif |
| 115 case content::PermissionType::PLUGINS: |
| 116 message_id = IDS_FLASH_PERMISSION_FRAGMENT; |
| 117 break; |
| 110 default: | 118 default: |
| 111 NOTREACHED(); | 119 NOTREACHED(); |
| 112 return base::string16(); | 120 return base::string16(); |
| 113 } | 121 } |
| 114 return l10n_util::GetStringUTF16(message_id); | 122 return l10n_util::GetStringUTF16(message_id); |
| 115 } | 123 } |
| 116 | 124 |
| 117 GURL PermissionRequestImpl::GetOrigin() const { | 125 GURL PermissionRequestImpl::GetOrigin() const { |
| 118 return request_origin_; | 126 return request_origin_; |
| 119 } | 127 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 148 return PermissionRequestType::PERMISSION_NOTIFICATIONS; | 156 return PermissionRequestType::PERMISSION_NOTIFICATIONS; |
| 149 #endif | 157 #endif |
| 150 case content::PermissionType::MIDI_SYSEX: | 158 case content::PermissionType::MIDI_SYSEX: |
| 151 return PermissionRequestType::PERMISSION_MIDI_SYSEX; | 159 return PermissionRequestType::PERMISSION_MIDI_SYSEX; |
| 152 case content::PermissionType::PUSH_MESSAGING: | 160 case content::PermissionType::PUSH_MESSAGING: |
| 153 return PermissionRequestType::PERMISSION_PUSH_MESSAGING; | 161 return PermissionRequestType::PERMISSION_PUSH_MESSAGING; |
| 154 #if defined(OS_CHROMEOS) | 162 #if defined(OS_CHROMEOS) |
| 155 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: | 163 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: |
| 156 return PermissionRequestType::PERMISSION_PROTECTED_MEDIA_IDENTIFIER; | 164 return PermissionRequestType::PERMISSION_PROTECTED_MEDIA_IDENTIFIER; |
| 157 #endif | 165 #endif |
| 166 case content::PermissionType::PLUGINS: |
| 167 return PermissionRequestType::PERMISSION_PLUGINS; |
| 158 default: | 168 default: |
| 159 NOTREACHED(); | 169 NOTREACHED(); |
| 160 return PermissionRequestType::UNKNOWN; | 170 return PermissionRequestType::UNKNOWN; |
| 161 } | 171 } |
| 162 } | 172 } |
| 163 | 173 |
| 164 PermissionRequestGestureType PermissionRequestImpl::GetGestureType() | 174 PermissionRequestGestureType PermissionRequestImpl::GetGestureType() |
| 165 const { | 175 const { |
| 166 return has_gesture_ ? PermissionRequestGestureType::GESTURE | 176 return has_gesture_ ? PermissionRequestGestureType::GESTURE |
| 167 : PermissionRequestGestureType::NO_GESTURE; | 177 : PermissionRequestGestureType::NO_GESTURE; |
| 168 } | 178 } |
| OLD | NEW |