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

Unified 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: rebased Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/renderer_webcolorchooser_impl.h ('k') | skia/ext/skia_utils_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/renderer_webcolorchooser_impl.cc
diff --git a/content/renderer/renderer_webcolorchooser_impl.cc b/content/renderer/renderer_webcolorchooser_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9a50b19945ddcc5c8f374f866ff6b981d330ddc7
--- /dev/null
+++ b/content/renderer/renderer_webcolorchooser_impl.cc
@@ -0,0 +1,70 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/renderer_webcolorchooser_impl.h"
+
+#include "content/common/view_messages.h"
+#include "content/renderer/render_view_impl.h"
+
+static int GenerateColorChooserIdentifier() {
+ static int next = 0;
+ return ++next;
+}
+
+RendererWebColorChooserImpl::RendererWebColorChooserImpl(
+ RenderViewImpl* render_view,
+ WebKit::WebColorChooserClient* client)
+ : content::RenderViewObserver(render_view),
+ identifier_(GenerateColorChooserIdentifier()),
+ client_(client) {
+}
+
+RendererWebColorChooserImpl::~RendererWebColorChooserImpl() {
+}
+
+bool RendererWebColorChooserImpl::OnMessageReceived(
+ const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(RendererWebColorChooserImpl, message)
+ IPC_MESSAGE_HANDLER(ViewMsg_DidChooseColorResponse,
+ OnDidChooseColorResponse)
+ IPC_MESSAGE_HANDLER(ViewMsg_DidEndColorChooser,
+ OnDidEndColorChooser)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void RendererWebColorChooserImpl::FrameWillClose(WebKit::WebFrame* frame) {
+ endChooser();
+ client_->didEndChooser();
+}
+
+void RendererWebColorChooserImpl::setSelectedColor(WebKit::WebColor color) {
+ Send(new ViewHostMsg_SetSelectedColorInColorChooser(routing_id(), identifier_,
+ static_cast<SkColor>(color)));
+}
+
+void RendererWebColorChooserImpl::endChooser() {
+ Send(new ViewHostMsg_EndColorChooser(routing_id(), identifier_));
+}
+
+void RendererWebColorChooserImpl::Open(SkColor initial_color) {
+ Send(new ViewHostMsg_OpenColorChooser(routing_id(), identifier_,
+ initial_color));
+}
+
+void RendererWebColorChooserImpl::OnDidChooseColorResponse(
+ int color_chooser_id,
+ const SkColor& color) {
+ DCHECK(identifier_ == color_chooser_id);
+
+ client_->didChooseColor(static_cast<WebKit::WebColor>(color));
+}
+
+void RendererWebColorChooserImpl::OnDidEndColorChooser(int color_chooser_id) {
+ if (identifier_ != color_chooser_id)
+ return;
+ client_->didEndChooser();
+}
« no previous file with comments | « content/renderer/renderer_webcolorchooser_impl.h ('k') | skia/ext/skia_utils_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698