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

Unified Diff: content/renderer/browser_plugin/browser_plugin_impl.cc

Issue 11826005: Browser Plugin: Implement BrowserPluginObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/browser_plugin/browser_plugin_impl.cc
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin_impl.cc
similarity index 77%
rename from content/renderer/browser_plugin/browser_plugin.cc
rename to content/renderer/browser_plugin/browser_plugin_impl.cc
index 75af8912790bcf84ebd5744dde7711472fb41a1a..132aaba069c4da212fa2ef518b35357e0053f244 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/renderer/browser_plugin/browser_plugin.h"
+#include "content/renderer/browser_plugin/browser_plugin_impl.h"
#include "base/json/json_string_value_serializer.h"
#include "base/message_loop.h"
@@ -12,6 +12,7 @@
#include "content/common/browser_plugin_messages.h"
#include "content/common/view_messages.h"
#include "content/public/common/content_client.h"
+#include "content/public/renderer/browser_plugin/browser_plugin_observer.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/browser_plugin/browser_plugin_bindings.h"
#include "content/renderer/browser_plugin/browser_plugin_manager.h"
@@ -97,7 +98,7 @@ static std::string TerminationStatusToString(base::TerminationStatus status) {
}
}
-BrowserPlugin::BrowserPlugin(
+BrowserPluginImpl::BrowserPluginImpl(
int instance_id,
RenderViewImpl* render_view,
WebKit::WebFrame* frame,
@@ -132,19 +133,34 @@ BrowserPlugin::BrowserPlugin(
bindings_.reset(new BrowserPluginBindings(this));
ParseAttributes(params);
+ GetContentClient()->renderer()->BrowserPluginCreated(this);
}
-BrowserPlugin::~BrowserPlugin() {
+BrowserPluginImpl::~BrowserPluginImpl() {
browser_plugin_manager()->RemoveBrowserPlugin(instance_id_);
- browser_plugin_manager()->Send(
- new BrowserPluginHostMsg_PluginDestroyed(
- render_view_routing_id_,
- instance_id_));
+ Send(new BrowserPluginHostMsg_PluginDestroyed(
+ render_view_routing_id_,
+ instance_id_));
+}
+
+void BrowserPluginImpl::AddObserver(BrowserPluginObserver* observer) {
+ observers_.AddObserver(observer);
}
-bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) {
+void BrowserPluginImpl::RemoveObserver(BrowserPluginObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+bool BrowserPluginImpl::OnMessageReceived(const IPC::Message& message) {
+ ObserverListBase<BrowserPluginObserver>::Iterator it(observers_);
sadrul 2013/01/09 15:21:54 Check observers_.might_have_observers() first.
Fady Samuel 2013/01/09 17:41:24 Done.
+ BrowserPluginObserver* observer;
+ while ((observer = it.GetNext()) != NULL) {
+ if (observer->OnMessageReceived(message))
+ return true;
+ }
+
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message)
+ IPC_BEGIN_MESSAGE_MAP(BrowserPluginImpl, message)
IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus)
IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady,
OnGuestContentWindowReady)
@@ -165,7 +181,7 @@ bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) {
return handled;
}
-void BrowserPlugin::UpdateDOMAttribute(
+void BrowserPluginImpl::UpdateDOMAttribute(
const std::string& attribute_name,
const std::string& attribute_value) {
if (!container())
@@ -186,8 +202,8 @@ void BrowserPlugin::UpdateDOMAttribute(
}
}
-bool BrowserPlugin::SetSrcAttribute(const std::string& src,
- std::string* error_message) {
+bool BrowserPluginImpl::SetSrcAttribute(const std::string& src,
+ std::string* error_message) {
if (!valid_partition_id_) {
*error_message = kErrorInvalidPartition;
return false;
@@ -207,18 +223,16 @@ bool BrowserPlugin::SetSrcAttribute(const std::string& src,
create_guest_params.visible = visible_;
GetDamageBufferWithSizeParams(&create_guest_params.auto_size_params,
&create_guest_params.resize_guest_params);
- browser_plugin_manager()->Send(
- new BrowserPluginHostMsg_CreateGuest(
- render_view_routing_id_,
- instance_id_,
- create_guest_params));
+ Send(new BrowserPluginHostMsg_CreateGuest(
+ render_view_routing_id_,
+ instance_id_,
+ create_guest_params));
}
- browser_plugin_manager()->Send(
- new BrowserPluginHostMsg_NavigateGuest(
- render_view_routing_id_,
- instance_id_,
- src));
+ Send(new BrowserPluginHostMsg_NavigateGuest(
+ render_view_routing_id_,
+ instance_id_,
+ src));
// Record that we sent a NavigateGuest message to embedder.
// Once this instance has navigated, the storage partition cannot be changed,
// so this value is used for enforcing this.
@@ -227,7 +241,7 @@ bool BrowserPlugin::SetSrcAttribute(const std::string& src,
return true;
}
-void BrowserPlugin::SetAutoSizeAttribute(bool auto_size) {
+void BrowserPluginImpl::SetAutoSizeAttribute(bool auto_size) {
if (auto_size_ == auto_size)
return;
auto_size_ = auto_size;
@@ -235,7 +249,7 @@ void BrowserPlugin::SetAutoSizeAttribute(bool auto_size) {
UpdateGuestAutoSizeState();
}
-void BrowserPlugin::PopulateAutoSizeParameters(
+void BrowserPluginImpl::PopulateAutoSizeParameters(
BrowserPluginHostMsg_AutoSize_Params* params) {
// If maxWidth or maxHeight have not been set, set them to the container size.
max_height_ = max_height_ ? max_height_ : height();
@@ -249,24 +263,25 @@ void BrowserPlugin::PopulateAutoSizeParameters(
params->min_size = gfx::Size(min_width_, min_height_);
}
-void BrowserPlugin::UpdateGuestAutoSizeState() {
+void BrowserPluginImpl::UpdateGuestAutoSizeState() {
// If we haven't yet heard back from the guest about the last resize request,
// then we don't issue another request until we do in
- // BrowserPlugin::UpdateRect.
+ // BrowserPluginImpl::UpdateRect.
if (!navigate_src_sent_ || !resize_ack_received_)
return;
BrowserPluginHostMsg_AutoSize_Params auto_size_params;
BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params;
GetDamageBufferWithSizeParams(&auto_size_params, &resize_guest_params);
resize_ack_received_ = false;
- browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetAutoSize(
+ Send(new BrowserPluginHostMsg_SetAutoSize(
render_view_routing_id_,
instance_id_,
auto_size_params,
resize_guest_params));
}
-void BrowserPlugin::SizeChangedDueToAutoSize(const gfx::Size& old_view_size) {
+void BrowserPluginImpl::SizeChangedDueToAutoSize(
+ const gfx::Size& old_view_size) {
size_changed_in_flight_ = false;
std::map<std::string, base::Value*> props;
@@ -278,30 +293,33 @@ void BrowserPlugin::SizeChangedDueToAutoSize(const gfx::Size& old_view_size) {
}
// static
-bool BrowserPlugin::UsesDamageBuffer(
+bool BrowserPluginImpl::UsesDamageBuffer(
const BrowserPluginMsg_UpdateRect_Params& params) {
return params.damage_buffer_sequence_id != 0;
}
-bool BrowserPlugin::UsesPendingDamageBuffer(
+bool BrowserPluginImpl::UsesPendingDamageBuffer(
const BrowserPluginMsg_UpdateRect_Params& params) {
if (!pending_damage_buffer_.get())
return false;
return damage_buffer_sequence_id_ == params.damage_buffer_sequence_id;
}
-void BrowserPlugin::OnAdvanceFocus(int instance_id, bool reverse) {
+void BrowserPluginImpl::OnAdvanceFocus(int instance_id, bool reverse) {
DCHECK(render_view_);
render_view_->GetWebView()->advanceFocus(reverse);
}
-void BrowserPlugin::OnGuestContentWindowReady(int instance_id,
- int content_window_routing_id) {
+void BrowserPluginImpl::OnGuestContentWindowReady(
+ int instance_id,
+ int content_window_routing_id) {
DCHECK(content_window_routing_id != MSG_ROUTING_NONE);
content_window_routing_id_ = content_window_routing_id;
}
-void BrowserPlugin::OnGuestGone(int instance_id, int process_id, int status) {
+void BrowserPluginImpl::OnGuestGone(int instance_id,
+ int process_id,
+ int status) {
// We fire the event listeners before painting the sad graphic to give the
// developer an opportunity to display an alternative overlay image on crash.
std::string termination_status = TerminationStatusToString(
@@ -312,7 +330,7 @@ void BrowserPlugin::OnGuestGone(int instance_id, int process_id, int status) {
// Event listeners may remove the BrowserPlugin from the document. If that
// happens, the BrowserPlugin will be scheduled for later deletion (see
- // BrowserPlugin::destroy()). That will clear the container_ reference,
+ // BrowserPluginImpl::destroy()). That will clear the container_ reference,
// but leave other member variables valid below.
TriggerEvent(kEventExit, &props);
@@ -326,22 +344,22 @@ void BrowserPlugin::OnGuestGone(int instance_id, int process_id, int status) {
container_->invalidate();
}
-void BrowserPlugin::OnGuestResponsive(int instance_id, int process_id) {
+void BrowserPluginImpl::OnGuestResponsive(int instance_id, int process_id) {
std::map<std::string, base::Value*> props;
props[kProcessId] = base::Value::CreateIntegerValue(process_id);
TriggerEvent(kEventResponsive, &props);
}
-void BrowserPlugin::OnGuestUnresponsive(int instance_id, int process_id) {
+void BrowserPluginImpl::OnGuestUnresponsive(int instance_id, int process_id) {
std::map<std::string, base::Value*> props;
props[kProcessId] = base::Value::CreateIntegerValue(process_id);
TriggerEvent(kEventUnresponsive, &props);
}
-void BrowserPlugin::OnLoadAbort(int instance_id,
- const GURL& url,
- bool is_top_level,
- const std::string& type) {
+void BrowserPluginImpl::OnLoadAbort(int instance_id,
+ const GURL& url,
+ bool is_top_level,
+ const std::string& type) {
std::map<std::string, base::Value*> props;
props[kURL] = base::Value::CreateStringValue(url.spec());
props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level);
@@ -349,7 +367,7 @@ void BrowserPlugin::OnLoadAbort(int instance_id,
TriggerEvent(kEventLoadAbort, &props);
}
-void BrowserPlugin::OnLoadCommit(
+void BrowserPluginImpl::OnLoadCommit(
int instance_id,
const BrowserPluginMsg_LoadCommit_Params& params) {
// If the guest has just committed a new navigation then it is no longer
@@ -369,10 +387,10 @@ void BrowserPlugin::OnLoadCommit(
TriggerEvent(kEventLoadCommit, &props);
}
-void BrowserPlugin::OnLoadRedirect(int instance_id,
- const GURL& old_url,
- const GURL& new_url,
- bool is_top_level) {
+void BrowserPluginImpl::OnLoadRedirect(int instance_id,
+ const GURL& old_url,
+ const GURL& new_url,
+ bool is_top_level) {
std::map<std::string, base::Value*> props;
props[kOldURL] = base::Value::CreateStringValue(old_url.spec());
props[kNewURL] = base::Value::CreateStringValue(new_url.spec());
@@ -380,9 +398,9 @@ void BrowserPlugin::OnLoadRedirect(int instance_id,
TriggerEvent(kEventLoadRedirect, &props);
}
-void BrowserPlugin::OnLoadStart(int instance_id,
- const GURL& url,
- bool is_top_level) {
+void BrowserPluginImpl::OnLoadStart(int instance_id,
+ const GURL& url,
+ bool is_top_level) {
std::map<std::string, base::Value*> props;
props[kURL] = base::Value::CreateStringValue(url.spec());
props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level);
@@ -390,15 +408,16 @@ void BrowserPlugin::OnLoadStart(int instance_id,
TriggerEvent(kEventLoadStart, &props);
}
-void BrowserPlugin::OnLoadStop(int instance_id) {
+void BrowserPluginImpl::OnLoadStop(int instance_id) {
TriggerEvent(kEventLoadStop, NULL);
}
-void BrowserPlugin::OnSetCursor(int instance_id, const WebCursor& cursor) {
+void BrowserPluginImpl::OnSetCursor(int instance_id, const WebCursor& cursor) {
cursor_ = cursor;
}
-void BrowserPlugin::OnShouldAcceptTouchEvents(int instance_id, bool accept) {
+void BrowserPluginImpl::OnShouldAcceptTouchEvents(int instance_id,
+ bool accept) {
if (container()) {
container()->requestTouchEventType(accept ?
WebKit::WebPluginContainer::TouchEventRequestTypeRaw :
@@ -406,7 +425,7 @@ void BrowserPlugin::OnShouldAcceptTouchEvents(int instance_id, bool accept) {
}
}
-void BrowserPlugin::OnUpdateRect(
+void BrowserPluginImpl::OnUpdateRect(
int instance_id,
const BrowserPluginMsg_UpdateRect_Params& params) {
bool use_new_damage_buffer = !backing_store_;
@@ -439,7 +458,7 @@ void BrowserPlugin::OnUpdateRect(
GetDamageBufferWithSizeParams(&auto_size_params,
&resize_guest_params);
}
- browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateRect_ACK(
+ Send(new BrowserPluginHostMsg_UpdateRect_ACK(
render_view_routing_id_,
instance_id_,
auto_size_params,
@@ -464,7 +483,7 @@ void BrowserPlugin::OnUpdateRect(
size_changed_in_flight_ = true;
MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(&BrowserPlugin::SizeChangedDueToAutoSize,
+ base::Bind(&BrowserPluginImpl::SizeChangedDueToAutoSize,
base::Unretained(this),
old_view_size));
}
@@ -506,14 +525,14 @@ void BrowserPlugin::OnUpdateRect(
if (container_)
container_->invalidate();
PopulateAutoSizeParameters(&auto_size_params);
- browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateRect_ACK(
+ Send(new BrowserPluginHostMsg_UpdateRect_ACK(
render_view_routing_id_,
instance_id_,
auto_size_params,
resize_guest_params));
}
-void BrowserPlugin::SetMaxHeightAttribute(int max_height) {
+void BrowserPluginImpl::SetMaxHeightAttribute(int max_height) {
if (max_height_ == max_height)
return;
max_height_ = max_height;
@@ -522,7 +541,7 @@ void BrowserPlugin::SetMaxHeightAttribute(int max_height) {
UpdateGuestAutoSizeState();
}
-void BrowserPlugin::SetMaxWidthAttribute(int max_width) {
+void BrowserPluginImpl::SetMaxWidthAttribute(int max_width) {
if (max_width_ == max_width)
return;
max_width_ = max_width;
@@ -531,7 +550,7 @@ void BrowserPlugin::SetMaxWidthAttribute(int max_width) {
UpdateGuestAutoSizeState();
}
-void BrowserPlugin::SetMinHeightAttribute(int min_height) {
+void BrowserPluginImpl::SetMinHeightAttribute(int min_height) {
if (min_height_ == min_height)
return;
min_height_ = min_height;
@@ -540,7 +559,7 @@ void BrowserPlugin::SetMinHeightAttribute(int min_height) {
UpdateGuestAutoSizeState();
}
-void BrowserPlugin::SetMinWidthAttribute(int min_width) {
+void BrowserPluginImpl::SetMinWidthAttribute(int min_width) {
if (min_width_ == min_width)
return;
min_width_ = min_width;
@@ -549,11 +568,11 @@ void BrowserPlugin::SetMinWidthAttribute(int min_width) {
UpdateGuestAutoSizeState();
}
-bool BrowserPlugin::InAutoSizeBounds(const gfx::Size& size) const {
+bool BrowserPluginImpl::InAutoSizeBounds(const gfx::Size& size) const {
return size.width() <= max_width_ && size.height() <= max_height_;
}
-NPObject* BrowserPlugin::GetContentWindow() const {
+NPObject* BrowserPluginImpl::GetContentWindow() const {
if (content_window_routing_id_ == MSG_ROUTING_NONE)
return NULL;
RenderViewImpl* guest_render_view = static_cast<RenderViewImpl*>(
@@ -564,7 +583,7 @@ NPObject* BrowserPlugin::GetContentWindow() const {
return guest_frame->windowObject();
}
-std::string BrowserPlugin::GetPartitionAttribute() const {
+std::string BrowserPluginImpl::GetPartitionAttribute() const {
std::string value;
if (persist_storage_)
value.append(kPersistPrefix);
@@ -573,17 +592,17 @@ std::string BrowserPlugin::GetPartitionAttribute() const {
return value;
}
-bool BrowserPlugin::CanGoBack() const {
+bool BrowserPluginImpl::CanGoBack() const {
return nav_entry_count_ > 1 && current_nav_entry_index_ > 0;
}
-bool BrowserPlugin::CanGoForward() const {
+bool BrowserPluginImpl::CanGoForward() const {
return current_nav_entry_index_ >= 0 &&
current_nav_entry_index_ < (nav_entry_count_ - 1);
}
-bool BrowserPlugin::SetPartitionAttribute(const std::string& partition_id,
- std::string* error_message) {
+bool BrowserPluginImpl::SetPartitionAttribute(const std::string& partition_id,
+ std::string* error_message) {
if (navigate_src_sent_) {
*error_message = kErrorAlreadyNavigated;
return false;
@@ -615,7 +634,7 @@ bool BrowserPlugin::SetPartitionAttribute(const std::string& partition_id,
return true;
}
-void BrowserPlugin::ParseAttributes(const WebKit::WebPluginParams& params) {
+void BrowserPluginImpl::ParseAttributes(const WebKit::WebPluginParams& params) {
std::string src;
// Get the src attribute from the attributes vector
@@ -635,14 +654,15 @@ void BrowserPlugin::ParseAttributes(const WebKit::WebPluginParams& params) {
SetSrcAttribute(src, &error);
}
-float BrowserPlugin::GetDeviceScaleFactor() const {
+float BrowserPluginImpl::GetDeviceScaleFactor() const {
if (!render_view_)
return 1.0f;
return render_view_->GetWebView()->deviceScaleFactor();
}
-void BrowserPlugin::TriggerEvent(const std::string& event_name,
- std::map<std::string, base::Value*>* props) {
+void BrowserPluginImpl::TriggerEvent(
+ const std::string& event_name,
+ std::map<std::string, base::Value*>* props) {
if (!container() || !container()->element().document().frame())
return;
v8::HandleScope handle_scope;
@@ -677,56 +697,50 @@ void BrowserPlugin::TriggerEvent(const std::string& event_name,
container()->element().dispatchEvent(event);
}
-void BrowserPlugin::Back() {
+void BrowserPluginImpl::Back() {
if (!navigate_src_sent_)
return;
- browser_plugin_manager()->Send(
- new BrowserPluginHostMsg_Go(render_view_routing_id_,
- instance_id_, -1));
+ Send(new BrowserPluginHostMsg_Go(render_view_routing_id_,
+ instance_id_, -1));
}
-void BrowserPlugin::Forward() {
+void BrowserPluginImpl::Forward() {
if (!navigate_src_sent_)
return;
- browser_plugin_manager()->Send(
- new BrowserPluginHostMsg_Go(render_view_routing_id_,
- instance_id_, 1));
+ Send(new BrowserPluginHostMsg_Go(render_view_routing_id_,
+ instance_id_, 1));
}
-void BrowserPlugin::Go(int relative_index) {
+void BrowserPluginImpl::Go(int relative_index) {
if (!navigate_src_sent_)
return;
- browser_plugin_manager()->Send(
- new BrowserPluginHostMsg_Go(render_view_routing_id_,
- instance_id_,
- relative_index));
+ Send(new BrowserPluginHostMsg_Go(render_view_routing_id_,
+ instance_id_,
+ relative_index));
}
-void BrowserPlugin::TerminateGuest() {
+void BrowserPluginImpl::TerminateGuest() {
if (!navigate_src_sent_)
return;
- browser_plugin_manager()->Send(
- new BrowserPluginHostMsg_TerminateGuest(render_view_routing_id_,
- instance_id_));
+ Send(new BrowserPluginHostMsg_TerminateGuest(render_view_routing_id_,
+ instance_id_));
}
-void BrowserPlugin::Stop() {
+void BrowserPluginImpl::Stop() {
if (!navigate_src_sent_)
return;
- browser_plugin_manager()->Send(
- new BrowserPluginHostMsg_Stop(render_view_routing_id_,
- instance_id_));
+ Send(new BrowserPluginHostMsg_Stop(render_view_routing_id_,
+ instance_id_));
}
-void BrowserPlugin::Reload() {
+void BrowserPluginImpl::Reload() {
if (!navigate_src_sent_)
return;
- browser_plugin_manager()->Send(
- new BrowserPluginHostMsg_Reload(render_view_routing_id_,
- instance_id_));
+ Send(new BrowserPluginHostMsg_Reload(render_view_routing_id_,
+ instance_id_));
}
-void BrowserPlugin::SetEmbedderFocus(bool focused) {
+void BrowserPluginImpl::SetEmbedderFocus(bool focused) {
if (embedder_focused_ == focused)
return;
@@ -737,31 +751,31 @@ void BrowserPlugin::SetEmbedderFocus(bool focused) {
UpdateGuestFocusState();
}
-void BrowserPlugin::UpdateGuestFocusState() {
+void BrowserPluginImpl::UpdateGuestFocusState() {
if (!navigate_src_sent_)
return;
bool should_be_focused = ShouldGuestBeFocused();
- browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetFocus(
+ Send(new BrowserPluginHostMsg_SetFocus(
render_view_routing_id_,
instance_id_,
should_be_focused));
}
-bool BrowserPlugin::ShouldGuestBeFocused() const {
+bool BrowserPluginImpl::ShouldGuestBeFocused() const {
return plugin_focused_ && embedder_focused_;
}
-WebKit::WebPluginContainer* BrowserPlugin::container() const {
+WebKit::WebPluginContainer* BrowserPluginImpl::container() const {
return container_;
}
-bool BrowserPlugin::initialize(WebPluginContainer* container) {
+bool BrowserPluginImpl::initialize(WebPluginContainer* container) {
container_ = container;
container_->setWantsWheelEvents(true);
return true;
}
-void BrowserPlugin::EnableCompositing(bool enable) {
+void BrowserPluginImpl::EnableCompositing(bool enable) {
if (enable) {
LOG(ERROR) << "BrowserPlugin compositing not yet implemented.";
return;
@@ -770,33 +784,34 @@ void BrowserPlugin::EnableCompositing(bool enable) {
compositing_enabled_ = enable;
}
-void BrowserPlugin::destroy() {
+void BrowserPluginImpl::destroy() {
// The BrowserPlugin's WebPluginContainer is deleted immediately after this
// call returns, so let's not keep a reference to it around.
container_ = NULL;
+ FOR_EACH_OBSERVER(BrowserPluginObserver, observers_, BrowserPluginGone());
+ FOR_EACH_OBSERVER(BrowserPluginObserver, observers_, OnDestruct());
MessageLoop::current()->DeleteSoon(FROM_HERE, this);
}
-NPObject* BrowserPlugin::scriptableObject() {
+NPObject* BrowserPluginImpl::scriptableObject() {
NPObject* browser_plugin_np_object(bindings_->np_object());
// The object is expected to be retained before it is returned.
WebKit::WebBindings::retainObject(browser_plugin_np_object);
return browser_plugin_np_object;
}
-bool BrowserPlugin::supportsKeyboardFocus() const {
+bool BrowserPluginImpl::supportsKeyboardFocus() const {
return true;
}
-bool BrowserPlugin::canProcessDrag() const {
+bool BrowserPluginImpl::canProcessDrag() const {
return true;
}
-void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) {
+void BrowserPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) {
if (guest_crashed_) {
if (!sad_guest_) // Lazily initialize bitmap.
- sad_guest_ = content::GetContentClient()->renderer()->
- GetSadWebViewBitmap();
+ sad_guest_ = GetContentClient()->renderer()->GetSadWebViewBitmap();
// content_shell does not have the sad plugin bitmap, so we'll paint black
// instead to make it clear that something went wrong.
if (sad_guest_) {
@@ -827,7 +842,7 @@ void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) {
canvas->drawBitmap(backing_store_->GetBitmap(), 0, 0);
}
-bool BrowserPlugin::InBounds(const gfx::Point& position) const {
+bool BrowserPluginImpl::InBounds(const gfx::Point& position) const {
// Note that even for plugins that are rotated using rotate transformations,
// we use the the |plugin_rect_| provided by updateGeometry, which means we
// will be off if |position| is within the plugin rect but does not fall
@@ -842,13 +857,32 @@ bool BrowserPlugin::InBounds(const gfx::Point& position) const {
return result;
}
-gfx::Point BrowserPlugin::ToLocalCoordinates(const gfx::Point& point) const {
+void BrowserPluginImpl::AddMethodBinding(
+ BrowserPluginMethodBinding* method_binding) {
+ bindings_->AddMethodBinding(method_binding);
+}
+
+void BrowserPluginImpl::AddPropertyBinding(
+ BrowserPluginPropertyBinding* method_binding) {
+ bindings_->AddPropertyBinding(method_binding);
+}
+
+bool BrowserPluginImpl::Send(IPC::Message* message) {
+ return browser_plugin_manager()->Send(message);
+}
+
+void BrowserPluginImpl::RequestMessage(uint32 message_id) {
+ browser_plugin_manager()->RequestMessage(message_id);
+}
+
+gfx::Point BrowserPluginImpl::ToLocalCoordinates(
+ const gfx::Point& point) const {
if (container_)
return container_->windowToLocalPoint(WebKit::WebPoint(point));
return gfx::Point(point.x() - plugin_rect_.x(), point.y() - plugin_rect_.y());
}
-void BrowserPlugin::updateGeometry(
+void BrowserPluginImpl::updateGeometry(
const WebRect& window_rect,
const WebRect& clip_rect,
const WebVector<WebRect>& cut_outs_rects,
@@ -869,18 +903,18 @@ void BrowserPlugin::updateGeometry(
BrowserPluginHostMsg_ResizeGuest_Params params;
PopulateResizeGuestParameters(&params, gfx::Size(width(), height()));
resize_ack_received_ = false;
- browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest(
+ Send(new BrowserPluginHostMsg_ResizeGuest(
render_view_routing_id_,
instance_id_,
params));
}
-void BrowserPlugin::SwapDamageBuffers() {
+void BrowserPluginImpl::SwapDamageBuffers() {
current_damage_buffer_.reset(pending_damage_buffer_.release());
resize_ack_received_ = true;
}
-void BrowserPlugin::PopulateResizeGuestParameters(
+void BrowserPluginImpl::PopulateResizeGuestParameters(
BrowserPluginHostMsg_ResizeGuest_Params* params,
const gfx::Size& view_size) {
params->view_size = view_size;
@@ -908,7 +942,7 @@ void BrowserPlugin::PopulateResizeGuestParameters(
params->damage_buffer_sequence_id = ++damage_buffer_sequence_id_;
}
-void BrowserPlugin::GetDamageBufferWithSizeParams(
+void BrowserPluginImpl::GetDamageBufferWithSizeParams(
BrowserPluginHostMsg_AutoSize_Params* auto_size_params,
BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params) {
PopulateAutoSizeParameters(auto_size_params);
@@ -921,7 +955,7 @@ void BrowserPlugin::GetDamageBufferWithSizeParams(
}
#if defined(OS_POSIX)
-base::SharedMemory* BrowserPlugin::CreateDamageBuffer(
+base::SharedMemory* BrowserPluginImpl::CreateDamageBuffer(
const size_t size,
base::SharedMemoryHandle* damage_buffer_handle) {
scoped_ptr<base::SharedMemory> shared_buf(
@@ -950,7 +984,6 @@ base::SharedMemory* BrowserPlugin::CreateDamageBuffer(
NOTREACHED() << "Buffer allocation failed";
return NULL;
}
-
// Insert the magic word.
*static_cast<unsigned int*>(shared_buf->memory()) = 0xdeadbeef;
if (shared_buf->ShareToProcess(base::GetCurrentProcessHandle(),
@@ -961,7 +994,7 @@ base::SharedMemory* BrowserPlugin::CreateDamageBuffer(
}
#endif
-void BrowserPlugin::updateFocus(bool focused) {
+void BrowserPluginImpl::updateFocus(bool focused) {
if (plugin_focused_ == focused)
return;
@@ -972,7 +1005,7 @@ void BrowserPlugin::updateFocus(bool focused) {
UpdateGuestFocusState();
}
-void BrowserPlugin::updateVisibility(bool visible) {
+void BrowserPluginImpl::updateVisibility(bool visible) {
if (visible_ == visible)
return;
@@ -980,66 +1013,65 @@ void BrowserPlugin::updateVisibility(bool visible) {
if (!navigate_src_sent_)
return;
- browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetVisibility(
+ Send(new BrowserPluginHostMsg_SetVisibility(
render_view_routing_id_,
instance_id_,
visible));
}
-bool BrowserPlugin::acceptsInputEvents() {
+bool BrowserPluginImpl::acceptsInputEvents() {
return true;
}
-bool BrowserPlugin::handleInputEvent(const WebKit::WebInputEvent& event,
- WebKit::WebCursorInfo& cursor_info) {
+bool BrowserPluginImpl::handleInputEvent(const WebKit::WebInputEvent& event,
+ WebKit::WebCursorInfo& cursor_info) {
if (guest_crashed_ || !navigate_src_sent_ ||
event.type == WebKit::WebInputEvent::ContextMenu)
return false;
- browser_plugin_manager()->Send(
- new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
- instance_id_,
- plugin_rect_,
- &event));
+ Send(new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
+ instance_id_,
+ plugin_rect_,
+ &event));
cursor_.GetCursorInfo(&cursor_info);
return true;
}
-bool BrowserPlugin::handleDragStatusUpdate(WebKit::WebDragStatus drag_status,
- const WebKit::WebDragData& drag_data,
- WebKit::WebDragOperationsMask mask,
- const WebKit::WebPoint& position,
- const WebKit::WebPoint& screen) {
+bool BrowserPluginImpl::handleDragStatusUpdate(
+ WebKit::WebDragStatus drag_status,
+ const WebKit::WebDragData& drag_data,
+ WebKit::WebDragOperationsMask mask,
+ const WebKit::WebPoint& position,
+ const WebKit::WebPoint& screen) {
if (guest_crashed_ || !navigate_src_sent_)
return false;
- browser_plugin_manager()->Send(
- new BrowserPluginHostMsg_DragStatusUpdate(
- render_view_routing_id_,
- instance_id_,
- drag_status,
- WebDropData(drag_data),
- mask,
- position));
+ Send(new BrowserPluginHostMsg_DragStatusUpdate(
+ render_view_routing_id_,
+ instance_id_,
+ drag_status,
+ WebDropData(drag_data),
+ mask,
+ position));
return false;
}
-void BrowserPlugin::didReceiveResponse(
+void BrowserPluginImpl::didReceiveResponse(
const WebKit::WebURLResponse& response) {
}
-void BrowserPlugin::didReceiveData(const char* data, int data_length) {
+void BrowserPluginImpl::didReceiveData(const char* data, int data_length) {
}
-void BrowserPlugin::didFinishLoading() {
+void BrowserPluginImpl::didFinishLoading() {
}
-void BrowserPlugin::didFailLoading(const WebKit::WebURLError& error) {
+void BrowserPluginImpl::didFailLoading(const WebKit::WebURLError& error) {
}
-void BrowserPlugin::didFinishLoadingFrameRequest(const WebKit::WebURL& url,
- void* notify_data) {
+void BrowserPluginImpl::didFinishLoadingFrameRequest(const WebKit::WebURL& url,
+ void* notify_data) {
}
-void BrowserPlugin::didFailLoadingFrameRequest(
+void BrowserPluginImpl::didFailLoadingFrameRequest(
const WebKit::WebURL& url,
void* notify_data,
const WebKit::WebURLError& error) {

Powered by Google App Engine
This is Rietveld 408576698