| 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 #ifndef COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ | 5 #ifndef COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ |
| 6 #define COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ | 6 #define COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/timer/timer.h" |
| 9 #include "components/plugins/renderer/plugin_placeholder.h" | 10 #include "components/plugins/renderer/plugin_placeholder.h" |
| 10 #include "content/public/common/webplugininfo.h" | 11 #include "content/public/common/webplugininfo.h" |
| 11 #include "content/public/renderer/plugin_instance_throttler.h" | 12 #include "content/public/renderer/plugin_instance_throttler.h" |
| 12 | 13 |
| 13 namespace plugins { | 14 namespace plugins { |
| 14 // Placeholders can be used if a plugin is missing or not available | 15 // Placeholders can be used if a plugin is missing or not available |
| 15 // (blocked or disabled). | 16 // (blocked or disabled). |
| 16 class LoadablePluginPlaceholder : public PluginPlaceholder { | 17 class LoadablePluginPlaceholder : public PluginPlaceholder { |
| 17 public: | 18 public: |
| 18 void set_blocked_for_background_tab(bool blocked_for_background_tab) { | 19 void set_blocked_for_background_tab(bool blocked_for_background_tab) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 79 |
| 79 // gin::Wrappable method: | 80 // gin::Wrappable method: |
| 80 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | 81 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 81 v8::Isolate* isolate) override; | 82 v8::Isolate* isolate) override; |
| 82 | 83 |
| 83 private: | 84 private: |
| 84 // WebViewPlugin::Delegate methods: | 85 // WebViewPlugin::Delegate methods: |
| 85 void PluginDestroyed() override; | 86 void PluginDestroyed() override; |
| 86 v8::Local<v8::Object> GetV8ScriptableObject( | 87 v8::Local<v8::Object> GetV8ScriptableObject( |
| 87 v8::Isolate* isolate) const override; | 88 v8::Isolate* isolate) const override; |
| 89 #if defined(ENABLE_PLUGINS) |
| 90 void OnUnobscuredSizeUpdate(const gfx::Size& unobscured_size) override; |
| 91 #endif |
| 88 | 92 |
| 89 // RenderFrameObserver methods: | 93 // RenderFrameObserver methods: |
| 90 void WasShown() override; | 94 void WasShown() override; |
| 91 | 95 |
| 92 // Javascript callbacks: | 96 // Javascript callbacks: |
| 93 void LoadCallback(); | 97 void LoadCallback(); |
| 94 void HideCallback(); | 98 void HideCallback(); |
| 95 void DidFinishLoadingCallback(); | 99 void DidFinishLoadingCallback(); |
| 96 | 100 |
| 97 void UpdateMessage(); | 101 void UpdateMessage(); |
| 98 | 102 |
| 99 bool LoadingBlocked() const; | 103 bool LoadingBlocked() const; |
| 104 #if defined(ENABLE_PLUGINS) |
| 105 void RecheckSizeAndMaybeUnthrottle(); |
| 106 #endif |
| 100 | 107 |
| 101 // Plugin creation is embedder-specific. | 108 // Plugin creation is embedder-specific. |
| 102 virtual blink::WebPlugin* CreatePlugin() = 0; | 109 virtual blink::WebPlugin* CreatePlugin() = 0; |
| 103 | 110 |
| 104 content::WebPluginInfo plugin_info_; | 111 content::WebPluginInfo plugin_info_; |
| 105 | 112 |
| 106 base::string16 message_; | 113 base::string16 message_; |
| 107 | 114 |
| 108 // True if the plugin load was deferred due to page being a background tab. | 115 // True if the plugin load was deferred due to page being a background tab. |
| 109 // Plugin may be automatically loaded when the page is foregrounded. | 116 // Plugin may be automatically loaded when the page is foregrounded. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 122 | 129 |
| 123 // When we load, uses this premade plugin instead of creating a new one. | 130 // When we load, uses this premade plugin instead of creating a new one. |
| 124 content::PluginInstanceThrottler* premade_throttler_; | 131 content::PluginInstanceThrottler* premade_throttler_; |
| 125 | 132 |
| 126 bool allow_loading_; | 133 bool allow_loading_; |
| 127 | 134 |
| 128 bool hidden_; | 135 bool hidden_; |
| 129 bool finished_loading_; | 136 bool finished_loading_; |
| 130 std::string identifier_; | 137 std::string identifier_; |
| 131 | 138 |
| 139 // Used to prevent re-entrancy during the size recheck for throttled plugins. |
| 140 bool in_size_recheck_; |
| 141 gfx::Size unobscured_size_; |
| 142 base::OneShotTimer<LoadablePluginPlaceholder> size_update_timer_; |
| 143 |
| 132 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_; | 144 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_; |
| 133 | 145 |
| 134 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder); | 146 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder); |
| 135 }; | 147 }; |
| 136 | 148 |
| 137 } // namespace plugins | 149 } // namespace plugins |
| 138 | 150 |
| 139 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ | 151 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ |
| OLD | NEW |