Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: chrome/browser/permissions/permission_request_impl.cc

Issue 2385063005: Make PermissionRequest::GetIconId return different types (Closed)
Patch Set: android Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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)
18 #include "chrome/browser/android/android_theme_resources.h"
19 #endif
20
21 PermissionRequestImpl::PermissionRequestImpl( 16 PermissionRequestImpl::PermissionRequestImpl(
22 const GURL& request_origin, 17 const GURL& request_origin,
23 content::PermissionType permission_type, 18 content::PermissionType permission_type,
24 Profile* profile, 19 Profile* profile,
25 bool has_gesture, 20 bool has_gesture,
26 const PermissionDecidedCallback& permission_decided_callback, 21 const PermissionDecidedCallback& permission_decided_callback,
27 const base::Closure delete_callback) 22 const base::Closure delete_callback)
28 : request_origin_(request_origin), 23 : request_origin_(request_origin),
29 permission_type_(permission_type), 24 permission_type_(permission_type),
30 profile_(profile), 25 profile_(profile),
31 has_gesture_(has_gesture), 26 has_gesture_(has_gesture),
32 permission_decided_callback_(permission_decided_callback), 27 permission_decided_callback_(permission_decided_callback),
33 delete_callback_(delete_callback), 28 delete_callback_(delete_callback),
34 is_finished_(false), 29 is_finished_(false),
35 action_taken_(false) {} 30 action_taken_(false) {}
36 31
37 PermissionRequestImpl::~PermissionRequestImpl() { 32 PermissionRequestImpl::~PermissionRequestImpl() {
38 DCHECK(is_finished_); 33 DCHECK(is_finished_);
39 if (!action_taken_) { 34 if (!action_taken_) {
40 PermissionUmaUtil::PermissionIgnored(permission_type_, GetGestureType(), 35 PermissionUmaUtil::PermissionIgnored(permission_type_, GetGestureType(),
41 request_origin_, profile_); 36 request_origin_, profile_);
42 } 37 }
43 } 38 }
44 39
45 gfx::VectorIconId PermissionRequestImpl::GetVectorIconId() const { 40 PermissionRequest::IconId PermissionRequestImpl::GetIconId() const {
felt 2016/10/11 00:36:35 I find this part a little confusing. Someone readi
Evan Stade 2016/10/11 00:45:17 This entire file is not compiled on Android. It do
Peter Kasting 2016/10/11 00:48:51 I would be somewhat unhappy if we added #if PLATFO
46 #if defined(OS_ANDROID)
47 return gfx::VectorIconId::VECTOR_ICON_NONE;
48 #else
49 switch (permission_type_) { 41 switch (permission_type_) {
50 case content::PermissionType::GEOLOCATION: 42 case content::PermissionType::GEOLOCATION:
51 return gfx::VectorIconId::LOCATION_ON; 43 return gfx::VectorIconId::LOCATION_ON;
52 #if defined(ENABLE_NOTIFICATIONS) 44 #if defined(ENABLE_NOTIFICATIONS)
53 case content::PermissionType::NOTIFICATIONS: 45 case content::PermissionType::NOTIFICATIONS:
54 case content::PermissionType::PUSH_MESSAGING: 46 case content::PermissionType::PUSH_MESSAGING:
55 return gfx::VectorIconId::NOTIFICATIONS; 47 return gfx::VectorIconId::NOTIFICATIONS;
56 #endif 48 #endif
57 #if defined(OS_CHROMEOS) 49 #if defined(OS_CHROMEOS)
58 // TODO(xhwang): fix this icon, see crrev.com/863263007 50 // TODO(xhwang): fix this icon, see crrev.com/863263007
59 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: 51 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
60 return gfx::VectorIconId::CHROME_PRODUCT; 52 return gfx::VectorIconId::CHROME_PRODUCT;
61 #endif 53 #endif
62 case content::PermissionType::MIDI_SYSEX: 54 case content::PermissionType::MIDI_SYSEX:
63 return gfx::VectorIconId::MIDI; 55 return gfx::VectorIconId::MIDI;
64 case content::PermissionType::FLASH: 56 case content::PermissionType::FLASH:
65 return gfx::VectorIconId::EXTENSION; 57 return gfx::VectorIconId::EXTENSION;
66 default: 58 default:
67 NOTREACHED(); 59 NOTREACHED();
68 return gfx::VectorIconId::VECTOR_ICON_NONE; 60 return gfx::VectorIconId::VECTOR_ICON_NONE;
69 } 61 }
70 #endif
71 } 62 }
72 63
73 #if defined(OS_ANDROID)
74 int PermissionRequestImpl::GetIconId() const {
felt 2016/10/10 21:39:44 Where did this move to?
Evan Stade 2016/10/10 22:17:43 this file wasn't actually being used on android. T
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 { 64 base::string16 PermissionRequestImpl::GetMessageTextFragment() const {
90 int message_id; 65 int message_id;
91 switch (permission_type_) { 66 switch (permission_type_) {
92 case content::PermissionType::GEOLOCATION: 67 case content::PermissionType::GEOLOCATION:
93 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT; 68 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT;
94 break; 69 break;
95 #if defined(ENABLE_NOTIFICATIONS) 70 #if defined(ENABLE_NOTIFICATIONS)
96 case content::PermissionType::NOTIFICATIONS: 71 case content::PermissionType::NOTIFICATIONS:
97 case content::PermissionType::PUSH_MESSAGING: 72 case content::PermissionType::PUSH_MESSAGING:
98 message_id = IDS_NOTIFICATION_PERMISSIONS_FRAGMENT; 73 message_id = IDS_NOTIFICATION_PERMISSIONS_FRAGMENT;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 NOTREACHED(); 143 NOTREACHED();
169 return PermissionRequestType::UNKNOWN; 144 return PermissionRequestType::UNKNOWN;
170 } 145 }
171 } 146 }
172 147
173 PermissionRequestGestureType PermissionRequestImpl::GetGestureType() 148 PermissionRequestGestureType PermissionRequestImpl::GetGestureType()
174 const { 149 const {
175 return has_gesture_ ? PermissionRequestGestureType::GESTURE 150 return has_gesture_ ? PermissionRequestGestureType::GESTURE
176 : PermissionRequestGestureType::NO_GESTURE; 151 : PermissionRequestGestureType::NO_GESTURE;
177 } 152 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698