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

Unified Diff: chrome/browser/ui/gtk/color_chooser_gtk.cc

Issue 13150004: Support color chooser inside extesions, apps, chrome frame, dev tool (Closed) Base URL: http://git.chromium.org/chromium/src.git@ngcolor
Patch Set: Used static class member Created 7 years, 8 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/gtk/color_chooser_gtk.cc
diff --git a/chrome/browser/ui/gtk/color_chooser_gtk.cc b/chrome/browser/ui/gtk/color_chooser_gtk.cc
index 8b9384fec66bf755c767fe424fa16e9b9fb79f4c..13f3768bf5a9f924b5147d8395dd8620f64d2478 100644
--- a/chrome/browser/ui/gtk/color_chooser_gtk.cc
+++ b/chrome/browser/ui/gtk/color_chooser_gtk.cc
@@ -4,20 +4,16 @@
#include <gtk/gtk.h>
-#include "content/public/browser/color_chooser.h"
-
+#include "chrome/browser/ui/color_chooser.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_observer.h"
#include "grit/generated_resources.h"
#include "ui/base/gtk/gtk_signal.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/skia_utils_gtk.h"
-class ColorChooserGtk : public content::ColorChooser,
- public content::WebContentsObserver {
+class ColorChooserGtk : public ColorChooser {
public:
- ColorChooserGtk(
- int identifier, content::WebContents* tab, SkColor initial_color);
+ ColorChooserGtk(content::WebContents* web_contents, SkColor initial_color);
virtual ~ColorChooserGtk();
virtual void End() OVERRIDE;
@@ -31,15 +27,18 @@ class ColorChooserGtk : public content::ColorChooser,
GtkWidget* color_selection_dialog_;
};
-content::ColorChooser* content::ColorChooser::Create(
- int identifier, content::WebContents* tab, SkColor initial_color) {
- return new ColorChooserGtk(identifier, tab, initial_color);
+ColorChooser* ColorChooser::Open(content::WebContents* web_contents,
+ SkColor initial_color) {
+ ColorChooser* current_color_chooser =
+ ColorChooser::get_current_color_chooser();
+ if (current_color_chooser)
+ current_color_chooser->End();
+ return new ColorChooserGtk(web_contents, initial_color);
}
-ColorChooserGtk::ColorChooserGtk(
- int identifier, content::WebContents* tab, SkColor initial_color)
- : content::ColorChooser(identifier),
- content::WebContentsObserver(tab) {
+ColorChooserGtk::ColorChooserGtk(content::WebContents* web_contents,
+ SkColor initial_color)
+ : ColorChooser(web_contents) {
color_selection_dialog_ = gtk_color_selection_dialog_new(
l10n_util::GetStringUTF8(IDS_SELECT_COLOR_DIALOG_TITLE).c_str());
GtkWidget* cancel_button;
@@ -77,8 +76,7 @@ void ColorChooserGtk::OnColorChooserOk(GtkWidget* widget) {
g_object_get(color_selection_dialog_,
"color-selection", &color_selection, NULL);
gtk_color_selection_get_current_color(color_selection, &color);
- web_contents()->DidChooseColorInColorChooser(identifier(),
- gfx::GdkColorToSkColor(color));
+ DidChooseColor(gfx::GdkColorToSkColor(color));
g_object_unref(color_selection);
gtk_widget_destroy(color_selection_dialog_);
}
@@ -89,8 +87,7 @@ void ColorChooserGtk::OnColorChooserCancel(GtkWidget* widget) {
void ColorChooserGtk::OnColorChooserDestroy(GtkWidget* widget) {
color_selection_dialog_ = NULL;
- if (web_contents())
- web_contents()->DidEndColorChooser(identifier());
+ DidEndColorChooser();
}
void ColorChooserGtk::End() {

Powered by Google App Engine
This is Rietveld 408576698