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

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

Issue 2123653006: Rename PermissionBubbleRequest to PermissionRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission_manager_rename
Patch Set: Fix missed file Created 4 years, 5 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_bubble_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/gfx/vector_icons_public.h" 15 #include "ui/gfx/vector_icons_public.h"
16 16
17 PermissionBubbleRequestImpl::PermissionBubbleRequestImpl( 17 PermissionRequestImpl::PermissionRequestImpl(
18 const GURL& request_origin, 18 const GURL& request_origin,
19 content::PermissionType permission_type, 19 content::PermissionType permission_type,
20 const PermissionDecidedCallback& permission_decided_callback, 20 const PermissionDecidedCallback& permission_decided_callback,
21 const base::Closure delete_callback) 21 const base::Closure delete_callback)
22 : request_origin_(request_origin), 22 : request_origin_(request_origin),
23 permission_type_(permission_type), 23 permission_type_(permission_type),
24 permission_decided_callback_(permission_decided_callback), 24 permission_decided_callback_(permission_decided_callback),
25 delete_callback_(delete_callback), 25 delete_callback_(delete_callback),
26 is_finished_(false), 26 is_finished_(false),
27 action_taken_(false) {} 27 action_taken_(false) {}
28 28
29 PermissionBubbleRequestImpl::~PermissionBubbleRequestImpl() { 29 PermissionRequestImpl::~PermissionRequestImpl() {
30 DCHECK(is_finished_); 30 DCHECK(is_finished_);
31 if (!action_taken_) 31 if (!action_taken_)
32 // TODO(stefanocs): Pass in a non null profile. 32 // TODO(stefanocs): Pass in a non null profile.
33 PermissionUmaUtil::PermissionIgnored(permission_type_, request_origin_, 33 PermissionUmaUtil::PermissionIgnored(permission_type_, request_origin_,
34 nullptr); 34 nullptr);
35 } 35 }
36 36
37 gfx::VectorIconId PermissionBubbleRequestImpl::GetVectorIconId() const { 37 gfx::VectorIconId PermissionRequestImpl::GetVectorIconId() const {
38 #if !defined(OS_MACOSX) 38 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
39 switch (permission_type_) { 39 switch (permission_type_) {
40 case content::PermissionType::GEOLOCATION: 40 case content::PermissionType::GEOLOCATION:
41 return gfx::VectorIconId::LOCATION_ON; 41 return gfx::VectorIconId::LOCATION_ON;
42 #if defined(ENABLE_NOTIFICATIONS) 42 #if defined(ENABLE_NOTIFICATIONS)
43 case content::PermissionType::NOTIFICATIONS: 43 case content::PermissionType::NOTIFICATIONS:
44 return gfx::VectorIconId::NOTIFICATIONS; 44 return gfx::VectorIconId::NOTIFICATIONS;
45 #endif 45 #endif
46 #if defined(OS_CHROMEOS) 46 #if defined(OS_CHROMEOS)
47 // TODO(xhwang): fix this icon, see crrev.com/863263007 47 // TODO(xhwang): fix this icon, see crrev.com/863263007
48 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: 48 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
49 return gfx::VectorIconId::CHROME_PRODUCT; 49 return gfx::VectorIconId::CHROME_PRODUCT;
50 #endif 50 #endif
51 case content::PermissionType::MIDI_SYSEX: 51 case content::PermissionType::MIDI_SYSEX:
52 return gfx::VectorIconId::MIDI; 52 return gfx::VectorIconId::MIDI;
53 default: 53 default:
54 NOTREACHED(); 54 NOTREACHED();
55 return gfx::VectorIconId::VECTOR_ICON_NONE; 55 return gfx::VectorIconId::VECTOR_ICON_NONE;
56 } 56 }
57 #else // !defined(OS_MACOSX) 57 #else // !defined(OS_MACOSX) && !defined(OS_ANDROID)
58 return gfx::VectorIconId::VECTOR_ICON_NONE; 58 return gfx::VectorIconId::VECTOR_ICON_NONE;
59 #endif 59 #endif
60 } 60 }
61 61
62 int PermissionBubbleRequestImpl::GetIconId() const { 62 int PermissionRequestImpl::GetIconId() const {
63 int icon_id = IDR_INFOBAR_WARNING; 63 int icon_id = IDR_INFOBAR_WARNING;
64 #if defined(OS_MACOSX) 64 #if defined(OS_MACOSX) || defined(OS_ANDROID)
65 switch (permission_type_) { 65 switch (permission_type_) {
66 case content::PermissionType::GEOLOCATION: 66 case content::PermissionType::GEOLOCATION:
67 icon_id = IDR_INFOBAR_GEOLOCATION; 67 icon_id = IDR_INFOBAR_GEOLOCATION;
68 break; 68 break;
69 #if defined(ENABLE_NOTIFICATIONS) 69 #if defined(ENABLE_NOTIFICATIONS)
70 case content::PermissionType::NOTIFICATIONS: 70 case content::PermissionType::NOTIFICATIONS:
71 icon_id = IDR_INFOBAR_DESKTOP_NOTIFICATIONS; 71 icon_id = IDR_INFOBAR_DESKTOP_NOTIFICATIONS;
72 break; 72 break;
73 #endif 73 #endif
74 case content::PermissionType::MIDI_SYSEX: 74 case content::PermissionType::MIDI_SYSEX:
75 icon_id = IDR_ALLOWED_MIDI_SYSEX; 75 icon_id = IDR_ALLOWED_MIDI_SYSEX;
76 break; 76 break;
77 default: 77 default:
78 NOTREACHED(); 78 NOTREACHED();
79 } 79 }
80 #endif 80 #endif
81 return icon_id; 81 return icon_id;
82 } 82 }
83 83
84 base::string16 PermissionBubbleRequestImpl::GetMessageTextFragment() const { 84 base::string16 PermissionRequestImpl::GetMessageTextFragment() const {
85 int message_id; 85 int message_id;
86 switch (permission_type_) { 86 switch (permission_type_) {
87 case content::PermissionType::GEOLOCATION: 87 case content::PermissionType::GEOLOCATION:
88 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT; 88 message_id = IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT;
89 break; 89 break;
90 #if defined(ENABLE_NOTIFICATIONS) 90 #if defined(ENABLE_NOTIFICATIONS)
91 case content::PermissionType::NOTIFICATIONS: 91 case content::PermissionType::NOTIFICATIONS:
92 message_id = IDS_NOTIFICATION_PERMISSIONS_FRAGMENT; 92 message_id = IDS_NOTIFICATION_PERMISSIONS_FRAGMENT;
93 break; 93 break;
94 #endif 94 #endif
95 case content::PermissionType::MIDI_SYSEX: 95 case content::PermissionType::MIDI_SYSEX:
96 message_id = IDS_MIDI_SYSEX_PERMISSION_FRAGMENT; 96 message_id = IDS_MIDI_SYSEX_PERMISSION_FRAGMENT;
97 break; 97 break;
98 case content::PermissionType::PUSH_MESSAGING: 98 case content::PermissionType::PUSH_MESSAGING:
99 message_id = IDS_PUSH_MESSAGES_BUBBLE_FRAGMENT; 99 message_id = IDS_PUSH_MESSAGES_BUBBLE_FRAGMENT;
100 break; 100 break;
101 #if defined(OS_CHROMEOS) 101 #if defined(OS_CHROMEOS)
102 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: 102 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
103 message_id = IDS_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_FRAGMENT; 103 message_id = IDS_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_FRAGMENT;
104 break; 104 break;
105 #endif 105 #endif
106 default: 106 default:
107 NOTREACHED(); 107 NOTREACHED();
108 return base::string16(); 108 return base::string16();
109 } 109 }
110 return l10n_util::GetStringUTF16(message_id); 110 return l10n_util::GetStringUTF16(message_id);
111 } 111 }
112 112
113 GURL PermissionBubbleRequestImpl::GetOrigin() const { 113 GURL PermissionRequestImpl::GetOrigin() const {
114 return request_origin_; 114 return request_origin_;
115 } 115 }
116 116
117 void PermissionBubbleRequestImpl::PermissionGranted() { 117 void PermissionRequestImpl::PermissionGranted() {
118 RegisterActionTaken(); 118 RegisterActionTaken();
119 permission_decided_callback_.Run(true, CONTENT_SETTING_ALLOW); 119 permission_decided_callback_.Run(true, CONTENT_SETTING_ALLOW);
120 } 120 }
121 121
122 void PermissionBubbleRequestImpl::PermissionDenied() { 122 void PermissionRequestImpl::PermissionDenied() {
123 RegisterActionTaken(); 123 RegisterActionTaken();
124 permission_decided_callback_.Run(true, CONTENT_SETTING_BLOCK); 124 permission_decided_callback_.Run(true, CONTENT_SETTING_BLOCK);
125 } 125 }
126 126
127 void PermissionBubbleRequestImpl::Cancelled() { 127 void PermissionRequestImpl::Cancelled() {
128 RegisterActionTaken(); 128 RegisterActionTaken();
129 permission_decided_callback_.Run(false, CONTENT_SETTING_DEFAULT); 129 permission_decided_callback_.Run(false, CONTENT_SETTING_DEFAULT);
130 } 130 }
131 131
132 void PermissionBubbleRequestImpl::RequestFinished() { 132 void PermissionRequestImpl::RequestFinished() {
133 is_finished_ = true; 133 is_finished_ = true;
134 delete_callback_.Run(); 134 delete_callback_.Run();
135 } 135 }
136 136
137 PermissionBubbleType PermissionBubbleRequestImpl::GetPermissionBubbleType() 137 PermissionRequestType PermissionRequestImpl::GetPermissionRequestType()
138 const { 138 const {
139 switch (permission_type_) { 139 switch (permission_type_) {
140 case content::PermissionType::GEOLOCATION: 140 case content::PermissionType::GEOLOCATION:
141 return PermissionBubbleType::PERMISSION_GEOLOCATION; 141 return PermissionRequestType::PERMISSION_GEOLOCATION;
142 #if defined(ENABLE_NOTIFICATIONS) 142 #if defined(ENABLE_NOTIFICATIONS)
143 case content::PermissionType::NOTIFICATIONS: 143 case content::PermissionType::NOTIFICATIONS:
144 return PermissionBubbleType::PERMISSION_NOTIFICATIONS; 144 return PermissionRequestType::PERMISSION_NOTIFICATIONS;
145 #endif 145 #endif
146 case content::PermissionType::MIDI_SYSEX: 146 case content::PermissionType::MIDI_SYSEX:
147 return PermissionBubbleType::PERMISSION_MIDI_SYSEX; 147 return PermissionRequestType::PERMISSION_MIDI_SYSEX;
148 case content::PermissionType::PUSH_MESSAGING: 148 case content::PermissionType::PUSH_MESSAGING:
149 return PermissionBubbleType::PERMISSION_PUSH_MESSAGING; 149 return PermissionRequestType::PERMISSION_PUSH_MESSAGING;
150 #if defined(OS_CHROMEOS) 150 #if defined(OS_CHROMEOS)
151 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: 151 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
152 return PermissionBubbleType::PERMISSION_PROTECTED_MEDIA_IDENTIFIER; 152 return PermissionRequestType::PERMISSION_PROTECTED_MEDIA_IDENTIFIER;
153 #endif 153 #endif
154 default: 154 default:
155 NOTREACHED(); 155 NOTREACHED();
156 return PermissionBubbleType::UNKNOWN; 156 return PermissionRequestType::UNKNOWN;
157 } 157 }
158 } 158 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_request_impl.h ('k') | chrome/browser/permissions/permission_request_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698