Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: content/renderer/renderer_webcolorchooser_impl.cc

Issue 9203001: Implement input type=color UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed issues/removed color_select_helper/added color_chooser_id Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 #include "content/renderer/renderer_webcolorchooser_impl.h"
6
7 #include "content/common/view_messages.h"
8 #include "content/renderer/render_view_impl.h"
9
10 static unsigned generateColorChooserIdentifier() {
11 static unsigned next = 0;
12 return ++next;
13 }
14
15 RendererWebColorChooserImpl::RendererWebColorChooserImpl(
16 RenderViewImpl* render_view, WebKit::WebColorChooserClient* client)
17 : content::RenderViewObserver(render_view),
18 identifier_(generateColorChooserIdentifier()),
19 client_(client) {
20 }
21
22 RendererWebColorChooserImpl::~RendererWebColorChooserImpl() {
23 }
24
25 bool RendererWebColorChooserImpl::OnMessageReceived(
26 const IPC::Message& message) {
27 bool handled = true;
28 IPC_BEGIN_MESSAGE_MAP(RendererWebColorChooserImpl, message)
29 IPC_MESSAGE_HANDLER(ViewMsg_DidChooseColorResponse,
30 OnDidChooseColorResponse)
31 IPC_MESSAGE_HANDLER(ViewMsg_DidEndColorChooser,
32 OnDidEndColorChooser)
33 IPC_MESSAGE_UNHANDLED(handled = false)
34 IPC_END_MESSAGE_MAP()
35 return handled;
36 }
37
38 void RendererWebColorChooserImpl::setSelectedColor(WebKit::WebColor color) {
39 Send(new ViewHostMsg_SetSelectedColorInColorChooser(routing_id(), identifier_,
40 static_cast<SkColor>(color)));
41 }
42
43 void RendererWebColorChooserImpl::endChooser() {
44 printf("@ RendererWebColorChooserImpl::endChooser %p\n", this);
45 Send(new ViewHostMsg_EndColorChooser(routing_id(), identifier_));
46 if (client_.get())
47 client_->didEndChooser();
48 }
49
50 void RendererWebColorChooserImpl::Open(SkColor initial_color) {
51 printf("@ RendererWebColorChooserImpl::Open %p\n", this);
52 Send(new ViewHostMsg_OpenColorChooser(routing_id(), identifier_,
53 initial_color));
54 if (client_.get())
55 client_->didEndChooser();
56 }
57
58 void RendererWebColorChooserImpl::OnDidChooseColorResponse(
59 unsigned color_chooser_id,
60 const SkColor& color) {
61 if (identifier_ != color_chooser_id)
62 return;
63 if (client_.get())
64 client_->didChooseColor(static_cast<WebKit::WebColor>(color));
65 }
66
67 void RendererWebColorChooserImpl::OnDidEndColorChooser(
68 unsigned color_chooser_id) {
69 if (identifier_ != color_chooser_id)
70 return;
71 if (client_.get())
72 client_->didEndChooser();
73 }
74
75 WebKit::WebColorChooserClient* RendererWebColorChooserImpl::client() {
76 return client_.get();
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698