OLD | NEW |
---|---|
(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() { | |
Peter Kasting
2012/03/01 20:44:18
Nit: Both this function and the static variable sh
keishi
2012/03/02 06:12:13
Done.
| |
11 static unsigned next = 0; | |
12 return ++next; | |
13 } | |
14 | |
15 RendererWebColorChooserImpl::RendererWebColorChooserImpl( | |
16 RenderViewImpl* render_view, WebKit::WebColorChooserClient* client) | |
Peter Kasting
2012/03/01 20:44:18
Nit: One arg per line
keishi
2012/03/02 06:12:13
Done.
| |
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 client_->didEndChooser(); | |
50 } | |
51 | |
52 void RendererWebColorChooserImpl::Open(SkColor initial_color) { | |
53 Send(new ViewHostMsg_OpenColorChooser(routing_id(), identifier_, | |
54 initial_color)); | |
55 client_->didEndChooser(); | |
56 } | |
57 | |
58 void RendererWebColorChooserImpl::OnDidChooseColorResponse( | |
59 int color_chooser_id, | |
60 const SkColor& color) { | |
61 DCHECK(identifier_ == color_chooser_id); | |
62 | |
63 client_->didChooseColor(static_cast<WebKit::WebColor>(color)); | |
64 } | |
65 | |
66 void RendererWebColorChooserImpl::OnDidEndColorChooser( | |
67 int color_chooser_id) { | |
Peter Kasting
2012/03/01 20:44:18
Nit: This arg will fit on the previous line
keishi
2012/03/02 06:12:13
Done.
| |
68 if (identifier_ != color_chooser_id) | |
69 return; | |
70 client_->didEndChooser(); | |
71 } | |
OLD | NEW |