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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/string_escape.h" | 10 #include "base/json/string_escape.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" | 22 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" |
23 #include "third_party/WebKit/public/web/WebDocument.h" | 23 #include "third_party/WebKit/public/web/WebDocument.h" |
24 #include "third_party/WebKit/public/web/WebElement.h" | 24 #include "third_party/WebKit/public/web/WebElement.h" |
25 #include "third_party/WebKit/public/web/WebInputEvent.h" | 25 #include "third_party/WebKit/public/web/WebInputEvent.h" |
26 #include "third_party/WebKit/public/web/WebKit.h" | 26 #include "third_party/WebKit/public/web/WebKit.h" |
27 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 27 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
28 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 28 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
29 #include "third_party/WebKit/public/web/WebScriptSource.h" | 29 #include "third_party/WebKit/public/web/WebScriptSource.h" |
30 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 30 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
31 #include "third_party/WebKit/public/web/WebView.h" | 31 #include "third_party/WebKit/public/web/WebView.h" |
| 32 #include "url/gurl.h" |
| 33 #include "url/origin.h" |
| 34 |
32 using base::UserMetricsAction; | 35 using base::UserMetricsAction; |
33 using content::PluginInstanceThrottler; | 36 using content::PluginInstanceThrottler; |
34 using content::RenderThread; | 37 using content::RenderThread; |
35 | 38 |
36 namespace plugins { | 39 namespace plugins { |
37 | 40 |
38 // TODO(tommycli): After a size update, re-check the size after this delay, as | 41 // TODO(tommycli): After a size update, re-check the size after this delay, as |
39 // Blink can report incorrect sizes to plugins while the compositing state is | 42 // Blink can report incorrect sizes to plugins while the compositing state is |
40 // dirty. Chosen because it seems to work. | 43 // dirty. Chosen because it seems to work. |
41 const int kSizeChangeRecheckDelayMilliseconds = 100; | 44 const int kSizeChangeRecheckDelayMilliseconds = 100; |
42 | 45 |
43 void LoadablePluginPlaceholder::BlockForPowerSaverPoster() { | 46 void LoadablePluginPlaceholder::BlockForPowerSaverPoster() { |
44 DCHECK(!is_blocked_for_power_saver_poster_); | 47 DCHECK(!is_blocked_for_power_saver_poster_); |
45 is_blocked_for_power_saver_poster_ = true; | 48 is_blocked_for_power_saver_poster_ = true; |
46 | 49 |
47 render_frame()->RegisterPeripheralPlugin( | 50 render_frame()->RegisterPeripheralPlugin( |
48 GURL(GetPluginParams().url).GetOrigin(), | 51 url::Origin(GURL(GetPluginParams().url)), |
49 base::Bind(&LoadablePluginPlaceholder::MarkPluginEssential, | 52 base::Bind(&LoadablePluginPlaceholder::MarkPluginEssential, |
50 weak_factory_.GetWeakPtr(), | 53 weak_factory_.GetWeakPtr(), |
51 PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_WHITELIST)); | 54 PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_WHITELIST)); |
52 } | 55 } |
53 | 56 |
54 void LoadablePluginPlaceholder::SetPremadePlugin( | 57 void LoadablePluginPlaceholder::SetPremadePlugin( |
55 content::PluginInstanceThrottler* throttler) { | 58 content::PluginInstanceThrottler* throttler) { |
56 DCHECK(throttler); | 59 DCHECK(throttler); |
57 DCHECK(!premade_throttler_); | 60 DCHECK(!premade_throttler_); |
58 premade_throttler_ = throttler; | 61 premade_throttler_ = throttler; |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 roundf(unobscured_rect_.width() / zoom_factor), | 353 roundf(unobscured_rect_.width() / zoom_factor), |
351 roundf(unobscured_rect_.height() / zoom_factor))) { | 354 roundf(unobscured_rect_.height() / zoom_factor))) { |
352 MarkPluginEssential( | 355 MarkPluginEssential( |
353 PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_SIZE_CHANGE); | 356 PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_SIZE_CHANGE); |
354 } | 357 } |
355 | 358 |
356 in_size_recheck_ = false; | 359 in_size_recheck_ = false; |
357 } | 360 } |
358 | 361 |
359 } // namespace plugins | 362 } // namespace plugins |
OLD | NEW |