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

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

Issue 1913413002: [WIP][POC] Base URL: https://chromium.googlesource.com/chromium/src.git@permission-request-rename
Patch Set: rebase Created 4 years, 8 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_context_base.h" 8 #include "chrome/browser/permissions/permission_context_base.h"
9 #include "chrome/browser/permissions/permission_uma_util.h" 9 #include "chrome/browser/permissions/permission_uma_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 "grit/theme_resources.h" 12 #include "grit/theme_resources.h"
13 #include "net/base/escape.h" 13 #include "net/base/escape.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/vector_icons_public.h" 16 #include "ui/gfx/vector_icons_public.h"
17 17
18 #if defined(OS_ANDROID)
19 #include "chrome/browser/android/android_theme_resources.h"
20 #endif // OS_ANDROID
21
18 PermissionRequestImpl::PermissionRequestImpl( 22 PermissionRequestImpl::PermissionRequestImpl(
19 const GURL& request_origin, 23 const GURL& request_origin,
20 content::PermissionType permission_type, 24 content::PermissionType permission_type,
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 permission_decided_callback_(permission_decided_callback), 29 permission_decided_callback_(permission_decided_callback),
26 delete_callback_(delete_callback), 30 delete_callback_(delete_callback),
27 is_finished_(false), 31 is_finished_(false),
28 action_taken_(false) {} 32 action_taken_(false) {}
29 33
30 PermissionRequestImpl::~PermissionRequestImpl() { 34 PermissionRequestImpl::~PermissionRequestImpl() {
31 DCHECK(is_finished_); 35 DCHECK(is_finished_);
32 if (!action_taken_) 36 if (!action_taken_)
33 PermissionUmaUtil::PermissionIgnored(permission_type_, request_origin_); 37 PermissionUmaUtil::PermissionIgnored(permission_type_, request_origin_);
34 } 38 }
35 39
40 #if defined(OS_ANDROID)
41 int PermissionRequestImpl::GetIconId() const {
42 switch (permission_type_) {
43 case content::PermissionType::GEOLOCATION:
44 return IDR_ANDROID_INFOBAR_GEOLOCATION;
45 default:
46 return IDR_INFOBAR_WARNING;
47 }
48 }
49 #else
36 gfx::VectorIconId PermissionRequestImpl::GetVectorIconId() const { 50 gfx::VectorIconId PermissionRequestImpl::GetVectorIconId() const {
37 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 51 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
38 switch (permission_type_) { 52 switch (permission_type_) {
39 case content::PermissionType::GEOLOCATION: 53 case content::PermissionType::GEOLOCATION:
40 return gfx::VectorIconId::LOCATION_ON; 54 return gfx::VectorIconId::LOCATION_ON;
41 #if defined(ENABLE_NOTIFICATIONS) 55 #if defined(ENABLE_NOTIFICATIONS)
42 case content::PermissionType::NOTIFICATIONS: 56 case content::PermissionType::NOTIFICATIONS:
43 return gfx::VectorIconId::NOTIFICATIONS; 57 return gfx::VectorIconId::NOTIFICATIONS;
44 #endif 58 #endif
45 #if defined(OS_CHROMEOS) 59 #if defined(OS_CHROMEOS)
(...skipping 26 matching lines...) Expand all
72 #endif 86 #endif
73 case content::PermissionType::MIDI_SYSEX: 87 case content::PermissionType::MIDI_SYSEX:
74 icon_id = IDR_ALLOWED_MIDI_SYSEX; 88 icon_id = IDR_ALLOWED_MIDI_SYSEX;
75 break; 89 break;
76 default: 90 default:
77 NOTREACHED(); 91 NOTREACHED();
78 } 92 }
79 #endif 93 #endif
80 return icon_id; 94 return icon_id;
81 } 95 }
96 #endif
82 97
83 base::string16 PermissionRequestImpl::GetMessageText() const { 98 base::string16 PermissionRequestImpl::GetMessageText() const {
84 int message_id; 99 int message_id;
85 switch (permission_type_) { 100 switch (permission_type_) {
86 case content::PermissionType::GEOLOCATION: 101 case content::PermissionType::GEOLOCATION:
87 message_id = IDS_GEOLOCATION_INFOBAR_QUESTION; 102 message_id = IDS_GEOLOCATION_INFOBAR_QUESTION;
88 break; 103 break;
89 #if defined(ENABLE_NOTIFICATIONS) 104 #if defined(ENABLE_NOTIFICATIONS)
90 case content::PermissionType::NOTIFICATIONS: 105 case content::PermissionType::NOTIFICATIONS:
91 message_id = IDS_NOTIFICATION_PERMISSIONS; 106 message_id = IDS_NOTIFICATION_PERMISSIONS;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 177
163 void PermissionRequestImpl::RequestFinished() { 178 void PermissionRequestImpl::RequestFinished() {
164 is_finished_ = true; 179 is_finished_ = true;
165 delete_callback_.Run(); 180 delete_callback_.Run();
166 } 181 }
167 182
168 PermissionBubbleType PermissionRequestImpl::GetPermissionBubbleType() 183 PermissionBubbleType PermissionRequestImpl::GetPermissionBubbleType()
169 const { 184 const {
170 return PermissionBubbleType::PERMISSION; 185 return PermissionBubbleType::PERMISSION;
171 } 186 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_request_impl.h ('k') | chrome/browser/permissions/permission_request_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698