OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/renderer_webcolorchooser_impl.h" | 5 #include "content/renderer/renderer_webcolorchooser_impl.h" |
6 | 6 |
7 #include "content/common/view_messages.h" | 7 #include "content/common/view_messages.h" |
8 #include "content/renderer/render_view_impl.h" | 8 #include "content/renderer/render_view_impl.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 static int GenerateColorChooserIdentifier() { | 12 static int GenerateColorChooserIdentifier() { |
13 static int next = 0; | 13 static int next = 0; |
14 return ++next; | 14 return ++next; |
15 } | 15 } |
16 | 16 |
17 RendererWebColorChooserImpl::RendererWebColorChooserImpl( | 17 RendererWebColorChooserImpl::RendererWebColorChooserImpl( |
18 RenderViewImpl* render_view, | 18 RenderViewImpl* render_view, |
19 WebKit::WebColorChooserClient* client) | 19 blink::WebColorChooserClient* client) |
20 : RenderViewObserver(render_view), | 20 : RenderViewObserver(render_view), |
21 identifier_(GenerateColorChooserIdentifier()), | 21 identifier_(GenerateColorChooserIdentifier()), |
22 client_(client) { | 22 client_(client) { |
23 } | 23 } |
24 | 24 |
25 RendererWebColorChooserImpl::~RendererWebColorChooserImpl() { | 25 RendererWebColorChooserImpl::~RendererWebColorChooserImpl() { |
26 } | 26 } |
27 | 27 |
28 bool RendererWebColorChooserImpl::OnMessageReceived( | 28 bool RendererWebColorChooserImpl::OnMessageReceived( |
29 const IPC::Message& message) { | 29 const IPC::Message& message) { |
30 bool handled = true; | 30 bool handled = true; |
31 IPC_BEGIN_MESSAGE_MAP(RendererWebColorChooserImpl, message) | 31 IPC_BEGIN_MESSAGE_MAP(RendererWebColorChooserImpl, message) |
32 IPC_MESSAGE_HANDLER(ViewMsg_DidChooseColorResponse, | 32 IPC_MESSAGE_HANDLER(ViewMsg_DidChooseColorResponse, |
33 OnDidChooseColorResponse) | 33 OnDidChooseColorResponse) |
34 IPC_MESSAGE_HANDLER(ViewMsg_DidEndColorChooser, | 34 IPC_MESSAGE_HANDLER(ViewMsg_DidEndColorChooser, |
35 OnDidEndColorChooser) | 35 OnDidEndColorChooser) |
36 IPC_MESSAGE_UNHANDLED(handled = false) | 36 IPC_MESSAGE_UNHANDLED(handled = false) |
37 IPC_END_MESSAGE_MAP() | 37 IPC_END_MESSAGE_MAP() |
38 return handled; | 38 return handled; |
39 } | 39 } |
40 | 40 |
41 void RendererWebColorChooserImpl::setSelectedColor(WebKit::WebColor color) { | 41 void RendererWebColorChooserImpl::setSelectedColor(blink::WebColor color) { |
42 Send(new ViewHostMsg_SetSelectedColorInColorChooser(routing_id(), identifier_, | 42 Send(new ViewHostMsg_SetSelectedColorInColorChooser(routing_id(), identifier_, |
43 static_cast<SkColor>(color))); | 43 static_cast<SkColor>(color))); |
44 } | 44 } |
45 | 45 |
46 void RendererWebColorChooserImpl::endChooser() { | 46 void RendererWebColorChooserImpl::endChooser() { |
47 Send(new ViewHostMsg_EndColorChooser(routing_id(), identifier_)); | 47 Send(new ViewHostMsg_EndColorChooser(routing_id(), identifier_)); |
48 } | 48 } |
49 | 49 |
50 void RendererWebColorChooserImpl::Open(SkColor initial_color) { | 50 void RendererWebColorChooserImpl::Open(SkColor initial_color) { |
51 Send(new ViewHostMsg_OpenColorChooser(routing_id(), identifier_, | 51 Send(new ViewHostMsg_OpenColorChooser(routing_id(), identifier_, |
52 initial_color)); | 52 initial_color)); |
53 } | 53 } |
54 | 54 |
55 void RendererWebColorChooserImpl::OnDidChooseColorResponse(int color_chooser_id, | 55 void RendererWebColorChooserImpl::OnDidChooseColorResponse(int color_chooser_id, |
56 SkColor color) { | 56 SkColor color) { |
57 DCHECK(identifier_ == color_chooser_id); | 57 DCHECK(identifier_ == color_chooser_id); |
58 | 58 |
59 client_->didChooseColor(static_cast<WebKit::WebColor>(color)); | 59 client_->didChooseColor(static_cast<blink::WebColor>(color)); |
60 } | 60 } |
61 | 61 |
62 void RendererWebColorChooserImpl::OnDidEndColorChooser(int color_chooser_id) { | 62 void RendererWebColorChooserImpl::OnDidEndColorChooser(int color_chooser_id) { |
63 if (identifier_ != color_chooser_id) | 63 if (identifier_ != color_chooser_id) |
64 return; | 64 return; |
65 client_->didEndChooser(); | 65 client_->didEndChooser(); |
66 } | 66 } |
67 | 67 |
68 } // namespace content | 68 } // namespace content |
OLD | NEW |