summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/resources/extensions/ad_view.js12
-rw-r--r--chrome/renderer/resources/extensions/web_view.js12
-rw-r--r--content/common/browser_plugin/browser_plugin_constants.cc3
-rw-r--r--content/common/browser_plugin/browser_plugin_constants.h3
-rw-r--r--content/renderer/browser_plugin/browser_plugin.cc20
-rw-r--r--content/renderer/browser_plugin/browser_plugin.h14
-rw-r--r--content/renderer/browser_plugin/browser_plugin_bindings.cc37
-rw-r--r--content/renderer/browser_plugin/browser_plugin_manager_impl.cc2
-rw-r--r--content/renderer/browser_plugin/mock_browser_plugin_manager.cc4
-rw-r--r--content/test/data/browser_plugin_dragging.html5
-rw-r--r--content/test/data/browser_plugin_embedder.html10
-rw-r--r--content/test/data/browser_plugin_embedder_guest_unresponsive.html3
-rw-r--r--content/test/data/browser_plugin_focus.html6
13 files changed, 96 insertions, 35 deletions
diff --git a/chrome/renderer/resources/extensions/ad_view.js b/chrome/renderer/resources/extensions/ad_view.js
index 13bc0d2..81cb42c 100644
--- a/chrome/renderer/resources/extensions/ad_view.js
+++ b/chrome/renderer/resources/extensions/ad_view.js
@@ -147,7 +147,6 @@ function AdView(adviewNode) {
AdView.prototype.createBrowserPluginNode_ = function() {
var browserPluginNode = document.createElement('object');
browserPluginNode.type = 'application/browser-plugin';
- browserPluginNode.setAttribute('api', 'adview');
// The <object> node fills in the <adview> container.
browserPluginNode.style.width = '100%';
browserPluginNode.style.height = '100%';
@@ -455,13 +454,20 @@ AdView.prototype.handleSrcMutation = function(mutation) {
*/
AdView.prototype.setupAdviewNodeEvents_ = function() {
var self = this;
- this.browserPluginNode_.addEventListener('-internal-attached', function(e) {
+ var onInstanceIdAllocated = function(e) {
var detail = e.detail ? JSON.parse(e.detail) : {};
self.instanceId_ = detail.windowId;
+ var params = {
+ 'api': 'adview'
+ };
+ self.browserPluginNode_['-internal-attach'](params);
+
for (var eventName in AD_VIEW_EXT_EVENTS) {
self.setupExtEvent_(eventName, AD_VIEW_EXT_EVENTS[eventName]);
}
- });
+ };
+ this.browserPluginNode_.addEventListener('-internal-instanceid-allocated',
+ onInstanceIdAllocated);
for (var eventName in AD_VIEW_EVENTS) {
this.setupEvent_(eventName, AD_VIEW_EVENTS[eventName]);
diff --git a/chrome/renderer/resources/extensions/web_view.js b/chrome/renderer/resources/extensions/web_view.js
index f249350..16961b9 100644
--- a/chrome/renderer/resources/extensions/web_view.js
+++ b/chrome/renderer/resources/extensions/web_view.js
@@ -127,7 +127,6 @@ function WebView(webviewNode) {
WebView.prototype.createBrowserPluginNode_ = function() {
var browserPluginNode = document.createElement('object');
browserPluginNode.type = 'application/browser-plugin';
- browserPluginNode.setAttribute('api', 'webview');
// The <object> node fills in the <webview> container.
browserPluginNode.style.width = '100%';
browserPluginNode.style.height = '100%';
@@ -359,13 +358,20 @@ WebView.prototype.handleBrowserPluginAttributeMutation_ = function(mutation) {
*/
WebView.prototype.setupWebviewNodeEvents_ = function() {
var self = this;
- this.browserPluginNode_.addEventListener('-internal-attached', function(e) {
+ var onInstanceIdAllocated = function(e) {
var detail = e.detail ? JSON.parse(e.detail) : {};
self.instanceId_ = detail.windowId;
+ var params = {
+ 'api': 'webview'
+ };
+ self.browserPluginNode_['-internal-attach'](params);
+
for (var eventName in WEB_VIEW_EXT_EVENTS) {
self.setupExtEvent_(eventName, WEB_VIEW_EXT_EVENTS[eventName]);
}
- });
+ };
+ this.browserPluginNode_.addEventListener('-internal-instanceid-allocated',
+ onInstanceIdAllocated);
for (var eventName in WEB_VIEW_EVENTS) {
this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]);
diff --git a/content/common/browser_plugin/browser_plugin_constants.cc b/content/common/browser_plugin/browser_plugin_constants.cc
index d688e9a..3752bb4 100644
--- a/content/common/browser_plugin/browser_plugin_constants.cc
+++ b/content/common/browser_plugin/browser_plugin_constants.cc
@@ -21,13 +21,14 @@ const char kMethodStop[] = "stop";
const char kMethodTerminate[] = "terminate";
// Internal method bindings.
+const char kMethodInternalAttach[] = "-internal-attach";
const char kMethodInternalAttachWindowTo[] = "-internal-attachWindowTo";
const char kMethodInternalTrackObjectLifetime[] =
"-internal-trackObjectLifetime";
const char kMethodInternalSetPermission[] = "-internal-setPermission";
// Internal events.
-const char kEventInternalAttached[] = "attached";
+const char kEventInternalInstanceIDAllocated[] = "instanceid-allocated";
const char kEventInternalTrackedObjectGone[] = "trackedobjectgone";
// Attributes.
diff --git a/content/common/browser_plugin/browser_plugin_constants.h b/content/common/browser_plugin/browser_plugin_constants.h
index cc7eb2f..4ffa7aa 100644
--- a/content/common/browser_plugin/browser_plugin_constants.h
+++ b/content/common/browser_plugin/browser_plugin_constants.h
@@ -22,12 +22,13 @@ extern const char kMethodStop[];
extern const char kMethodTerminate[];
// Internal method bindings.
+extern const char kMethodInternalAttach[];
extern const char kMethodInternalAttachWindowTo[];
extern const char kMethodInternalTrackObjectLifetime[];
extern const char kMethodInternalSetPermission[];
// Internal events
-extern const char kEventInternalAttached[];
+extern const char kEventInternalInstanceIDAllocated[];
extern const char kEventInternalTrackedObjectGone[];
// Attributes.
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc
index 5a961ba..e679b94 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -208,10 +208,6 @@ std::string BrowserPlugin::GetSrcAttribute() const {
return GetDOMAttributeValue(browser_plugin::kAttributeSrc);
}
-std::string BrowserPlugin::GetApiAttribute() const {
- return GetDOMAttributeValue(browser_plugin::kAttributeApi);
-}
-
bool BrowserPlugin::GetAutoSizeAttribute() const {
return HasDOMAttribute(browser_plugin::kAttributeAutoSize);
}
@@ -386,7 +382,7 @@ bool BrowserPlugin::UsesPendingDamageBuffer(
return damage_buffer_sequence_id_ == params.damage_buffer_sequence_id;
}
-void BrowserPlugin::Attach(int guest_instance_id) {
+void BrowserPlugin::OnInstanceIDAllocated(int guest_instance_id) {
CHECK(guest_instance_id != browser_plugin::kInstanceIDNone);
before_first_navigation_ = false;
guest_instance_id_ = guest_instance_id;
@@ -395,8 +391,10 @@ void BrowserPlugin::Attach(int guest_instance_id) {
std::map<std::string, base::Value*> props;
props[browser_plugin::kWindowID] =
new base::FundamentalValue(guest_instance_id);
- TriggerEvent(browser_plugin::kEventInternalAttached, &props);
+ TriggerEvent(browser_plugin::kEventInternalInstanceIDAllocated, &props);
+}
+void BrowserPlugin::Attach(scoped_ptr<base::DictionaryValue> extra_params) {
BrowserPluginHostMsg_Attach_Params attach_params;
attach_params.browser_plugin_instance_id = instance_id_;
attach_params.focused = ShouldGuestBeFocused();
@@ -408,16 +406,10 @@ void BrowserPlugin::Attach(int guest_instance_id) {
GetDamageBufferWithSizeParams(&attach_params.auto_size_params,
&attach_params.resize_guest_params);
- // TODO(fsamuel): These params should be populated by a new internal attach
- // API in the near future. This will permit shims that use BrowserPlugin to
- // propagate shim-specific data on attachment that will be handled by the
- // content embedder.
- base::DictionaryValue extra_params;
- extra_params.SetString(browser_plugin::kAttributeApi, GetApiAttribute());
browser_plugin_manager()->Send(
new BrowserPluginHostMsg_Attach(render_view_routing_id_,
guest_instance_id_, attach_params,
- extra_params));
+ *extra_params));
}
void BrowserPlugin::DidCommitCompositorFrame() {
@@ -762,7 +754,7 @@ bool BrowserPlugin::AttachWindowTo(const WebKit::WebNode& node, int window_id) {
if (browser_plugin->HasNavigated())
return false;
- browser_plugin->Attach(window_id);
+ browser_plugin->OnInstanceIDAllocated(window_id);
return true;
}
diff --git a/content/renderer/browser_plugin/browser_plugin.h b/content/renderer/browser_plugin/browser_plugin.h
index b3e0f4b..1457a53 100644
--- a/content/renderer/browser_plugin/browser_plugin.h
+++ b/content/renderer/browser_plugin/browser_plugin.h
@@ -66,8 +66,6 @@ class CONTENT_EXPORT BrowserPlugin :
std::string GetSrcAttribute() const;
// Parse the src attribute value of the BrowserPlugin instance.
bool ParseSrcAttribute(std::string* error_message);
- // Get the Api attribute value.
- std::string GetApiAttribute() const;
// Get the autosize attribute value.
bool GetAutoSizeAttribute() const;
// Parses the autosize attribute value.
@@ -134,12 +132,12 @@ class CONTENT_EXPORT BrowserPlugin :
// Called by browser plugin binding.
void OnEmbedderDecidedPermission(int request_id, bool allow);
- // Attaches this BrowserPlugin to a guest with the provided |instance_id|.
- // If the |instance_id| is not yet associated with a guest, a new guest
- // will be created. If the |instance_id| has not yet been allocated or the
- // embedder is not permitted access to that particular guest, then the
- // embedder will be killed.
- void Attach(int instance_id);
+ // Called when a guest instance ID has been allocated by the browser process.
+ void OnInstanceIDAllocated(int guest_instance_id);
+ // Provided that a guest instance ID has been allocated, this method attaches
+ // this BrowserPlugin instance to that guest. |extra_params| are parameters
+ // passed in by the content embedder to the browser process.
+ void Attach(scoped_ptr<base::DictionaryValue> extra_params);
// Notify the plugin about a compositor commit so that frame ACKs could be
// sent, if needed.
diff --git a/content/renderer/browser_plugin/browser_plugin_bindings.cc b/content/renderer/browser_plugin/browser_plugin_bindings.cc
index 56b8e29..adef1b3 100644
--- a/content/renderer/browser_plugin/browser_plugin_bindings.cc
+++ b/content/renderer/browser_plugin/browser_plugin_bindings.cc
@@ -14,6 +14,7 @@
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "content/common/browser_plugin/browser_plugin_constants.h"
+#include "content/public/renderer/v8_value_converter.h"
#include "content/renderer/browser_plugin/browser_plugin.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/web/WebBindings.h"
@@ -23,6 +24,7 @@
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebNode.h"
#include "third_party/WebKit/public/web/WebPluginContainer.h"
+#include "third_party/WebKit/public/web/WebView.h"
#include "third_party/npapi/bindings/npapi.h"
#include "v8/include/v8.h"
@@ -226,6 +228,40 @@ class BrowserPluginMethodBinding {
DISALLOW_COPY_AND_ASSIGN(BrowserPluginMethodBinding);
};
+class BrowserPluginBindingAttach: public BrowserPluginMethodBinding {
+ public:
+ BrowserPluginBindingAttach()
+ : BrowserPluginMethodBinding(
+ browser_plugin::kMethodInternalAttach, 1) {
+ }
+
+ virtual bool Invoke(BrowserPluginBindings* bindings,
+ const NPVariant* args,
+ NPVariant* result) OVERRIDE {
+ if (!bindings->instance()->render_view())
+ return false;
+
+ scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
+ v8::Handle<v8::Value> obj(WebKit::WebBindings::toV8Value(&args[0]));
+ scoped_ptr<base::Value> value(
+ converter->FromV8Value(obj, bindings->instance()->render_view()->
+ GetWebView()->mainFrame()->mainWorldScriptContext()));
+ if (!value)
+ return false;
+
+ if (!value->IsType(Value::TYPE_DICTIONARY))
+ return false;
+
+ scoped_ptr<base::DictionaryValue> extra_params(
+ static_cast<base::DictionaryValue*>(value.release()));
+ bindings->instance()->Attach(extra_params.Pass());
+ return true;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingAttach);
+};
+
class BrowserPluginBindingAttachWindowTo : public BrowserPluginMethodBinding {
public:
BrowserPluginBindingAttachWindowTo()
@@ -689,6 +725,7 @@ BrowserPluginBindings::BrowserPluginBindings(BrowserPlugin* instance)
np_object_ = static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(obj);
np_object_->message_channel = weak_ptr_factory_.GetWeakPtr();
+ method_bindings_.push_back(new BrowserPluginBindingAttach);
method_bindings_.push_back(new BrowserPluginBindingAttachWindowTo);
method_bindings_.push_back(new BrowserPluginBindingGetInstanceID);
method_bindings_.push_back(new BrowserPluginBindingGetGuestInstanceID);
diff --git a/content/renderer/browser_plugin/browser_plugin_manager_impl.cc b/content/renderer/browser_plugin/browser_plugin_manager_impl.cc
index 2f256eb..15c29a6 100644
--- a/content/renderer/browser_plugin/browser_plugin_manager_impl.cc
+++ b/content/renderer/browser_plugin/browser_plugin_manager_impl.cc
@@ -87,7 +87,7 @@ void BrowserPluginManagerImpl::OnAllocateInstanceIDACK(
return;
pending_allocate_guest_instance_id_requests_.Remove(
browser_plugin_instance_id);
- plugin->Attach(guest_instance_id);
+ plugin->OnInstanceIDAllocated(guest_instance_id);
}
void BrowserPluginManagerImpl::OnPluginAtPositionRequest(
diff --git a/content/renderer/browser_plugin/mock_browser_plugin_manager.cc b/content/renderer/browser_plugin/mock_browser_plugin_manager.cc
index e8cb029..e6ee005 100644
--- a/content/renderer/browser_plugin/mock_browser_plugin_manager.cc
+++ b/content/renderer/browser_plugin/mock_browser_plugin_manager.cc
@@ -43,7 +43,9 @@ void MockBrowserPluginManager::AllocateInstanceID(
void MockBrowserPluginManager::AllocateInstanceIDACK(
BrowserPlugin* browser_plugin,
int guest_instance_id) {
- browser_plugin->Attach(guest_instance_id);
+ browser_plugin->OnInstanceIDAllocated(guest_instance_id);
+ scoped_ptr<base::DictionaryValue> extra_params(new base::DictionaryValue());
+ browser_plugin->Attach(extra_params.Pass());
}
bool MockBrowserPluginManager::Send(IPC::Message* msg) {
diff --git a/content/test/data/browser_plugin_dragging.html b/content/test/data/browser_plugin_dragging.html
index 66375e0..80cc14b 100644
--- a/content/test/data/browser_plugin_dragging.html
+++ b/content/test/data/browser_plugin_dragging.html
@@ -29,6 +29,11 @@ function SetSrc(src) {
plugin = document.getElementById('plugin');
plugin.src = src;
}
+
+var plugin = document.getElementById('plugin');
+plugin.addEventListener('-internal-instanceid-allocated', function(e) {
+ plugin['-internal-attach']({});
+});
</script>
</body>
diff --git a/content/test/data/browser_plugin_embedder.html b/content/test/data/browser_plugin_embedder.html
index ec9e3fc..73ce463 100644
--- a/content/test/data/browser_plugin_embedder.html
+++ b/content/test/data/browser_plugin_embedder.html
@@ -54,7 +54,11 @@ function receiveMessage(event) {
}
}
}
- var plugin = document.getElementById('plugin');
- window.addEventListener('message', receiveMessage, false);
- plugin.addEventListener('-internal-sizechanged', sizeChanged);
+
+var plugin = document.getElementById('plugin');
+window.addEventListener('message', receiveMessage, false);
+plugin.addEventListener('-internal-sizechanged', sizeChanged);
+plugin.addEventListener('-internal-instanceid-allocated', function(e) {
+ plugin['-internal-attach']({});
+});
</script>
diff --git a/content/test/data/browser_plugin_embedder_guest_unresponsive.html b/content/test/data/browser_plugin_embedder_guest_unresponsive.html
index 734878c..f6e819b 100644
--- a/content/test/data/browser_plugin_embedder_guest_unresponsive.html
+++ b/content/test/data/browser_plugin_embedder_guest_unresponsive.html
@@ -25,4 +25,7 @@ function GuestResponsive(evt) {
var plugin = document.getElementById('plugin');
plugin.addEventListener('-internal-unresponsive', GuestUnresponsive);
plugin.addEventListener('-internal-responsive', GuestResponsive);
+ plugin.addEventListener('-internal-instanceid-allocated', function(e) {
+ plugin['-internal-attach']({});
+ });
</script>
diff --git a/content/test/data/browser_plugin_focus.html b/content/test/data/browser_plugin_focus.html
index 9d47cf3..b6b0dff 100644
--- a/content/test/data/browser_plugin_focus.html
+++ b/content/test/data/browser_plugin_focus.html
@@ -17,5 +17,11 @@
height="480"
border="0px"></object>
<button id="after" tabindex="0">After</button>
+<script type="text/javascript">
+var plugin = document.getElementById('plugin');
+plugin.addEventListener('-internal-instanceid-allocated', function(e) {
+ plugin['-internal-attach']({});
+});
+</script>
</body>
</html>