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

Unified Diff: chrome/browser/ui/views/color_chooser_aura.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/views/color_chooser_aura.cc
diff --git a/chrome/browser/ui/views/color_chooser_aura.cc b/chrome/browser/ui/views/color_chooser_aura.cc
index 37b9163e646b0269d42eab49cb7b0cf9769ec81f..6a96679e31a65fc8b8d36e6a7cd76f24edc687e2 100644
--- a/chrome/browser/ui/views/color_chooser_aura.cc
+++ b/chrome/browser/ui/views/color_chooser_aura.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#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_view.h"
#include "ui/views/color_chooser/color_chooser_listener.h"
@@ -12,12 +12,10 @@
namespace {
-class ColorChooserAura : public content::ColorChooser,
+class ColorChooserAura : public ColorChooser,
public views::ColorChooserListener {
public:
- ColorChooserAura(int identifier,
- content::WebContents* tab,
- SkColor initial_color);
+ ColorChooserAura(content::WebContents* web_contents, SkColor initial_color);
private:
// content::ColorChooser overrides:
@@ -28,10 +26,6 @@ class ColorChooserAura : public content::ColorChooser,
virtual void OnColorChosen(SkColor color) OVERRIDE;
virtual void OnColorChooserDialogClosed() OVERRIDE;
- // The web contents invoking the color chooser. No ownership because it will
- // outlive this class.
- content::WebContents* tab_;
-
// The actual view of the color chooser. No ownership because its parent
// view will take care of its lifetime.
views::ColorChooserView* view_;
@@ -43,27 +37,24 @@ class ColorChooserAura : public content::ColorChooser,
DISALLOW_COPY_AND_ASSIGN(ColorChooserAura);
};
-ColorChooserAura::ColorChooserAura(int identifier,
- content::WebContents* tab,
+ColorChooserAura::ColorChooserAura(content::WebContents* web_contents,
SkColor initial_color)
- : ColorChooser(identifier),
- tab_(tab) {
- DCHECK(tab_);
+ : ColorChooser(web_contents) {
view_ = new views::ColorChooserView(this, initial_color);
widget_ = views::Widget::CreateWindowWithContext(
- view_, tab->GetView()->GetNativeView());
+ view_, web_contents->GetView()->GetNativeView());
widget_->SetAlwaysOnTop(true);
widget_->Show();
}
void ColorChooserAura::OnColorChosen(SkColor color) {
- tab_->DidChooseColorInColorChooser(identifier(), color);
+ DidChooseColor(color);
}
void ColorChooserAura::OnColorChooserDialogClosed() {
view_ = NULL;
widget_ = NULL;
- tab_->DidEndColorChooser(identifier());
+ DidEndColorChooser();
}
void ColorChooserAura::End() {
@@ -74,7 +65,7 @@ void ColorChooserAura::End() {
widget_ = NULL;
// DidEndColorChooser will invoke Browser::DidEndColorChooser, which deletes
// this. Take care of the call order.
- tab_->DidEndColorChooser(identifier());
+ DidEndColorChooser();
}
}
@@ -86,7 +77,11 @@ void ColorChooserAura::SetSelectedColor(SkColor color) {
} // namespace
// static
-content::ColorChooser* content::ColorChooser::Create(
- int identifier, content::WebContents* tab, SkColor initial_color) {
- return new ColorChooserAura(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 ColorChooserAura(web_contents, initial_color);
}

Powered by Google App Engine
This is Rietveld 408576698