OLD | NEW |
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // TODO(toyoshim): Support Extension's manifest declared permission. | 43 // TODO(toyoshim): Support Extension's manifest declared permission. |
44 // http://crbug.com/266338 . | 44 // http://crbug.com/266338 . |
45 | 45 |
46 content::WebContents* web_contents = | 46 content::WebContents* web_contents = |
47 tab_util::GetWebContentsByID(render_process_id, render_view_id); | 47 tab_util::GetWebContentsByID(render_process_id, render_view_id); |
48 | 48 |
49 // The page doesn't exist any more. | 49 // The page doesn't exist any more. |
50 if (!web_contents) | 50 if (!web_contents) |
51 return; | 51 return; |
52 | 52 |
53 const PermissionRequestID id(render_process_id, render_view_id, bridge_id); | 53 const PermissionRequestID id(render_process_id, render_view_id, bridge_id, 0); |
54 | 54 |
55 GURL embedder = web_contents->GetURL(); | 55 GURL embedder = web_contents->GetURL(); |
56 if (!requesting_frame.is_valid() || !embedder.is_valid()) { | 56 if (!requesting_frame.is_valid() || !embedder.is_valid()) { |
57 LOG(WARNING) << "Attempt to use MIDI sysex from an invalid URL: " | 57 LOG(WARNING) << "Attempt to use MIDI sysex from an invalid URL: " |
58 << requesting_frame << "," << embedder | 58 << requesting_frame << "," << embedder |
59 << " (Web MIDI is not supported in popups)"; | 59 << " (Web MIDI is not supported in popups)"; |
60 PermissionDecided(id, requesting_frame, embedder, callback, false); | 60 PermissionDecided(id, requesting_frame, embedder, callback, false); |
61 return; | 61 return; |
62 } | 62 } |
63 | 63 |
64 DecidePermission(id, requesting_frame, embedder, callback); | 64 DecidePermission(id, requesting_frame, embedder, callback); |
65 } | 65 } |
66 | 66 |
67 void ChromeMIDIPermissionContext::CancelMIDISysExPermissionRequest( | 67 void ChromeMIDIPermissionContext::CancelMIDISysExPermissionRequest( |
68 int render_process_id, | 68 int render_process_id, |
69 int render_view_id, | 69 int render_view_id, |
70 int bridge_id, | 70 int bridge_id, |
71 const GURL& requesting_frame) { | 71 const GURL& requesting_frame) { |
72 CancelPendingInfoBarRequest( | 72 CancelPendingInfobarRequest( |
73 PermissionRequestID(render_process_id, render_view_id, bridge_id)); | 73 PermissionRequestID(render_process_id, render_view_id, bridge_id, 0)); |
74 } | 74 } |
75 | 75 |
76 void ChromeMIDIPermissionContext::DecidePermission( | 76 void ChromeMIDIPermissionContext::DecidePermission( |
77 const PermissionRequestID& id, | 77 const PermissionRequestID& id, |
78 const GURL& requesting_frame, | 78 const GURL& requesting_frame, |
79 const GURL& embedder, | 79 const GURL& embedder, |
80 const content::BrowserContext::MIDISysExPermissionCallback& callback) { | 80 const content::BrowserContext::MIDISysExPermissionCallback& callback) { |
81 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 81 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
82 | 82 |
83 ContentSetting content_setting = | 83 ContentSetting content_setting = |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 PermissionQueueController* ChromeMIDIPermissionContext::GetQueueController() { | 134 PermissionQueueController* ChromeMIDIPermissionContext::GetQueueController() { |
135 if (!permission_queue_controller_) { | 135 if (!permission_queue_controller_) { |
136 permission_queue_controller_.reset( | 136 permission_queue_controller_.reset( |
137 new PermissionQueueController(profile_, | 137 new PermissionQueueController(profile_, |
138 CONTENT_SETTINGS_TYPE_MIDI_SYSEX)); | 138 CONTENT_SETTINGS_TYPE_MIDI_SYSEX)); |
139 } | 139 } |
140 return permission_queue_controller_.get(); | 140 return permission_queue_controller_.get(); |
141 } | 141 } |
142 | 142 |
143 void ChromeMIDIPermissionContext::CancelPendingInfoBarRequest( | 143 void ChromeMIDIPermissionContext::CancelPendingInfobarRequest( |
144 const PermissionRequestID& id) { | 144 const PermissionRequestID& id) { |
145 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 145 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
146 if (shutting_down_) | 146 if (shutting_down_) |
147 return; | 147 return; |
148 GetQueueController()->CancelInfoBarRequest(id); | 148 GetQueueController()->CancelInfoBarRequest(id); |
149 } | 149 } |
OLD | NEW |