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

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

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

Powered by Google App Engine
This is Rietveld 408576698