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

Unified Diff: chrome/browser/ui/cocoa/color_chooser_mac.mm

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/cocoa/color_chooser_mac.mm
diff --git a/chrome/browser/ui/cocoa/color_chooser_mac.mm b/chrome/browser/ui/cocoa/color_chooser_mac.mm
index 0548b43eb3496c357f382ad615bc6d394364f173..9ac5481aaf33c496ccde3f1a79420fc92d2c6f66 100644
--- a/chrome/browser/ui/cocoa/color_chooser_mac.mm
+++ b/chrome/browser/ui/cocoa/color_chooser_mac.mm
@@ -2,14 +2,12 @@
// 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"
-
#import <Cocoa/Cocoa.h>
#include "base/logging.h"
#import "base/memory/scoped_nsobject.h"
+#include "chrome/browser/ui/color_chooser.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_observer.h"
#include "skia/ext/skia_utils_mac.h"
class ColorChooserMac;
@@ -34,16 +32,14 @@ class ColorChooserMac;
@end
-class ColorChooserMac : public content::ColorChooser,
- public content::WebContentsObserver {
+class ColorChooserMac : public ColorChooser {
public:
- ColorChooserMac(
- int identifier, content::WebContents* tab, SkColor initial_color);
+ ColorChooserMac(content::WebContents* tab, SkColor initial_color);
virtual ~ColorChooserMac();
// Called from ColorPanelCocoa.
- void DidChooseColor(SkColor color);
- void DidClose();
+ void DidChooseColorInColorPanel(SkColor color);
+ void DidCloseColorPabel();
virtual void End() OVERRIDE;
virtual void SetSelectedColor(SkColor color) OVERRIDE;
@@ -52,15 +48,18 @@ class ColorChooserMac : public content::ColorChooser,
scoped_nsobject<ColorPanelCocoa> panel_;
};
-content::ColorChooser* content::ColorChooser::Create(
- int identifier, content::WebContents* tab, SkColor initial_color) {
- return new ColorChooserMac(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 ColorChooserMac(web_contents, initial_color);
}
-ColorChooserMac::ColorChooserMac(
- int identifier, content::WebContents* tab, SkColor initial_color)
- : content::ColorChooser(identifier),
- content::WebContentsObserver(tab) {
+ColorChooserMac::ColorChooserMac(content::WebContents* web_contents,
+ SkColor initial_color)
+ : ColorChooser(web_contents) {
panel_.reset([[ColorPanelCocoa alloc] initWithChooser:this]);
[panel_ setColor:gfx::SkColorToDeviceNSColor(initial_color)];
[[NSColorPanel sharedColorPanel] makeKeyAndOrderFront:nil];
@@ -71,19 +70,17 @@ ColorChooserMac::~ColorChooserMac() {
DCHECK(!panel_);
}
-void ColorChooserMac::DidChooseColor(SkColor color) {
- if (web_contents())
- web_contents()->DidChooseColorInColorChooser(identifier(), color);
+void ColorChooserMac::DidChooseColorInColorPanel(SkColor color) {
+ DidChooseColor(color);
}
-void ColorChooserMac::DidClose() {
+void ColorChooserMac::DidCloseColorPabel() {
End();
}
void ColorChooserMac::End() {
panel_.reset();
- if (web_contents())
- web_contents()->DidEndColorChooser(identifier());
+ DidEndColorChooser();
}
void ColorChooserMac::SetSelectedColor(SkColor color) {
@@ -116,7 +113,7 @@ void ColorChooserMac::SetSelectedColor(SkColor color) {
}
- (void)windowWillClose:(NSNotification*)notification {
- chooser_->DidClose();
+ chooser_->DidCloseColorPabel();
nonUserChange_ = NO;
}
@@ -125,7 +122,7 @@ void ColorChooserMac::SetSelectedColor(SkColor color) {
nonUserChange_ = NO;
return;
}
- chooser_->DidChooseColor(gfx::NSDeviceColorToSkColor(
+ chooser_->DidChooseColorInColorPanel(gfx::NSDeviceColorToSkColor(
[[panel color] colorUsingColorSpaceName:NSDeviceRGBColorSpace]));
nonUserChange_ = NO;
}

Powered by Google App Engine
This is Rietveld 408576698