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.
4
5#ifndef CONTENT_RENDERER_RENDERER_WEBCOLORCHOOSER_IMPL_H_
6#define CONTENT_RENDERER_RENDERER_WEBCOLORCHOOSER_IMPL_H_
7
8#include <vector>
9
10#include "base/compiler_specific.h"
11#include "content/public/common/color_suggestion.h"
12#include "content/public/renderer/render_frame_observer.h"
13#include "third_party/WebKit/public/web/WebColorChooser.h"
14#include "third_party/WebKit/public/web/WebColorChooserClient.h"
15#include "third_party/skia/include/core/SkColor.h"
16
17namespace blink {
18class WebFrame;
19}
20
21namespace content {
22
23class RendererWebColorChooserImpl : public blink::WebColorChooser,
24                                    public RenderFrameObserver {
25 public:
26  explicit RendererWebColorChooserImpl(RenderFrame* render_frame,
27                                       blink::WebColorChooserClient*);
28  virtual ~RendererWebColorChooserImpl();
29
30  // blink::WebColorChooser implementation:
31  virtual void setSelectedColor(const blink::WebColor);
32  virtual void endChooser();
33
34  void Open(SkColor initial_color,
35            const std::vector<content::ColorSuggestion>& suggestions);
36
37  blink::WebColorChooserClient* client() { return client_; }
38
39 private:
40  // RenderFrameObserver implementation:
41  // Don't destroy the RendererWebColorChooserImpl when the RenderFrame goes
42  // away. RendererWebColorChooserImpl is owned by
43  // blink::ColorChooserUIController.
44  virtual void OnDestruct() OVERRIDE {}
45  virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
46
47  void OnDidChooseColorResponse(int color_chooser_id, SkColor color);
48  void OnDidEndColorChooser(int color_chooser_id);
49
50  int identifier_;
51  blink::WebColorChooserClient* client_;
52
53  DISALLOW_COPY_AND_ASSIGN(RendererWebColorChooserImpl);
54};
55
56}  // namespace content
57
58#endif  // CONTENT_RENDERER_RENDERER_WEBCOLORCHOOSER_IMPL_H_
59