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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 235733002: <webview>: Move media request to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_geolocation_to_chrome
Patch Set: Fixed rebase Created 6 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/browser_plugin/browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 virtual void RespondImpl(bool should_allow, 100 virtual void RespondImpl(bool should_allow,
101 const std::string& user_input) OVERRIDE { 101 const std::string& user_input) OVERRIDE {
102 callback_.Run(should_allow); 102 callback_.Run(should_allow);
103 } 103 }
104 104
105 private: 105 private:
106 virtual ~DownloadRequest() {} 106 virtual ~DownloadRequest() {}
107 base::Callback<void(bool)> callback_; 107 base::Callback<void(bool)> callback_;
108 }; 108 };
109 109
110 class BrowserPluginGuest::MediaRequest : public PermissionRequest {
111 public:
112 MediaRequest(const base::WeakPtr<BrowserPluginGuest>& guest,
113 const MediaStreamRequest& request,
114 const MediaResponseCallback& callback)
115 : PermissionRequest(guest),
116 request_(request),
117 callback_(callback) {
118 RecordAction(
119 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Media"));
120 }
121
122 virtual void RespondImpl(bool should_allow,
123 const std::string& user_input) OVERRIDE {
124 WebContentsImpl* web_contents = guest_->embedder_web_contents();
125 if (should_allow && web_contents) {
126 // Re-route the request to the embedder's WebContents; the guest gets the
127 // permission this way.
128 web_contents->RequestMediaAccessPermission(request_, callback_);
129 } else {
130 // Deny the request.
131 callback_.Run(MediaStreamDevices(),
132 MEDIA_DEVICE_INVALID_STATE,
133 scoped_ptr<MediaStreamUI>());
134 }
135 }
136
137 private:
138 virtual ~MediaRequest() {}
139 MediaStreamRequest request_;
140 MediaResponseCallback callback_;
141 };
142
143 class BrowserPluginGuest::NewWindowRequest : public PermissionRequest { 110 class BrowserPluginGuest::NewWindowRequest : public PermissionRequest {
144 public: 111 public:
145 NewWindowRequest(const base::WeakPtr<BrowserPluginGuest>& guest, 112 NewWindowRequest(const base::WeakPtr<BrowserPluginGuest>& guest,
146 int instance_id) 113 int instance_id)
147 : PermissionRequest(guest), 114 : PermissionRequest(guest),
148 instance_id_(instance_id) { 115 instance_id_(instance_id) {
149 RecordAction( 116 RecordAction(
150 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.NewWindow ")); 117 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.NewWindow "));
151 } 118 }
152 119
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 return; 1569 return;
1603 1570
1604 name_ = name; 1571 name_ = name;
1605 SendMessageToEmbedder(new BrowserPluginMsg_UpdatedName(instance_id_, name)); 1572 SendMessageToEmbedder(new BrowserPluginMsg_UpdatedName(instance_id_, name));
1606 } 1573 }
1607 1574
1608 void BrowserPluginGuest::RequestMediaAccessPermission( 1575 void BrowserPluginGuest::RequestMediaAccessPermission(
1609 WebContents* web_contents, 1576 WebContents* web_contents,
1610 const MediaStreamRequest& request, 1577 const MediaStreamRequest& request,
1611 const MediaResponseCallback& callback) { 1578 const MediaResponseCallback& callback) {
1612 base::DictionaryValue request_info; 1579 if (!delegate_) {
1613 request_info.Set( 1580 callback.Run(MediaStreamDevices(),
1614 browser_plugin::kURL, 1581 MEDIA_DEVICE_INVALID_STATE,
1615 base::Value::CreateStringValue(request.security_origin.spec())); 1582 scoped_ptr<MediaStreamUI>());
1583 return;
1584 }
1616 1585
1617 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_MEDIA, 1586 delegate_->RequestMediaAccessPermission(request, callback);
1618 new MediaRequest(weak_ptr_factory_.GetWeakPtr(),
1619 request,
1620 callback),
1621 request_info);
1622 } 1587 }
1623 1588
1624 bool BrowserPluginGuest::PreHandleGestureEvent( 1589 bool BrowserPluginGuest::PreHandleGestureEvent(
1625 WebContents* source, const blink::WebGestureEvent& event) { 1590 WebContents* source, const blink::WebGestureEvent& event) {
1626 return event.type == blink::WebGestureEvent::GesturePinchBegin || 1591 return event.type == blink::WebGestureEvent::GesturePinchBegin ||
1627 event.type == blink::WebGestureEvent::GesturePinchUpdate || 1592 event.type == blink::WebGestureEvent::GesturePinchUpdate ||
1628 event.type == blink::WebGestureEvent::GesturePinchEnd; 1593 event.type == blink::WebGestureEvent::GesturePinchEnd;
1629 } 1594 }
1630 1595
1631 void BrowserPluginGuest::RunJavaScriptDialog( 1596 void BrowserPluginGuest::RunJavaScriptDialog(
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 base::Value::CreateStringValue(request_method)); 1753 base::Value::CreateStringValue(request_method));
1789 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); 1754 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url));
1790 1755
1791 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, 1756 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD,
1792 new DownloadRequest(weak_ptr_factory_.GetWeakPtr(), 1757 new DownloadRequest(weak_ptr_factory_.GetWeakPtr(),
1793 callback), 1758 callback),
1794 request_info); 1759 request_info);
1795 } 1760 }
1796 1761
1797 } // namespace content 1762 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/public/browser/browser_plugin_guest_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698