summaryrefslogtreecommitdiff
path: root/chromium/content/renderer/renderer_webcolorchooser_impl.h
blob: 0fa608f4359fc81188a4b7103e20c4705e7cc346 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_RENDERER_RENDERER_WEBCOLORCHOOSER_IMPL_H_
#define CONTENT_RENDERER_RENDERER_WEBCOLORCHOOSER_IMPL_H_

#include <vector>

#include "base/compiler_specific.h"
#include "content/public/common/color_suggestion.h"
#include "content/public/renderer/render_view_observer.h"
#include "third_party/WebKit/public/web/WebColorChooser.h"
#include "third_party/WebKit/public/web/WebColorChooserClient.h"
#include "third_party/skia/include/core/SkColor.h"

namespace blink {
class WebFrame;
}

namespace content {
class RenderViewImpl;

class RendererWebColorChooserImpl : public blink::WebColorChooser,
                                    public RenderViewObserver {
 public:
  explicit RendererWebColorChooserImpl(RenderViewImpl* sender,
                                       blink::WebColorChooserClient*);
  virtual ~RendererWebColorChooserImpl();

  virtual void setSelectedColor(const blink::WebColor);
  virtual void endChooser();

  void Open(SkColor initial_color,
            const std::vector<content::ColorSuggestion>& suggestions);

  blink::WebColorChooserClient* client() { return client_; }

  // Don't destroy the RendererWebColorChooserImpl when the RenderViewImpl goes
  // away. RendererWebColorChooserImpl is owned by
  // blink::ColorChooserUIController.
  virtual void OnDestruct() OVERRIDE {}

 private:
  // RenderViewObserver implementation.
  virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;

  void OnDidChooseColorResponse(int color_chooser_id, SkColor color);
  void OnDidEndColorChooser(int color_chooser_id);

  int identifier_;
  blink::WebColorChooserClient* client_;

  DISALLOW_COPY_AND_ASSIGN(RendererWebColorChooserImpl);
};

}  // namespace content

#endif  // CONTENT_RENDERER_RENDERER_WEBCOLORCHOOSER_IMPL_H_