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

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

Issue 38043004: Cancel MIDI permission request infobar on MIDIAccess stop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delay "requests_.Remove(it.GetCurrentKey());" until we're done using |it|. Created 7 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/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 16 matching lines...) Expand all
27 27
28 void ChromeMIDIPermissionContext::Shutdown() { 28 void ChromeMIDIPermissionContext::Shutdown() {
29 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 29 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
30 permission_queue_controller_.reset(); 30 permission_queue_controller_.reset();
31 shutting_down_ = true; 31 shutting_down_ = true;
32 } 32 }
33 33
34 void ChromeMIDIPermissionContext::RequestMIDISysExPermission( 34 void ChromeMIDIPermissionContext::RequestMIDISysExPermission(
35 int render_process_id, 35 int render_process_id,
36 int render_view_id, 36 int render_view_id,
37 int bridge_id,
37 const GURL& requesting_frame, 38 const GURL& requesting_frame,
38 const content::BrowserContext::MIDISysExPermissionCallback& callback) { 39 const content::BrowserContext::MIDISysExPermissionCallback& callback) {
39 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 40 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
40 DCHECK(!shutting_down_); 41 DCHECK(!shutting_down_);
41 42
42 // TODO(toyoshim): Support Extension's manifest declared permission. 43 // TODO(toyoshim): Support Extension's manifest declared permission.
43 // http://crbug.com/266338 . 44 // http://crbug.com/266338 .
44 45
45 content::WebContents* web_contents = 46 content::WebContents* web_contents =
46 tab_util::GetWebContentsByID(render_process_id, render_view_id); 47 tab_util::GetWebContentsByID(render_process_id, render_view_id);
47 48
48 // The page doesn't exist any more. 49 // The page doesn't exist any more.
49 if (!web_contents) 50 if (!web_contents)
50 return; 51 return;
51 52
52 const PermissionRequestID id(render_process_id, render_view_id, 0); 53 const PermissionRequestID id(render_process_id, render_view_id, bridge_id);
53 54
54 GURL embedder = web_contents->GetURL(); 55 GURL embedder = web_contents->GetURL();
55 if (!requesting_frame.is_valid() || !embedder.is_valid()) { 56 if (!requesting_frame.is_valid() || !embedder.is_valid()) {
56 LOG(WARNING) << "Attempt to use MIDI sysex from an invalid URL: " 57 LOG(WARNING) << "Attempt to use MIDI sysex from an invalid URL: "
57 << requesting_frame << "," << embedder 58 << requesting_frame << "," << embedder
58 << " (Web MIDI is not supported in popups)"; 59 << " (Web MIDI is not supported in popups)";
59 PermissionDecided(id, requesting_frame, embedder, callback, false); 60 PermissionDecided(id, requesting_frame, embedder, callback, false);
60 return; 61 return;
61 } 62 }
62 63
63 DecidePermission(id, requesting_frame, embedder, callback); 64 DecidePermission(id, requesting_frame, embedder, callback);
64 } 65 }
65 66
67 void ChromeMIDIPermissionContext::CancelMIDISysExPermissionRequest(
68 int render_process_id,
69 int render_view_id,
70 int bridge_id,
71 const GURL& requesting_frame) {
72 CancelPendingInfoBarRequest(
73 PermissionRequestID(render_process_id, render_view_id, bridge_id));
74 }
75
66 void ChromeMIDIPermissionContext::DecidePermission( 76 void ChromeMIDIPermissionContext::DecidePermission(
67 const PermissionRequestID& id, 77 const PermissionRequestID& id,
68 const GURL& requesting_frame, 78 const GURL& requesting_frame,
69 const GURL& embedder, 79 const GURL& embedder,
70 const content::BrowserContext::MIDISysExPermissionCallback& callback) { 80 const content::BrowserContext::MIDISysExPermissionCallback& callback) {
71 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 81 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
72 82
73 ContentSetting content_setting = 83 ContentSetting content_setting =
74 profile_->GetHostContentSettingsMap()->GetContentSetting( 84 profile_->GetHostContentSettingsMap()->GetContentSetting(
75 requesting_frame, 85 requesting_frame,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 132 }
123 133
124 PermissionQueueController* ChromeMIDIPermissionContext::GetQueueController() { 134 PermissionQueueController* ChromeMIDIPermissionContext::GetQueueController() {
125 if (!permission_queue_controller_) { 135 if (!permission_queue_controller_) {
126 permission_queue_controller_.reset( 136 permission_queue_controller_.reset(
127 new PermissionQueueController(profile_, 137 new PermissionQueueController(profile_,
128 CONTENT_SETTINGS_TYPE_MIDI_SYSEX)); 138 CONTENT_SETTINGS_TYPE_MIDI_SYSEX));
129 } 139 }
130 return permission_queue_controller_.get(); 140 return permission_queue_controller_.get();
131 } 141 }
142
143 void ChromeMIDIPermissionContext::CancelPendingInfoBarRequest(
144 const PermissionRequestID& id) {
145 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
146 if (shutting_down_)
147 return;
148 GetQueueController()->CancelInfoBarRequest(id);
149 }
OLDNEW
« no previous file with comments | « chrome/browser/media/chrome_midi_permission_context.h ('k') | chrome/browser/profiles/off_the_record_profile_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698