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" | |
raymes
2016/10/24 00:50:16
nit: is this one needed?
lshang
2016/10/24 08:48:02
Done.
| |
11 #include "components/url_formatter/elide_url.h" | 12 #include "components/url_formatter/elide_url.h" |
12 #include "net/base/escape.h" | 13 #include "net/base/escape.h" |
13 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
14 #include "ui/gfx/vector_icons_public.h" | 15 #include "ui/gfx/vector_icons_public.h" |
15 | 16 |
17 #if defined(OS_ANDROID) | |
18 #include "chrome/browser/android/android_theme_resources.h" | |
19 #endif | |
20 | |
16 PermissionRequestImpl::PermissionRequestImpl( | 21 PermissionRequestImpl::PermissionRequestImpl( |
17 const GURL& request_origin, | 22 const GURL& request_origin, |
18 content::PermissionType permission_type, | 23 content::PermissionType permission_type, |
19 Profile* profile, | 24 Profile* profile, |
20 bool has_gesture, | 25 bool has_gesture, |
21 const PermissionDecidedCallback& permission_decided_callback, | 26 const PermissionDecidedCallback& permission_decided_callback, |
22 const base::Closure delete_callback) | 27 const base::Closure delete_callback) |
23 : request_origin_(request_origin), | 28 : request_origin_(request_origin), |
24 permission_type_(permission_type), | 29 permission_type_(permission_type), |
25 profile_(profile), | 30 profile_(profile), |
26 has_gesture_(has_gesture), | 31 has_gesture_(has_gesture), |
27 permission_decided_callback_(permission_decided_callback), | 32 permission_decided_callback_(permission_decided_callback), |
28 delete_callback_(delete_callback), | 33 delete_callback_(delete_callback), |
29 is_finished_(false), | 34 is_finished_(false), |
30 action_taken_(false) {} | 35 action_taken_(false) {} |
31 | 36 |
32 PermissionRequestImpl::~PermissionRequestImpl() { | 37 PermissionRequestImpl::~PermissionRequestImpl() { |
33 DCHECK(is_finished_); | 38 DCHECK(is_finished_); |
34 if (!action_taken_) { | 39 if (!action_taken_) { |
35 PermissionUmaUtil::PermissionIgnored(permission_type_, GetGestureType(), | 40 PermissionUmaUtil::PermissionIgnored(permission_type_, GetGestureType(), |
36 request_origin_, profile_); | 41 request_origin_, profile_); |
37 } | 42 } |
38 } | 43 } |
39 | 44 |
40 PermissionRequest::IconId PermissionRequestImpl::GetIconId() const { | 45 PermissionRequest::IconId PermissionRequestImpl::GetIconId() const { |
46 #if defined(OS_ANDROID) | |
47 switch (permission_type_) { | |
48 case content::PermissionType::GEOLOCATION: | |
49 return IDR_ANDROID_INFOBAR_GEOLOCATION; | |
50 #if defined(ENABLE_NOTIFICATIONS) | |
51 case content::PermissionType::NOTIFICATIONS: | |
52 case content::PermissionType::PUSH_MESSAGING: | |
53 return IDR_ANDROID_INFOBAR_NOTIFICATIONS; | |
54 #endif | |
55 case content::PermissionType::MIDI_SYSEX: | |
56 return IDR_ANDROID_INFOBAR_MIDI; | |
57 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: | |
58 return IDR_ANDROID_INFOBAR_PROTECTED_MEDIA_IDENTIFIER; | |
59 default: | |
60 NOTREACHED(); | |
61 return IDR_ANDROID_INFOBAR_WARNING; | |
62 } | |
63 #else | |
41 switch (permission_type_) { | 64 switch (permission_type_) { |
42 case content::PermissionType::GEOLOCATION: | 65 case content::PermissionType::GEOLOCATION: |
43 return gfx::VectorIconId::LOCATION_ON; | 66 return gfx::VectorIconId::LOCATION_ON; |
44 #if defined(ENABLE_NOTIFICATIONS) | 67 #if defined(ENABLE_NOTIFICATIONS) |
45 case content::PermissionType::NOTIFICATIONS: | 68 case content::PermissionType::NOTIFICATIONS: |
46 case content::PermissionType::PUSH_MESSAGING: | 69 case content::PermissionType::PUSH_MESSAGING: |
47 return gfx::VectorIconId::NOTIFICATIONS; | 70 return gfx::VectorIconId::NOTIFICATIONS; |
48 #endif | 71 #endif |
49 #if defined(OS_CHROMEOS) | 72 #if defined(OS_CHROMEOS) |
50 // TODO(xhwang): fix this icon, see crrev.com/863263007 | 73 // TODO(xhwang): fix this icon, see crrev.com/863263007 |
51 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: | 74 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: |
52 return gfx::VectorIconId::CHROME_PRODUCT; | 75 return gfx::VectorIconId::CHROME_PRODUCT; |
53 #endif | 76 #endif |
54 case content::PermissionType::MIDI_SYSEX: | 77 case content::PermissionType::MIDI_SYSEX: |
55 return gfx::VectorIconId::MIDI; | 78 return gfx::VectorIconId::MIDI; |
56 case content::PermissionType::FLASH: | 79 case content::PermissionType::FLASH: |
57 return gfx::VectorIconId::EXTENSION; | 80 return gfx::VectorIconId::EXTENSION; |
58 default: | 81 default: |
59 NOTREACHED(); | 82 NOTREACHED(); |
60 return gfx::VectorIconId::VECTOR_ICON_NONE; | 83 return gfx::VectorIconId::VECTOR_ICON_NONE; |
61 } | 84 } |
85 #endif | |
62 } | 86 } |
63 | 87 |
64 base::string16 PermissionRequestImpl::GetMessageTextFragment() const { | 88 base::string16 PermissionRequestImpl::GetMessageTextFragment() const { |
65 int message_id; | 89 int message_id; |
66 switch (permission_type_) { | 90 switch (permission_type_) { |
67 case content::PermissionType::GEOLOCATION: | 91 case content::PermissionType::GEOLOCATION: |
68 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT; | 92 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT; |
69 break; | 93 break; |
70 #if defined(ENABLE_NOTIFICATIONS) | 94 #if defined(ENABLE_NOTIFICATIONS) |
71 case content::PermissionType::NOTIFICATIONS: | 95 case content::PermissionType::NOTIFICATIONS: |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: | 190 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: |
167 return CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER; | 191 return CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER; |
168 #endif | 192 #endif |
169 case content::PermissionType::FLASH: | 193 case content::PermissionType::FLASH: |
170 return CONTENT_SETTINGS_TYPE_PLUGINS; | 194 return CONTENT_SETTINGS_TYPE_PLUGINS; |
171 default: | 195 default: |
172 NOTREACHED(); | 196 NOTREACHED(); |
173 return CONTENT_SETTINGS_TYPE_DEFAULT; | 197 return CONTENT_SETTINGS_TYPE_DEFAULT; |
174 } | 198 } |
175 } | 199 } |
OLD | NEW |