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

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

Issue 2463393003: Record permission prompt gesture metrics on Android. (Closed)
Patch Set: Address comments 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_queue_controller.h" 5 #include "chrome/browser/permissions/permission_queue_controller.h"
6 6
7 #include "build/build_config.h"
7 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
9 #include "chrome/browser/infobars/infobar_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/browser/permissions/permission_dialog_delegate.h" 11 #include "chrome/browser/permissions/permission_dialog_delegate.h"
11 #include "chrome/browser/permissions/permission_infobar_delegate.h" 12 #include "chrome/browser/permissions/permission_infobar_delegate.h"
12 #include "chrome/browser/permissions/permission_request.h" 13 #include "chrome/browser/permissions/permission_request.h"
13 #include "chrome/browser/permissions/permission_request_id.h" 14 #include "chrome/browser/permissions/permission_request_id.h"
14 #include "chrome/browser/permissions/permission_uma_util.h" 15 #include "chrome/browser/permissions/permission_uma_util.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/tab_contents/tab_util.h" 17 #include "chrome/browser/tab_contents/tab_util.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const GURL& requesting_frame, 58 const GURL& requesting_frame,
58 const GURL& embedder, 59 const GURL& embedder,
59 bool user_gesture, 60 bool user_gesture,
60 Profile* profile, 61 Profile* profile,
61 const PermissionDecidedCallback& callback); 62 const PermissionDecidedCallback& callback);
62 ~PendingInfobarRequest(); 63 ~PendingInfobarRequest();
63 64
64 bool IsForPair(const GURL& requesting_frame, 65 bool IsForPair(const GURL& requesting_frame,
65 const GURL& embedder) const; 66 const GURL& embedder) const;
66 67
68 PermissionRequestType request_type() const {
69 return PermissionUtil::GetRequestType(type_);
70 }
71
72 PermissionRequestGestureType gesture_type() const {
73 return PermissionUtil::GetGestureType(user_gesture_);
74 }
75
67 const PermissionRequestID& id() const { return id_; } 76 const PermissionRequestID& id() const { return id_; }
68 const GURL& requesting_frame() const { return requesting_frame_; } 77 const GURL& requesting_frame() const { return requesting_frame_; }
69 bool has_gesture() const { return user_gesture_; } 78 bool has_gesture() const { return user_gesture_; }
70 bool has_infobar() const { return !!infobar_; } 79 bool has_infobar() const { return !!infobar_; }
71 bool has_dialog() const { return has_dialog_; } 80 bool has_dialog() const { return has_dialog_; }
72 infobars::InfoBar* infobar() { return infobar_; } 81 infobars::InfoBar* infobar() { return infobar_; }
73 82
74 void RunCallback(ContentSetting content_setting); 83 void RunCallback(ContentSetting content_setting);
75 void CreatePrompt(PermissionQueueController* controller, bool show_dialog); 84 void CreatePrompt(PermissionQueueController* controller, bool show_dialog);
76 85
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 211 }
203 212
204 void PermissionQueueController::OnPermissionSet(const PermissionRequestID& id, 213 void PermissionQueueController::OnPermissionSet(const PermissionRequestID& id,
205 const GURL& requesting_frame, 214 const GURL& requesting_frame,
206 const GURL& embedder, 215 const GURL& embedder,
207 bool user_gesture, 216 bool user_gesture,
208 bool update_content_setting, 217 bool update_content_setting,
209 PermissionAction decision) { 218 PermissionAction decision) {
210 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 219 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
211 220
212 // TODO(miguelg): move the permission persistence to 221 PermissionRequestType request_type =
213 // PermissionContextBase once all the types are moved there. 222 PermissionUtil::GetRequestType(permission_type_);
214 PermissionRequestGestureType gesture_type = 223 PermissionRequestGestureType gesture_type =
215 user_gesture ? PermissionRequestGestureType::GESTURE 224 PermissionUtil::GetGestureType(user_gesture);
216 : PermissionRequestGestureType::NO_GESTURE;
217 switch (decision) { 225 switch (decision) {
218 case GRANTED: 226 case GRANTED:
219 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type, 227 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type,
220 requesting_frame, profile_); 228 requesting_frame, profile_);
229 PermissionUmaUtil::RecordPermissionPromptAccepted(request_type,
230 gesture_type);
221 break; 231 break;
222 case DENIED: 232 case DENIED:
223 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, 233 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type,
224 requesting_frame, profile_); 234 requesting_frame, profile_);
235 PermissionUmaUtil::RecordPermissionPromptDenied(request_type,
236 gesture_type);
225 break; 237 break;
226 case DISMISSED: 238 case DISMISSED:
227 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, 239 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type,
228 requesting_frame, profile_); 240 requesting_frame, profile_);
229 break; 241 break;
230 default: 242 default:
231 NOTREACHED(); 243 NOTREACHED();
232 } 244 }
233 245
246 // TODO(miguelg): move the permission persistence to
247 // PermissionContextBase once all the types are moved there.
234 if (update_content_setting) 248 if (update_content_setting)
235 UpdateContentSetting(requesting_frame, embedder, decision); 249 UpdateContentSetting(requesting_frame, embedder, decision);
236 250
237 // Cancel this request first, then notify listeners. TODO(pkasting): Why 251 // Cancel this request first, then notify listeners. TODO(pkasting): Why
238 // is this order important? 252 // is this order important?
239 PendingInfobarRequests requests_to_notify; 253 PendingInfobarRequests requests_to_notify;
240 PendingInfobarRequests infobars_to_remove; 254 PendingInfobarRequests infobars_to_remove;
241 std::vector<PendingInfobarRequests::iterator> pending_requests_to_remove; 255 std::vector<PendingInfobarRequests::iterator> pending_requests_to_remove;
242 for (PendingInfobarRequests::iterator i = pending_infobar_requests_.begin(); 256 for (PendingInfobarRequests::iterator i = pending_infobar_requests_.begin();
243 i != pending_infobar_requests_.end(); ++i) { 257 i != pending_infobar_requests_.end(); ++i) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 for (PendingInfobarRequests::iterator i = pending_infobar_requests_.begin(); 368 for (PendingInfobarRequests::iterator i = pending_infobar_requests_.begin();
355 i != pending_infobar_requests_.end(); ++i) { 369 i != pending_infobar_requests_.end(); ++i) {
356 if (ArePermissionRequestsForSameTab(i->id(), id) && !i->has_infobar()) { 370 if (ArePermissionRequestsForSameTab(i->id(), id) && !i->has_infobar()) {
357 // When using modal permission prompts, Java controls the display queue, 371 // When using modal permission prompts, Java controls the display queue,
358 // so infobar notifications are not relevant. 372 // so infobar notifications are not relevant.
359 bool show_dialog = 373 bool show_dialog =
360 PermissionDialogDelegate::ShouldShowDialog(i->has_gesture()); 374 PermissionDialogDelegate::ShouldShowDialog(i->has_gesture());
361 if (!show_dialog) 375 if (!show_dialog)
362 RegisterForInfoBarNotifications(infobar_service); 376 RegisterForInfoBarNotifications(infobar_service);
363 377
378 PermissionUmaUtil::RecordPermissionPromptShown(i->request_type(),
379 i->gesture_type());
364 i->CreatePrompt(this, show_dialog); 380 i->CreatePrompt(this, show_dialog);
365 return; 381 return;
366 } 382 }
367 } 383 }
368 384
369 UnregisterForInfoBarNotifications(infobar_service); 385 UnregisterForInfoBarNotifications(infobar_service);
370 } 386 }
371 387
372 void PermissionQueueController::ClearPendingInfobarRequestsForTab( 388 void PermissionQueueController::ClearPendingInfobarRequestsForTab(
373 const PermissionRequestID& id) { 389 const PermissionRequestID& id) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 } 433 }
418 434
419 ContentSetting content_setting = 435 ContentSetting content_setting =
420 (decision == GRANTED) ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 436 (decision == GRANTED) ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
421 437
422 HostContentSettingsMapFactory::GetForProfile(profile_) 438 HostContentSettingsMapFactory::GetForProfile(profile_)
423 ->SetContentSettingDefaultScope( 439 ->SetContentSettingDefaultScope(
424 requesting_frame.GetOrigin(), embedder.GetOrigin(), 440 requesting_frame.GetOrigin(), embedder.GetOrigin(),
425 content_settings_type_, std::string(), content_setting); 441 content_settings_type_, std::string(), content_setting);
426 } 442 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_infobar_delegate.h ('k') | chrome/browser/permissions/permission_request_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698