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

Unified Diff: chrome/browser/ui/views/color_chooser_win.cc

Issue 9203001: Implement input type=color UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/color_chooser_win.cc
diff --git a/chrome/browser/ui/views/color_chooser_win.cc b/chrome/browser/ui/views/color_chooser_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c466fddc377165b016a4d015a5e18f8bab566f0e
--- /dev/null
+++ b/chrome/browser/ui/views/color_chooser_win.cc
@@ -0,0 +1,65 @@
+// 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 <windows.h>
+
+#include "chrome/browser/platform_util.h"
+#include "chrome/browser/ui/color_chooser.h"
+#include "chrome/browser/ui/views/color_chooser_dialog.h"
+#include "content/public/browser/render_widget_host_view.h"
+#include "content/public/browser/web_contents.h"
+
+class ColorChooserWin : public ColorChooser,
Peter Kasting 2012/02/29 01:40:07 Why is it that the GTK and Mac versions need to li
keishi 2012/02/29 13:05:22 I thought maybe the dialog would block the tab fro
+ public ColorChooserDialog::Listener {
+ public:
+ virtual void End() OVERRIDE {}
Peter Kasting 2012/02/29 01:40:07 Nit: Add "// ColorChooser:" and "//ColorChooserDia
keishi 2012/02/29 13:05:22 Done.
+ virtual void SetSelectedColor(SkColor color) OVERRIDE {}
+
+ virtual void DidChooseColor(SkColor color);
+ virtual void DidEnd();
+
+ ColorChooserWin(
+ int identifier, content::WebContents* tab, SkColor initial_color);
Peter Kasting 2012/02/29 01:40:07 Nit: One arg per line (3 places)
keishi 2012/02/29 13:05:22 Done.
+ ~ColorChooserWin();
+
+ virtual int GetIdentifier() const OVERRIDE { return identifier_; }
Peter Kasting 2012/02/29 01:40:07 Nit: Don't inline virtual functions
keishi 2012/02/29 13:05:22 Done.
+
+ private:
+ int identifier_;
+ content::WebContents* tab_;
+ scoped_refptr<ColorChooserDialog> color_chooser_dialog_;
+};
+
+ColorChooser* ColorChooser::Create(
+ int identifier, content::WebContents* tab, SkColor initial_color) {
+ return new ColorChooserWin(identifier, tab, initial_color);
+}
+
+ColorChooserWin::ColorChooserWin(
+ int identifier, RenderViewHost* rvh, SkColor initial_color)
+ : identifier_(identifier),
+ tab_(tab),
+ color_chooser_dialog_(NULL) {
+ gfx::NativeWindow owning_window = platform_util::GetTopLevel(
+ tab_->GetRenderViewHost()->view()->GetNativeView());
+ color_chooser_dialog_ = new ColorChooserDialog(this,
+ initial_color,
+ owning_window);
+}
+
+ColorChooserWin::~ColorChooserWin() {
+ // Always call End() before destroying.
+ DCHECK(!color_chooser_dialog_);
+}
+
+void ColorChooserWin::DidChooseColor(SkColor color) {
+ if (tab_)
+ tab_->DidChooseColorInColorChooser(identifier_, color);
+}
+
+void ColorChooserWin::DidEnd() {
+ if (color_chooser_dialog_.get())
+ color_chooser_dialog_ = NULL;
+ tab_->DidEndColorChooser(identifier_);
+}

Powered by Google App Engine
This is Rietveld 408576698