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

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

Issue 2315563002: Add PermissionPromptAndroid skeleton (Closed)
Patch Set: remove unused stuff 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"
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 case content::PermissionType::FLASH:
raymes 2016/10/19 00:25:41 I don't think we need this on android
lshang 2016/10/20 05:03:10 Done.
60 return IDR_ALLOWED_PLUGINS;
61 default:
62 NOTREACHED();
63 return IDR_ANDROID_INFOBAR_WARNING;
64 }
65 #else
41 switch (permission_type_) { 66 switch (permission_type_) {
42 case content::PermissionType::GEOLOCATION: 67 case content::PermissionType::GEOLOCATION:
43 return gfx::VectorIconId::LOCATION_ON; 68 return gfx::VectorIconId::LOCATION_ON;
44 #if defined(ENABLE_NOTIFICATIONS) 69 #if defined(ENABLE_NOTIFICATIONS)
45 case content::PermissionType::NOTIFICATIONS: 70 case content::PermissionType::NOTIFICATIONS:
46 case content::PermissionType::PUSH_MESSAGING: 71 case content::PermissionType::PUSH_MESSAGING:
47 return gfx::VectorIconId::NOTIFICATIONS; 72 return gfx::VectorIconId::NOTIFICATIONS;
48 #endif 73 #endif
49 #if defined(OS_CHROMEOS) 74 #if defined(OS_CHROMEOS)
50 // TODO(xhwang): fix this icon, see crrev.com/863263007 75 // TODO(xhwang): fix this icon, see crrev.com/863263007
51 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: 76 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
52 return gfx::VectorIconId::CHROME_PRODUCT; 77 return gfx::VectorIconId::CHROME_PRODUCT;
53 #endif 78 #endif
54 case content::PermissionType::MIDI_SYSEX: 79 case content::PermissionType::MIDI_SYSEX:
55 return gfx::VectorIconId::MIDI; 80 return gfx::VectorIconId::MIDI;
56 case content::PermissionType::FLASH: 81 case content::PermissionType::FLASH:
57 return gfx::VectorIconId::EXTENSION; 82 return gfx::VectorIconId::EXTENSION;
58 default: 83 default:
59 NOTREACHED(); 84 NOTREACHED();
60 return gfx::VectorIconId::VECTOR_ICON_NONE; 85 return gfx::VectorIconId::VECTOR_ICON_NONE;
61 } 86 }
87 #endif
62 } 88 }
63 89
64 base::string16 PermissionRequestImpl::GetMessageTextFragment() const { 90 base::string16 PermissionRequestImpl::GetMessageTextFragment() const {
65 int message_id; 91 int message_id;
66 switch (permission_type_) { 92 switch (permission_type_) {
67 case content::PermissionType::GEOLOCATION: 93 case content::PermissionType::GEOLOCATION:
68 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT; 94 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT;
69 break; 95 break;
70 #if defined(ENABLE_NOTIFICATIONS) 96 #if defined(ENABLE_NOTIFICATIONS)
71 case content::PermissionType::NOTIFICATIONS: 97 case content::PermissionType::NOTIFICATIONS:
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: 192 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
167 return CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER; 193 return CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER;
168 #endif 194 #endif
169 case content::PermissionType::FLASH: 195 case content::PermissionType::FLASH:
170 return CONTENT_SETTINGS_TYPE_PLUGINS; 196 return CONTENT_SETTINGS_TYPE_PLUGINS;
171 default: 197 default:
172 NOTREACHED(); 198 NOTREACHED();
173 return CONTENT_SETTINGS_TYPE_DEFAULT; 199 return CONTENT_SETTINGS_TYPE_DEFAULT;
174 } 200 }
175 } 201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698