1 // Copyright (c) 2012 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 WEBKIT_PLUGINS_PPAPI_PPB_SCROLLBAR_IMPL_H_
6 #define WEBKIT_PLUGINS_PPAPI_PPB_SCROLLBAR_IMPL_H_
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "ppapi/thunk/ppb_scrollbar_api.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginScrollbarClient.h"
16 #include "ui/gfx/rect.h"
17 #include "webkit/plugins/ppapi/ppb_widget_impl.h"
22 class PPB_Scrollbar_Impl
: public PPB_Widget_Impl
,
23 public ::ppapi::thunk::PPB_Scrollbar_API
,
24 public WebKit::WebPluginScrollbarClient
{
26 static PP_Resource
Create(PP_Instance instance
, bool vertical
);
28 virtual ~PPB_Scrollbar_Impl();
30 // Resource overrides.
31 virtual PPB_Scrollbar_API
* AsPPB_Scrollbar_API() OVERRIDE
;
32 virtual void InstanceWasDeleted();
34 // PPB_Scrollbar_API implementation.
35 virtual uint32_t GetThickness() OVERRIDE
;
36 virtual bool IsOverlay() OVERRIDE
;
37 virtual uint32_t GetValue() OVERRIDE
;
38 virtual void SetValue(uint32_t value
) OVERRIDE
;
39 virtual void SetDocumentSize(uint32_t size
) OVERRIDE
;
40 virtual void SetTickMarks(const PP_Rect
* tick_marks
, uint32_t count
) OVERRIDE
;
41 virtual void ScrollBy(PP_ScrollBy_Dev unit
, int32_t multiplier
) OVERRIDE
;
44 explicit PPB_Scrollbar_Impl(PP_Instance instance
);
45 void Init(bool vertical
);
47 // PPB_Widget private implementation.
48 virtual PP_Bool
PaintInternal(const gfx::Rect
& rect
,
49 PPB_ImageData_Impl
* image
) OVERRIDE
;
50 virtual PP_Bool
HandleEventInternal(
51 const ::ppapi::InputEventData
& data
) OVERRIDE
;
52 virtual void SetLocationInternal(const PP_Rect
* location
) OVERRIDE
;
54 // WebKit::WebPluginScrollbarClient implementation.
55 virtual void valueChanged(WebKit::WebPluginScrollbar
* scrollbar
) OVERRIDE
;
56 virtual void overlayChanged(WebKit::WebPluginScrollbar
* scrollbar
) OVERRIDE
;
57 virtual void invalidateScrollbarRect(WebKit::WebPluginScrollbar
* scrollbar
,
58 const WebKit::WebRect
& rect
) OVERRIDE
;
59 virtual void getTickmarks(
60 WebKit::WebPluginScrollbar
* scrollbar
,
61 WebKit::WebVector
<WebKit::WebRect
>* tick_marks
) const OVERRIDE
;
63 void NotifyInvalidate();
66 std::vector
<WebKit::WebRect
> tickmarks_
;
67 scoped_ptr
<WebKit::WebPluginScrollbar
> scrollbar_
;
69 // Used so that the post task for Invalidate doesn't keep an extra reference.
70 base::WeakPtrFactory
<PPB_Scrollbar_Impl
> weak_ptr_factory_
;
72 DISALLOW_COPY_AND_ASSIGN(PPB_Scrollbar_Impl
);
78 #endif // WEBKIT_PLUGINS_PPAPI_PPB_SCROLLBAR_IMPL_H_