summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/guest_view
diff options
context:
space:
mode:
authorpaulmeyer <paulmeyer@chromium.org>2015-01-22 11:13:00 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-22 19:13:54 +0000
commit1b61eb2416aa8b922134955d7a4ef412b45b3f9e (patch)
tree6095bffb8de095d84c92f3cf11a6c70e12c35f2b /extensions/renderer/guest_view
parente5db46e6dec58a157e114d8f64e9f98a6eee3bc2 (diff)
downloadchromium_src-1b61eb2416aa8b922134955d7a4ef412b45b3f9e.zip
chromium_src-1b61eb2416aa8b922134955d7a4ef412b45b3f9e.tar.gz
chromium_src-1b61eb2416aa8b922134955d7a4ef412b45b3f9e.tar.bz2
Added the infrastructure for surfaceProxy.onResize() and SurfaceView.onResize(), as per https://docs.google.com/a/google.com/document/d/1EJfmJSK0JJsxKptSRhepnsOOwvXJNv5nnJ1pZdjGDRQ/edit?usp=sharing.
BUG=434226 Review URL: https://codereview.chromium.org/856563002 Cr-Commit-Position: refs/heads/master@{#312651}
Diffstat (limited to 'extensions/renderer/guest_view')
-rw-r--r--extensions/renderer/guest_view/extensions_guest_view_container.cc17
-rw-r--r--extensions/renderer/guest_view/extensions_guest_view_container.h11
-rw-r--r--extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc28
-rw-r--r--extensions/renderer/guest_view/guest_view_internal_custom_bindings.h6
-rw-r--r--extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc24
-rw-r--r--extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h6
6 files changed, 82 insertions, 10 deletions
diff --git a/extensions/renderer/guest_view/extensions_guest_view_container.cc b/extensions/renderer/guest_view/extensions_guest_view_container.cc
index c546c3a..3a5359f 100644
--- a/extensions/renderer/guest_view/extensions_guest_view_container.cc
+++ b/extensions/renderer/guest_view/extensions_guest_view_container.cc
@@ -147,7 +147,8 @@ ExtensionsGuestViewContainer::ExtensionsGuestViewContainer(
content::RenderFrame* render_frame)
: GuestViewContainer(render_frame),
ready_(false),
- destruction_isolate_(nullptr) {
+ destruction_isolate_(nullptr),
+ element_resize_isolate_(nullptr) {
}
ExtensionsGuestViewContainer::~ExtensionsGuestViewContainer() {
@@ -168,7 +169,7 @@ ExtensionsGuestViewContainer::~ExtensionsGuestViewContainer() {
v8::Context::Scope context_scope(context);
blink::WebScopedMicrotaskSuppression suppression;
- callback->Call(context->Global(), 0, nullptr);
+ callback->Call(context->Global(), 0 /* argc */, nullptr);
}
ExtensionsGuestViewContainer* ExtensionsGuestViewContainer::FromID(
@@ -191,6 +192,18 @@ void ExtensionsGuestViewContainer::RegisterDestructionCallback(
destruction_isolate_ = isolate;
}
+void ExtensionsGuestViewContainer::RegisterElementResizeCallback(
+ v8::Handle<v8::Function> callback,
+ v8::Isolate* isolate) {
+ element_resize_callback_.reset(callback);
+ element_resize_isolate_ = isolate;
+}
+
+void ExtensionsGuestViewContainer::DidResizeElement(const gfx::Size& old_size,
+ const gfx::Size& new_size) {
+ // TODO(paulmeyer): Call the |element_resize_callback_| callback here.
+}
+
bool ExtensionsGuestViewContainer::OnMessageReceived(
const IPC::Message& message) {
OnHandleCallback(message);
diff --git a/extensions/renderer/guest_view/extensions_guest_view_container.h b/extensions/renderer/guest_view/extensions_guest_view_container.h
index 1fbe126..6a5f9cc 100644
--- a/extensions/renderer/guest_view/extensions_guest_view_container.h
+++ b/extensions/renderer/guest_view/extensions_guest_view_container.h
@@ -13,6 +13,10 @@
#include "extensions/renderer/guest_view/guest_view_container.h"
#include "extensions/renderer/scoped_persistent.h"
+namespace gfx {
+class Size;
+}
+
namespace extensions {
class ExtensionsGuestViewContainer : public GuestViewContainer {
@@ -82,11 +86,15 @@ class ExtensionsGuestViewContainer : public GuestViewContainer {
void IssueRequest(linked_ptr<Request> request);
void RegisterDestructionCallback(v8::Handle<v8::Function> callback,
v8::Isolate* isolate);
+ void RegisterElementResizeCallback(v8::Handle<v8::Function> callback,
+ v8::Isolate* isolate);
// BrowserPluginDelegate implementation.
bool OnMessageReceived(const IPC::Message& message) override;
void SetElementInstanceID(int element_instance_id) override;
void Ready() override;
+ void DidResizeElement(const gfx::Size& old_size,
+ const gfx::Size& new_size) override;
private:
void OnHandleCallback(const IPC::Message& message);
@@ -103,6 +111,9 @@ class ExtensionsGuestViewContainer : public GuestViewContainer {
ScopedPersistent<v8::Function> destruction_callback_;
v8::Isolate* destruction_isolate_;
+ ScopedPersistent<v8::Function> element_resize_callback_;
+ v8::Isolate* element_resize_isolate_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionsGuestViewContainer);
};
diff --git a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
index c2d4293..62bbf18 100644
--- a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
+++ b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
@@ -32,6 +32,11 @@ GuestViewInternalCustomBindings::GuestViewInternalCustomBindings(
"RegisterDestructionCallback",
base::Bind(&GuestViewInternalCustomBindings::RegisterDestructionCallback,
base::Unretained(this)));
+ RouteFunction(
+ "RegisterElementResizeCallback",
+ base::Bind(
+ &GuestViewInternalCustomBindings::RegisterElementResizeCallback,
+ base::Unretained(this)));
}
void GuestViewInternalCustomBindings::AttachGuest(
@@ -135,4 +140,27 @@ void GuestViewInternalCustomBindings::RegisterDestructionCallback(
args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true));
}
+void GuestViewInternalCustomBindings::RegisterElementResizeCallback(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ // There are two parameters.
+ CHECK(args.Length() == 2);
+ // Element Instance ID.
+ CHECK(args[0]->IsInt32());
+ // Callback function.
+ CHECK(args[1]->IsFunction());
+
+ int element_instance_id = args[0]->Int32Value();
+ // An element instance ID uniquely identifies a ExtensionsGuestViewContainer
+ // within a RenderView.
+ ExtensionsGuestViewContainer* guest_view_container =
+ ExtensionsGuestViewContainer::FromID(element_instance_id);
+ if (!guest_view_container)
+ return;
+
+ guest_view_container->RegisterElementResizeCallback(
+ args[1].As<v8::Function>(), args.GetIsolate());
+
+ args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true));
+}
+
} // namespace extensions
diff --git a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.h b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.h
index b679aec..0c29435 100644
--- a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.h
+++ b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.h
@@ -45,6 +45,12 @@ class GuestViewInternalCustomBindings : public ObjectBackedNativeHandler {
// RegisterDestructionCallback takes in a single paramater, |callback|.
void RegisterDestructionCallback(
const v8::FunctionCallbackInfo<v8::Value>& args);
+
+ // RegisterElementResizeCallback registers a JavaScript callback function to
+ // be called when the element is resized. RegisterElementResizeCallback takes
+ // a single parameter, |callback|.
+ void RegisterElementResizeCallback(
+ const v8::FunctionCallbackInfo<v8::Value>& args);
};
} // namespace extensions
diff --git a/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc b/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc
index a8663ea..cdede3d 100644
--- a/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc
+++ b/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc
@@ -6,6 +6,7 @@
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
+#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_constants.h"
#include "extensions/common/extension_messages.h"
#include "extensions/common/guest_view/guest_view_constants.h"
#include "gin/arguments.h"
@@ -118,14 +119,19 @@ void MimeHandlerViewContainer::DidReceiveData(const char* data,
bool MimeHandlerViewContainer::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(MimeHandlerViewContainer, message)
- IPC_MESSAGE_HANDLER(ExtensionMsg_CreateMimeHandlerViewGuestACK,
- OnCreateMimeHandlerViewGuestACK)
- IPC_MESSAGE_HANDLER(ExtensionMsg_GuestAttached, OnGuestAttached)
- IPC_MESSAGE_HANDLER(ExtensionMsg_MimeHandlerViewGuestOnLoadCompleted,
- OnMimeHandlerViewGuestOnLoadCompleted)
- IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_MESSAGE_HANDLER(ExtensionMsg_CreateMimeHandlerViewGuestACK,
+ OnCreateMimeHandlerViewGuestACK)
+ IPC_MESSAGE_HANDLER(ExtensionMsg_GuestAttached, OnGuestAttached)
+ IPC_MESSAGE_HANDLER(ExtensionMsg_MimeHandlerViewGuestOnLoadCompleted,
+ OnMimeHandlerViewGuestOnLoadCompleted)
+ IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
- return handled;
+ return handled;
+}
+
+void MimeHandlerViewContainer::DidResizeElement(const gfx::Size& old_size,
+ const gfx::Size& new_size) {
+ element_size_ = new_size;
}
v8::Local<v8::Object> MimeHandlerViewContainer::V8ScriptableObject(
@@ -242,7 +248,9 @@ void MimeHandlerViewContainer::CreateMimeHandlerViewGuest() {
return;
render_frame()->Send(new ExtensionHostMsg_CreateMimeHandlerViewGuest(
- render_frame()->GetRoutingID(), view_id_, element_instance_id()));
+ render_frame()->GetRoutingID(),
+ view_id_, element_instance_id(),
+ element_size_));
}
} // namespace extensions
diff --git a/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h b/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h
index aaad340..105323d 100644
--- a/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h
+++ b/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h
@@ -11,6 +11,7 @@
#include "extensions/renderer/scoped_persistent.h"
#include "third_party/WebKit/public/platform/WebURLLoader.h"
#include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
+#include "ui/gfx/geometry/size.h"
#include "url/gurl.h"
#include "v8/include/v8.h"
@@ -44,6 +45,8 @@ class MimeHandlerViewContainer : public GuestViewContainer,
void Ready() override;
void DidFinishLoading() override;
void DidReceiveData(const char* data, int data_length) override;
+ void DidResizeElement(const gfx::Size& old_size,
+ const gfx::Size& new_size) override;
bool OnMessageReceived(const IPC::Message& message) override;
v8::Local<v8::Object> V8ScriptableObject(v8::Isolate*) override;
@@ -100,6 +103,9 @@ class MimeHandlerViewContainer : public GuestViewContainer,
// has been called.
bool guest_loaded_;
+ // The size of the element.
+ gfx::Size element_size_;
+
base::WeakPtrFactory<MimeHandlerViewContainer> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewContainer);