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

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 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() {
jam 2012/02/22 02:55:20 nit: GenerateColorChooserIdentifier
keishi 2012/02/24 14:38:54 Done.
11 static unsigned next = 0;
jam 2012/02/22 02:55:20 nit: 2 space indents per chrome C++ style guide
keishi 2012/02/24 14:38:54 Done.
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::FrameWillClose(WebKit::WebFrame* frame) {
39 endChooser();
40 }
41
42 void RendererWebColorChooserImpl::setSelectedColor(WebKit::WebColor color) {
43 Send(new ViewHostMsg_SetSelectedColorInColorChooser(routing_id(), identifier_,
44 static_cast<SkColor>(color)));
45 }
46
47 void RendererWebColorChooserImpl::endChooser() {
48 Send(new ViewHostMsg_EndColorChooser(routing_id(), identifier_));
49 if (client_.get())
50 client_->didEndChooser();
jam 2012/02/22 02:55:20 I don't see the webkit side giving NULL pointers,
keishi 2012/02/24 14:38:54 OK. Removed all checks.
51 }
52
53 void RendererWebColorChooserImpl::Open(SkColor initial_color) {
54 Send(new ViewHostMsg_OpenColorChooser(routing_id(), identifier_,
55 initial_color));
56 if (client_.get())
57 client_->didEndChooser();
58 }
59
60 void RendererWebColorChooserImpl::OnDidChooseColorResponse(
61 int color_chooser_id,
62 const SkColor& color) {
63 if (identifier_ != color_chooser_id)
jam 2012/02/22 02:55:20 is this a race condition that you sent the picture
keishi 2012/02/24 14:38:54 No, it's for another race condition. But this race
jam 2012/02/24 21:41:17 Are you sure that's a race condition that can occu
64 return;
65 if (client_.get())
66 client_->didChooseColor(static_cast<WebKit::WebColor>(color));
67 }
68
69 void RendererWebColorChooserImpl::OnDidEndColorChooser(
70 int color_chooser_id) {
71 if (identifier_ != color_chooser_id)
72 return;
73 if (client_.get())
74 client_->didEndChooser();
75 }
76
77 WebKit::WebColorChooserClient* RendererWebColorChooserImpl::client() {
78 return client_.get();
79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698