OLD | NEW |
---|---|
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 Loading... | |
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 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1637 return; | 1604 return; |
1638 | 1605 |
1639 name_ = name; | 1606 name_ = name; |
1640 SendMessageToEmbedder(new BrowserPluginMsg_UpdatedName(instance_id_, name)); | 1607 SendMessageToEmbedder(new BrowserPluginMsg_UpdatedName(instance_id_, name)); |
1641 } | 1608 } |
1642 | 1609 |
1643 void BrowserPluginGuest::RequestMediaAccessPermission( | 1610 void BrowserPluginGuest::RequestMediaAccessPermission( |
1644 WebContents* web_contents, | 1611 WebContents* web_contents, |
1645 const MediaStreamRequest& request, | 1612 const MediaStreamRequest& request, |
1646 const MediaResponseCallback& callback) { | 1613 const MediaResponseCallback& callback) { |
1647 base::DictionaryValue request_info; | 1614 if (!delegate_) { |
1648 request_info.Set( | 1615 callback.Run(MediaStreamDevices(), |
1649 browser_plugin::kURL, | 1616 MEDIA_DEVICE_INVALID_STATE, |
lazyboy
2014/04/11 20:13:20
indent
Fady Samuel
2014/04/11 21:52:31
Done.
| |
1650 base::Value::CreateStringValue(request.security_origin.spec())); | 1617 scoped_ptr<MediaStreamUI>()); |
1618 return; | |
1619 } | |
1651 | 1620 |
1652 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_MEDIA, | 1621 delegate_->RequestMediaAccessPermission(request, callback); |
1653 new MediaRequest(weak_ptr_factory_.GetWeakPtr(), | |
1654 request, | |
1655 callback), | |
1656 request_info); | |
1657 } | 1622 } |
1658 | 1623 |
1659 bool BrowserPluginGuest::PreHandleGestureEvent( | 1624 bool BrowserPluginGuest::PreHandleGestureEvent( |
1660 WebContents* source, const blink::WebGestureEvent& event) { | 1625 WebContents* source, const blink::WebGestureEvent& event) { |
1661 return event.type == blink::WebGestureEvent::GesturePinchBegin || | 1626 return event.type == blink::WebGestureEvent::GesturePinchBegin || |
1662 event.type == blink::WebGestureEvent::GesturePinchUpdate || | 1627 event.type == blink::WebGestureEvent::GesturePinchUpdate || |
1663 event.type == blink::WebGestureEvent::GesturePinchEnd; | 1628 event.type == blink::WebGestureEvent::GesturePinchEnd; |
1664 } | 1629 } |
1665 | 1630 |
1666 void BrowserPluginGuest::RunJavaScriptDialog( | 1631 void BrowserPluginGuest::RunJavaScriptDialog( |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1823 base::Value::CreateStringValue(request_method)); | 1788 base::Value::CreateStringValue(request_method)); |
1824 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); | 1789 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); |
1825 | 1790 |
1826 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, | 1791 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, |
1827 new DownloadRequest(weak_ptr_factory_.GetWeakPtr(), | 1792 new DownloadRequest(weak_ptr_factory_.GetWeakPtr(), |
1828 callback), | 1793 callback), |
1829 request_info); | 1794 request_info); |
1830 } | 1795 } |
1831 | 1796 |
1832 } // namespace content | 1797 } // namespace content |
OLD | NEW |