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
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_PLUGINS_PLUGIN_PREROLLER_H_
6 #define CHROME_RENDERER_PLUGINS_PLUGIN_PREROLLER_H_
8 #include "base/macros.h"
9 #include "content/public/common/webplugininfo.h"
10 #include "content/public/renderer/plugin_instance_throttler.h"
11 #include "content/public/renderer/render_frame_observer.h"
12 #include "third_party/WebKit/public/web/WebPluginParams.h"
22 // This class manages a plugin briefly for the purposes of keyframe extraction.
23 // Once a keyframe has been extracted, this class will replace the plugin with
24 // a ChromePluginPlaceholder. The actual plugin will continue to live in a
25 // throttled state. This class manages its own lifetime.
26 class PluginPreroller
: public content::PluginInstanceThrottler::Observer
,
27 public content::RenderFrameObserver
{
29 // Does not take ownership of either |plugin| or |throttler|.
30 PluginPreroller(content::RenderFrame
* render_frame
,
31 blink::WebLocalFrame
* frame
,
32 const blink::WebPluginParams
& params
,
33 const content::WebPluginInfo
& info
,
34 const std::string
& identifier
,
35 const base::string16
& name
,
36 const base::string16
& message
,
37 blink::WebPlugin
* plugin
,
38 content::PluginInstanceThrottler
* throttler
);
40 ~PluginPreroller() override
;
43 // content::PluginInstanceThrottler::Observer methods:
44 void OnKeyframeExtracted(const SkBitmap
* bitmap
) override
;
45 void OnThrottleStateChange() override
;
46 void OnThrottlerDestroyed() override
;
48 blink::WebLocalFrame
* frame_
;
49 blink::WebPluginParams params_
;
50 content::WebPluginInfo info_
;
51 std::string identifier_
;
53 base::string16 message_
;
55 blink::WebPlugin
* plugin_
;
56 content::PluginInstanceThrottler
* throttler_
;
58 GURL keyframe_data_url_
;
60 DISALLOW_COPY_AND_ASSIGN(PluginPreroller
);
63 #endif // CHROME_RENDERER_PLUGINS_PLUGIN_PREROLLER_H_