| Index: components/plugins/renderer/loadable_plugin_placeholder.cc
|
| diff --git a/components/plugins/renderer/loadable_plugin_placeholder.cc b/components/plugins/renderer/loadable_plugin_placeholder.cc
|
| index dc4b5b2797aacf78f1918d146b479e6e67053388..9091bb0a4a90d42907684a93ef5157952bbd5af3 100644
|
| --- a/components/plugins/renderer/loadable_plugin_placeholder.cc
|
| +++ b/components/plugins/renderer/loadable_plugin_placeholder.cc
|
| @@ -6,7 +6,6 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| -#include "base/command_line.h"
|
| #include "base/json/string_escape.h"
|
| #include "base/strings/string_piece.h"
|
| #include "base/strings/stringprintf.h"
|
| @@ -14,11 +13,8 @@
|
| #include "base/thread_task_runner_handle.h"
|
| #include "base/values.h"
|
| #include "content/public/child/v8_value_converter.h"
|
| -#include "content/public/common/content_switches.h"
|
| #include "content/public/renderer/render_frame.h"
|
| #include "content/public/renderer/render_thread.h"
|
| -#include "gin/handle.h"
|
| -#include "gin/object_template_builder.h"
|
| #include "third_party/WebKit/public/web/WebDOMMessageEvent.h"
|
| #include "third_party/WebKit/public/web/WebDocument.h"
|
| #include "third_party/WebKit/public/web/WebElement.h"
|
| @@ -188,12 +184,12 @@ void LoadablePluginPlaceholder::OnUnobscuredRectUpdate(
|
| if (!power_saver_enabled_ || !finished_loading_)
|
| return;
|
|
|
| - unobscured_rect_ = unobscured_rect;
|
| -
|
| - // During a size recheck, we will get another notification into this method.
|
| - // Use this flag to early exit to prevent reentrancy issues.
|
| - if (in_size_recheck_)
|
| + // Only update the unobscured rect during the recheck phase. Also early exit
|
| + // to prevent reentrancy issues.
|
| + if (in_size_recheck_) {
|
| + unobscured_rect_ = unobscured_rect;
|
| return;
|
| + }
|
|
|
| if (!size_update_timer_.IsRunning()) {
|
| // TODO(tommycli): We have to post a delayed task to recheck the size, as
|
| @@ -273,23 +269,23 @@ void LoadablePluginPlaceholder::DidFinishLoadingCallback() {
|
| // This is necessary to prevent a flicker.
|
| if (premade_throttler_ && power_saver_enabled_)
|
| premade_throttler_->SetHiddenForPlaceholder(true /* hidden */);
|
| +}
|
|
|
| +void LoadablePluginPlaceholder::DidFinishIconRepositionForTestingCallback() {
|
| // Set an attribute and post an event, so browser tests can wait for the
|
| // placeholder to be ready to receive simulated user input.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kEnablePluginPlaceholderTesting)) {
|
| - blink::WebElement element = plugin()->container()->element();
|
| - element.setAttribute("placeholderLoaded", "true");
|
| -
|
| - scoped_ptr<content::V8ValueConverter> converter(
|
| - content::V8ValueConverter::create());
|
| - base::StringValue value("placeholderLoaded");
|
| - blink::WebSerializedScriptValue message_data =
|
| - blink::WebSerializedScriptValue::serialize(converter->ToV8Value(
|
| - &value, element.document().frame()->mainWorldScriptContext()));
|
| - blink::WebDOMMessageEvent msg_event(message_data);
|
| - element.dispatchEvent(msg_event);
|
| - }
|
| + blink::WebElement element = plugin()->container()->element();
|
| + element.setAttribute("placeholderReady", "true");
|
| +
|
| + scoped_ptr<content::V8ValueConverter> converter(
|
| + content::V8ValueConverter::create());
|
| + base::StringValue value("placeholderReady");
|
| + blink::WebSerializedScriptValue message_data =
|
| + blink::WebSerializedScriptValue::serialize(converter->ToV8Value(
|
| + &value, element.document().frame()->mainWorldScriptContext()));
|
| + blink::WebDOMMessageEvent msg_event(message_data);
|
| +
|
| + element.dispatchEvent(msg_event);
|
| }
|
|
|
| void LoadablePluginPlaceholder::SetPluginInfo(
|
| @@ -318,15 +314,23 @@ bool LoadablePluginPlaceholder::LoadingBlocked() const {
|
| void LoadablePluginPlaceholder::RecheckSizeAndMaybeUnthrottle() {
|
| DCHECK(content::RenderThread::Get());
|
| DCHECK(!in_size_recheck_);
|
| + DCHECK(finished_loading_);
|
|
|
| if (!plugin())
|
| return;
|
|
|
| in_size_recheck_ = true;
|
|
|
| + gfx::Rect old_rect = unobscured_rect_;
|
| +
|
| // Re-check the size in case the reported size was incorrect.
|
| plugin()->container()->reportGeometry();
|
|
|
| + if (old_rect == unobscured_rect_) {
|
| + in_size_recheck_ = false;
|
| + return;
|
| + }
|
| +
|
| float zoom_factor = plugin()->container()->pageZoomFactor();
|
| int width = roundf(unobscured_rect_.width() / zoom_factor);
|
| int height = roundf(unobscured_rect_.height() / zoom_factor);
|
|
|