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

Side by Side Diff: chrome/browser/media/chrome_midi_permission_context.cc

Issue 185863003: [Media] Add user gesture reporting for API calls to midi and media streams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try 2 Created 6 years, 9 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 | Annotate | Revision Log
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/media/chrome_midi_permission_context.h" 5 #include "chrome/browser/media/chrome_midi_permission_context.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/content_settings/host_content_settings_map.h" 8 #include "chrome/browser/content_settings/host_content_settings_map.h"
9 #include "chrome/browser/content_settings/permission_queue_controller.h" 9 #include "chrome/browser/content_settings/permission_queue_controller.h"
10 #include "chrome/browser/content_settings/permission_request_id.h" 10 #include "chrome/browser/content_settings/permission_request_id.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 113 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
114 permission_queue_controller_.reset(); 114 permission_queue_controller_.reset();
115 shutting_down_ = true; 115 shutting_down_ = true;
116 } 116 }
117 117
118 void ChromeMidiPermissionContext::RequestMidiSysExPermission( 118 void ChromeMidiPermissionContext::RequestMidiSysExPermission(
119 int render_process_id, 119 int render_process_id,
120 int render_view_id, 120 int render_view_id,
121 int bridge_id, 121 int bridge_id,
122 const GURL& requesting_frame, 122 const GURL& requesting_frame,
123 bool user_gesture,
123 const content::BrowserContext::MidiSysExPermissionCallback& callback) { 124 const content::BrowserContext::MidiSysExPermissionCallback& callback) {
124 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 125 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
125 DCHECK(!shutting_down_); 126 DCHECK(!shutting_down_);
126 127
127 // TODO(toyoshim): Support Extension's manifest declared permission. 128 // TODO(toyoshim): Support Extension's manifest declared permission.
128 // See http://crbug.com/266338. 129 // See http://crbug.com/266338.
129 130
130 content::WebContents* web_contents = 131 content::WebContents* web_contents =
131 tab_util::GetWebContentsByID(render_process_id, render_view_id); 132 tab_util::GetWebContentsByID(render_process_id, render_view_id);
132 133
133 // The page doesn't exist any more. 134 // The page doesn't exist any more.
134 if (!web_contents) 135 if (!web_contents)
135 return; 136 return;
136 137
137 const PermissionRequestID id(render_process_id, render_view_id, bridge_id, 0); 138 const PermissionRequestID id(render_process_id, render_view_id, bridge_id, 0);
138 139
139 GURL embedder = web_contents->GetURL(); 140 GURL embedder = web_contents->GetURL();
140 // |requesting_frame| can be empty and invalid when the frame is a local 141 // |requesting_frame| can be empty and invalid when the frame is a local
141 // file. Here local files should be granted to show an infobar. 142 // file. Here local files should be granted to show an infobar.
142 // Any user's action will not be stored to content settings data base. 143 // Any user's action will not be stored to content settings data base.
143 if ((!requesting_frame.is_valid() && !requesting_frame.is_empty()) || 144 if ((!requesting_frame.is_valid() && !requesting_frame.is_empty()) ||
144 !embedder.is_valid()) { 145 !embedder.is_valid()) {
145 LOG(WARNING) << "Attempt to use MIDI sysex from an invalid URL: " 146 LOG(WARNING) << "Attempt to use MIDI sysex from an invalid URL: "
146 << requesting_frame << "," << embedder 147 << requesting_frame << "," << embedder
147 << " (Web MIDI is not supported in popups)"; 148 << " (Web MIDI is not supported in popups)";
148 PermissionDecided(id, requesting_frame, embedder, callback, false); 149 PermissionDecided(id, requesting_frame, embedder, callback, false);
149 return; 150 return;
150 } 151 }
151 152
152 DecidePermission(web_contents, id, requesting_frame, embedder, callback); 153 DecidePermission(web_contents, id, requesting_frame, embedder, user_gesture,
154 callback);
153 } 155 }
154 156
155 void ChromeMidiPermissionContext::CancelMidiSysExPermissionRequest( 157 void ChromeMidiPermissionContext::CancelMidiSysExPermissionRequest(
156 int render_process_id, 158 int render_process_id,
157 int render_view_id, 159 int render_view_id,
158 int bridge_id, 160 int bridge_id,
159 const GURL& requesting_frame) { 161 const GURL& requesting_frame) {
160 CancelPendingInfobarRequest( 162 CancelPendingInfobarRequest(
161 PermissionRequestID(render_process_id, render_view_id, bridge_id, 0)); 163 PermissionRequestID(render_process_id, render_view_id, bridge_id, 0));
162 } 164 }
163 165
164 void ChromeMidiPermissionContext::DecidePermission( 166 void ChromeMidiPermissionContext::DecidePermission(
165 content::WebContents* web_contents, 167 content::WebContents* web_contents,
166 const PermissionRequestID& id, 168 const PermissionRequestID& id,
167 const GURL& requesting_frame, 169 const GURL& requesting_frame,
168 const GURL& embedder, 170 const GURL& embedder,
171 bool user_gesture,
169 const content::BrowserContext::MidiSysExPermissionCallback& callback) { 172 const content::BrowserContext::MidiSysExPermissionCallback& callback) {
170 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 173 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
171 174
172 ContentSetting content_setting = 175 ContentSetting content_setting =
173 profile_->GetHostContentSettingsMap()->GetContentSetting( 176 profile_->GetHostContentSettingsMap()->GetContentSetting(
174 requesting_frame, 177 requesting_frame,
175 embedder, 178 embedder,
176 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, 179 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
177 std::string()); 180 std::string());
178 switch (content_setting) { 181 switch (content_setting) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 } 245 }
243 246
244 void ChromeMidiPermissionContext::CancelPendingInfobarRequest( 247 void ChromeMidiPermissionContext::CancelPendingInfobarRequest(
245 const PermissionRequestID& id) { 248 const PermissionRequestID& id) {
246 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 249 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
247 if (shutting_down_) 250 if (shutting_down_)
248 return; 251 return;
249 // TODO(gbillock): Add support for cancellation to permission bubbles. 252 // TODO(gbillock): Add support for cancellation to permission bubbles.
250 GetQueueController()->CancelInfoBarRequest(id); 253 GetQueueController()->CancelInfoBarRequest(id);
251 } 254 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698