Chromium Code Reviews| 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_uma_util.h" | 8 #include "chrome/browser/permissions/permission_uma_util.h" |
| 9 #include "chrome/browser/permissions/permission_util.h" | 9 #include "chrome/browser/permissions/permission_util.h" |
| 10 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
| 11 #include "chrome/grit/theme_resources.h" | |
| 12 #include "components/url_formatter/elide_url.h" | 11 #include "components/url_formatter/elide_url.h" |
| 13 #include "net/base/escape.h" | 12 #include "net/base/escape.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/gfx/vector_icons_public.h" | 14 #include "ui/gfx/vector_icons_public.h" |
| 16 | 15 |
| 17 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
| 18 #include "chrome/browser/android/android_theme_resources.h" | 17 #include "chrome/browser/android/android_theme_resources.h" |
| 19 #endif | 18 #endif |
| 20 | 19 |
| 21 PermissionRequestImpl::PermissionRequestImpl( | 20 PermissionRequestImpl::PermissionRequestImpl( |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 35 action_taken_(false) {} | 34 action_taken_(false) {} |
| 36 | 35 |
| 37 PermissionRequestImpl::~PermissionRequestImpl() { | 36 PermissionRequestImpl::~PermissionRequestImpl() { |
| 38 DCHECK(is_finished_); | 37 DCHECK(is_finished_); |
| 39 if (!action_taken_) { | 38 if (!action_taken_) { |
| 40 PermissionUmaUtil::PermissionIgnored(permission_type_, GetGestureType(), | 39 PermissionUmaUtil::PermissionIgnored(permission_type_, GetGestureType(), |
| 41 request_origin_, profile_); | 40 request_origin_, profile_); |
| 42 } | 41 } |
| 43 } | 42 } |
| 44 | 43 |
| 45 gfx::VectorIconId PermissionRequestImpl::GetVectorIconId() const { | 44 PermissionRequest::IconId PermissionRequestImpl::GetIconId() const { |
| 46 #if defined(OS_ANDROID) | |
| 47 return gfx::VectorIconId::VECTOR_ICON_NONE; | |
| 48 #else | |
| 49 switch (permission_type_) { | 45 switch (permission_type_) { |
| 50 case content::PermissionType::GEOLOCATION: | 46 case content::PermissionType::GEOLOCATION: |
| 51 return gfx::VectorIconId::LOCATION_ON; | 47 return gfx::VectorIconId::LOCATION_ON; |
| 52 #if defined(ENABLE_NOTIFICATIONS) | 48 #if defined(ENABLE_NOTIFICATIONS) |
| 53 case content::PermissionType::NOTIFICATIONS: | 49 case content::PermissionType::NOTIFICATIONS: |
| 54 case content::PermissionType::PUSH_MESSAGING: | 50 case content::PermissionType::PUSH_MESSAGING: |
| 55 return gfx::VectorIconId::NOTIFICATIONS; | 51 return gfx::VectorIconId::NOTIFICATIONS; |
| 56 #endif | 52 #endif |
| 57 #if defined(OS_CHROMEOS) | 53 #if defined(OS_CHROMEOS) |
| 58 // TODO(xhwang): fix this icon, see crrev.com/863263007 | 54 // TODO(xhwang): fix this icon, see crrev.com/863263007 |
| 59 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: | 55 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: |
| 60 return gfx::VectorIconId::CHROME_PRODUCT; | 56 return gfx::VectorIconId::CHROME_PRODUCT; |
| 61 #endif | 57 #endif |
| 62 case content::PermissionType::MIDI_SYSEX: | 58 case content::PermissionType::MIDI_SYSEX: |
| 63 return gfx::VectorIconId::MIDI; | 59 return gfx::VectorIconId::MIDI; |
| 64 case content::PermissionType::FLASH: | 60 case content::PermissionType::FLASH: |
| 65 return gfx::VectorIconId::EXTENSION; | 61 return gfx::VectorIconId::EXTENSION; |
| 66 default: | 62 default: |
| 67 NOTREACHED(); | 63 NOTREACHED(); |
| 68 return gfx::VectorIconId::VECTOR_ICON_NONE; | 64 return gfx::VectorIconId::VECTOR_ICON_NONE; |
| 69 } | 65 } |
| 70 #endif | |
| 71 } | 66 } |
| 72 | 67 |
| 73 #if defined(OS_ANDROID) | |
| 74 int PermissionRequestImpl::GetIconId() const { | |
|
Peter Kasting
2016/10/06 07:10:30
I guess if this used to be reachable, then the new
Evan Stade
2016/10/06 15:33:50
I noticed this file shouldn't even be compiled on
| |
| 75 switch (permission_type_) { | |
| 76 case content::PermissionType::GEOLOCATION: | |
| 77 return IDR_ANDROID_INFOBAR_GEOLOCATION; | |
| 78 case content::PermissionType::MIDI_SYSEX: | |
| 79 return IDR_ALLOWED_MIDI_SYSEX; | |
| 80 case content::PermissionType::FLASH: | |
| 81 return IDR_ALLOWED_PLUGINS; | |
| 82 default: | |
| 83 NOTREACHED(); | |
| 84 return 0; | |
| 85 } | |
| 86 } | |
| 87 #endif | |
| 88 | |
| 89 base::string16 PermissionRequestImpl::GetMessageTextFragment() const { | 68 base::string16 PermissionRequestImpl::GetMessageTextFragment() const { |
| 90 int message_id; | 69 int message_id; |
| 91 switch (permission_type_) { | 70 switch (permission_type_) { |
| 92 case content::PermissionType::GEOLOCATION: | 71 case content::PermissionType::GEOLOCATION: |
| 93 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT; | 72 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT; |
| 94 break; | 73 break; |
| 95 #if defined(ENABLE_NOTIFICATIONS) | 74 #if defined(ENABLE_NOTIFICATIONS) |
| 96 case content::PermissionType::NOTIFICATIONS: | 75 case content::PermissionType::NOTIFICATIONS: |
| 97 case content::PermissionType::PUSH_MESSAGING: | 76 case content::PermissionType::PUSH_MESSAGING: |
| 98 message_id = IDS_NOTIFICATION_PERMISSIONS_FRAGMENT; | 77 message_id = IDS_NOTIFICATION_PERMISSIONS_FRAGMENT; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 NOTREACHED(); | 147 NOTREACHED(); |
| 169 return PermissionRequestType::UNKNOWN; | 148 return PermissionRequestType::UNKNOWN; |
| 170 } | 149 } |
| 171 } | 150 } |
| 172 | 151 |
| 173 PermissionRequestGestureType PermissionRequestImpl::GetGestureType() | 152 PermissionRequestGestureType PermissionRequestImpl::GetGestureType() |
| 174 const { | 153 const { |
| 175 return has_gesture_ ? PermissionRequestGestureType::GESTURE | 154 return has_gesture_ ? PermissionRequestGestureType::GESTURE |
| 176 : PermissionRequestGestureType::NO_GESTURE; | 155 : PermissionRequestGestureType::NO_GESTURE; |
| 177 } | 156 } |
| OLD | NEW |