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 { |
| 11 |
10 static int GenerateColorChooserIdentifier() { | 12 static int GenerateColorChooserIdentifier() { |
11 static int next = 0; | 13 static int next = 0; |
12 return ++next; | 14 return ++next; |
13 } | 15 } |
14 | 16 |
15 RendererWebColorChooserImpl::RendererWebColorChooserImpl( | 17 RendererWebColorChooserImpl::RendererWebColorChooserImpl( |
16 RenderViewImpl* render_view, | 18 RenderViewImpl* render_view, |
17 WebKit::WebColorChooserClient* client) | 19 WebKit::WebColorChooserClient* client) |
18 : content::RenderViewObserver(render_view), | 20 : RenderViewObserver(render_view), |
19 identifier_(GenerateColorChooserIdentifier()), | 21 identifier_(GenerateColorChooserIdentifier()), |
20 client_(client) { | 22 client_(client) { |
21 } | 23 } |
22 | 24 |
23 RendererWebColorChooserImpl::~RendererWebColorChooserImpl() { | 25 RendererWebColorChooserImpl::~RendererWebColorChooserImpl() { |
24 } | 26 } |
25 | 27 |
26 bool RendererWebColorChooserImpl::OnMessageReceived( | 28 bool RendererWebColorChooserImpl::OnMessageReceived( |
27 const IPC::Message& message) { | 29 const IPC::Message& message) { |
28 bool handled = true; | 30 bool handled = true; |
(...skipping 26 matching lines...) Expand all Loading... |
55 DCHECK(identifier_ == color_chooser_id); | 57 DCHECK(identifier_ == color_chooser_id); |
56 | 58 |
57 client_->didChooseColor(static_cast<WebKit::WebColor>(color)); | 59 client_->didChooseColor(static_cast<WebKit::WebColor>(color)); |
58 } | 60 } |
59 | 61 |
60 void RendererWebColorChooserImpl::OnDidEndColorChooser(int color_chooser_id) { | 62 void RendererWebColorChooserImpl::OnDidEndColorChooser(int color_chooser_id) { |
61 if (identifier_ != color_chooser_id) | 63 if (identifier_ != color_chooser_id) |
62 return; | 64 return; |
63 client_->didEndChooser(); | 65 client_->didEndChooser(); |
64 } | 66 } |
| 67 |
| 68 } // namespace content |
OLD | NEW |