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

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

Issue 2463393003: Record permission prompt gesture metrics on Android. (Closed)
Patch Set: 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 switch (type_) {
70 case content::PermissionType::GEOLOCATION:
71 return PermissionRequestType::PERMISSION_GEOLOCATION;
72 #if defined(ENABLE_NOTIFICATIONS)
73 case content::PermissionType::NOTIFICATIONS:
74 return PermissionRequestType::PERMISSION_NOTIFICATIONS;
75 #endif
76 case content::PermissionType::MIDI_SYSEX:
77 return PermissionRequestType::PERMISSION_MIDI_SYSEX;
78 case content::PermissionType::PUSH_MESSAGING:
79 return PermissionRequestType::PERMISSION_PUSH_MESSAGING;
80 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
81 return PermissionRequestType::PERMISSION_PROTECTED_MEDIA_IDENTIFIER;
82 default:
83 NOTREACHED();
84 return PermissionRequestType::UNKNOWN;
85 }
86 }
87
88 PermissionRequestGestureType gesture_type() const {
89 return PermissionUtil::GetGestureType(user_gesture_);
90 }
91
67 const PermissionRequestID& id() const { return id_; } 92 const PermissionRequestID& id() const { return id_; }
68 const GURL& requesting_frame() const { return requesting_frame_; } 93 const GURL& requesting_frame() const { return requesting_frame_; }
69 bool has_gesture() const { return user_gesture_; } 94 bool has_gesture() const { return user_gesture_; }
70 bool has_infobar() const { return !!infobar_; } 95 bool has_infobar() const { return !!infobar_; }
71 bool has_dialog() const { return has_dialog_; } 96 bool has_dialog() const { return has_dialog_; }
72 infobars::InfoBar* infobar() { return infobar_; } 97 infobars::InfoBar* infobar() { return infobar_; }
73 98
74 void RunCallback(ContentSetting content_setting); 99 void RunCallback(ContentSetting content_setting);
75 void CreatePrompt(PermissionQueueController* controller, bool show_dialog); 100 void CreatePrompt(PermissionQueueController* controller, bool show_dialog);
76 101
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 const GURL& requesting_frame, 230 const GURL& requesting_frame,
206 const GURL& embedder, 231 const GURL& embedder,
207 bool user_gesture, 232 bool user_gesture,
208 bool update_content_setting, 233 bool update_content_setting,
209 PermissionAction decision) { 234 PermissionAction decision) {
210 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 235 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
211 236
212 // TODO(miguelg): move the permission persistence to 237 // TODO(miguelg): move the permission persistence to
213 // PermissionContextBase once all the types are moved there. 238 // PermissionContextBase once all the types are moved there.
214 PermissionRequestGestureType gesture_type = 239 PermissionRequestGestureType gesture_type =
215 user_gesture ? PermissionRequestGestureType::GESTURE 240 PermissionUtil::GetGestureType(user_gesture);
216 : PermissionRequestGestureType::NO_GESTURE;
217 switch (decision) { 241 switch (decision) {
218 case GRANTED: 242 case GRANTED:
219 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type, 243 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type,
220 requesting_frame, profile_); 244 requesting_frame, profile_);
221 break; 245 break;
222 case DENIED: 246 case DENIED:
223 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, 247 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type,
224 requesting_frame, profile_); 248 requesting_frame, profile_);
225 break; 249 break;
226 case DISMISSED: 250 case DISMISSED:
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 for (PendingInfobarRequests::iterator i = pending_infobar_requests_.begin(); 378 for (PendingInfobarRequests::iterator i = pending_infobar_requests_.begin();
355 i != pending_infobar_requests_.end(); ++i) { 379 i != pending_infobar_requests_.end(); ++i) {
356 if (ArePermissionRequestsForSameTab(i->id(), id) && !i->has_infobar()) { 380 if (ArePermissionRequestsForSameTab(i->id(), id) && !i->has_infobar()) {
357 // When using modal permission prompts, Java controls the display queue, 381 // When using modal permission prompts, Java controls the display queue,
358 // so infobar notifications are not relevant. 382 // so infobar notifications are not relevant.
359 bool show_dialog = 383 bool show_dialog =
360 PermissionDialogDelegate::ShouldShowDialog(i->has_gesture()); 384 PermissionDialogDelegate::ShouldShowDialog(i->has_gesture());
361 if (!show_dialog) 385 if (!show_dialog)
362 RegisterForInfoBarNotifications(infobar_service); 386 RegisterForInfoBarNotifications(infobar_service);
363 387
388 PermissionUmaUtil::RecordPermissionPromptTypeAndGesture(
389 i->request_type(), i->gesture_type());
364 i->CreatePrompt(this, show_dialog); 390 i->CreatePrompt(this, show_dialog);
365 return; 391 return;
366 } 392 }
367 } 393 }
368 394
369 UnregisterForInfoBarNotifications(infobar_service); 395 UnregisterForInfoBarNotifications(infobar_service);
370 } 396 }
371 397
372 void PermissionQueueController::ClearPendingInfobarRequestsForTab( 398 void PermissionQueueController::ClearPendingInfobarRequestsForTab(
373 const PermissionRequestID& id) { 399 const PermissionRequestID& id) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 } 443 }
418 444
419 ContentSetting content_setting = 445 ContentSetting content_setting =
420 (decision == GRANTED) ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 446 (decision == GRANTED) ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
421 447
422 HostContentSettingsMapFactory::GetForProfile(profile_) 448 HostContentSettingsMapFactory::GetForProfile(profile_)
423 ->SetContentSettingDefaultScope( 449 ->SetContentSettingDefaultScope(
424 requesting_frame.GetOrigin(), embedder.GetOrigin(), 450 requesting_frame.GetOrigin(), embedder.GetOrigin(),
425 content_settings_type_, std::string(), content_setting); 451 content_settings_type_, std::string(), content_setting);
426 } 452 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698