Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/plugins/renderer/loadable_plugin_placeholder.h" | 5 #include "components/plugins/renderer/loadable_plugin_placeholder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 // Pass through JavaScript access to the underlying throttled plugin. | 174 // Pass through JavaScript access to the underlying throttled plugin. |
| 175 if (premade_throttler_ && premade_throttler_->GetWebPlugin()) { | 175 if (premade_throttler_ && premade_throttler_->GetWebPlugin()) { |
| 176 return premade_throttler_->GetWebPlugin()->v8ScriptableObject(isolate); | 176 return premade_throttler_->GetWebPlugin()->v8ScriptableObject(isolate); |
| 177 } | 177 } |
| 178 return v8::Local<v8::Object>(); | 178 return v8::Local<v8::Object>(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void LoadablePluginPlaceholder::OnUnobscuredRectUpdate( | 181 void LoadablePluginPlaceholder::OnUnobscuredRectUpdate( |
| 182 const gfx::Rect& unobscured_rect) { | 182 const gfx::Rect& unobscured_rect) { |
| 183 DCHECK(content::RenderThread::Get()); | 183 DCHECK(content::RenderThread::Get()); |
| 184 if (!power_saver_enabled_ || !finished_loading_) | 184 if (!power_saver_enabled_ || !finished_loading_) { |
| 185 return; | 185 return; |
| 186 } | |
|
groby-ooo-7-16
2015/12/04 22:06:56
??
tommycli
2015/12/07 22:06:18
Done.
| |
| 186 | 187 |
| 187 // Only update the unobscured rect during the recheck phase. Also early exit | 188 // Only update the unobscured rect during the recheck phase. Also early exit |
| 188 // to prevent reentrancy issues. | 189 // to prevent reentrancy issues. |
| 189 if (in_size_recheck_) { | 190 if (in_size_recheck_) { |
| 190 unobscured_rect_ = unobscured_rect; | 191 unobscured_rect_ = unobscured_rect; |
| 191 return; | 192 return; |
| 192 } | 193 } |
| 193 | 194 |
| 194 if (!size_update_timer_.IsRunning()) { | 195 if (!size_update_timer_.IsRunning()) { |
| 195 // TODO(tommycli): We have to post a delayed task to recheck the size, as | 196 // TODO(tommycli): We have to post a delayed task to recheck the size, as |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 | 263 |
| 263 void LoadablePluginPlaceholder::DidFinishLoadingCallback() { | 264 void LoadablePluginPlaceholder::DidFinishLoadingCallback() { |
| 264 finished_loading_ = true; | 265 finished_loading_ = true; |
| 265 if (message_.length() > 0) | 266 if (message_.length() > 0) |
| 266 UpdateMessage(); | 267 UpdateMessage(); |
| 267 | 268 |
| 268 // Wait for the placeholder to finish loading to hide the premade plugin. | 269 // Wait for the placeholder to finish loading to hide the premade plugin. |
| 269 // This is necessary to prevent a flicker. | 270 // This is necessary to prevent a flicker. |
| 270 if (premade_throttler_ && power_saver_enabled_) | 271 if (premade_throttler_ && power_saver_enabled_) |
| 271 premade_throttler_->SetHiddenForPlaceholder(true /* hidden */); | 272 premade_throttler_->SetHiddenForPlaceholder(true /* hidden */); |
| 273 | |
| 274 // In case our initial geometry was reported before the placeholder finished | |
| 275 // loading, request another one. Needed for correct large poster unthrottling. | |
|
groby-ooo-7-16
2015/12/04 22:06:56
Is it, even if large posters don't get throttled?
tommycli
2015/12/07 22:06:18
Yes, as large posters are throttled, and then beco
groby-ooo-7-16
2015/12/07 22:16:04
That's... limited happiness. Will that mean poster
tommycli
2015/12/07 22:22:13
This patch makes the "flash" imperceptible on my m
| |
| 276 plugin()->container()->reportGeometry(); | |
| 272 } | 277 } |
| 273 | 278 |
| 274 void LoadablePluginPlaceholder::DidFinishIconRepositionForTestingCallback() { | 279 void LoadablePluginPlaceholder::DidFinishIconRepositionForTestingCallback() { |
| 275 // Set an attribute and post an event, so browser tests can wait for the | 280 // Set an attribute and post an event, so browser tests can wait for the |
| 276 // placeholder to be ready to receive simulated user input. | 281 // placeholder to be ready to receive simulated user input. |
| 277 blink::WebElement element = plugin()->container()->element(); | 282 blink::WebElement element = plugin()->container()->element(); |
| 278 element.setAttribute("placeholderReady", "true"); | 283 element.setAttribute("placeholderReady", "true"); |
| 279 | 284 |
| 280 scoped_ptr<content::V8ValueConverter> converter( | 285 scoped_ptr<content::V8ValueConverter> converter( |
| 281 content::V8ValueConverter::create()); | 286 content::V8ValueConverter::create()); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 render_frame()->WhitelistContentOrigin(content_origin); | 366 render_frame()->WhitelistContentOrigin(content_origin); |
| 362 } | 367 } |
| 363 | 368 |
| 364 heuristic_run_before_ = true; | 369 heuristic_run_before_ = true; |
| 365 } | 370 } |
| 366 | 371 |
| 367 in_size_recheck_ = false; | 372 in_size_recheck_ = false; |
| 368 } | 373 } |
| 369 | 374 |
| 370 } // namespace plugins | 375 } // namespace plugins |
| OLD | NEW |