| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "base/memory/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 9 #include "chrome/browser/ui/browser_dialogs.h" | 9 #include "chrome/browser/ui/browser_dialogs.h" |
| 10 #include "content/public/browser/color_chooser.h" | 10 #include "content/public/browser/color_chooser.h" |
| 11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "skia/ext/skia_utils_mac.h" | 12 #include "skia/ext/skia_utils_mac.h" |
| 13 | 13 |
| 14 class ColorChooserMac; | 14 class ColorChooserMac; |
| 15 | 15 |
| 16 // A Listener class to act as a event target for NSColorPanel and send | 16 // A Listener class to act as a event target for NSColorPanel and send |
| 17 // the results to the C++ class, ColorChooserMac. | 17 // the results to the C++ class, ColorChooserMac. |
| 18 @interface ColorPanelCocoa : NSObject<NSWindowDelegate> { | 18 @interface ColorPanelCocoa : NSObject<NSWindowDelegate> { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 47 | 47 |
| 48 virtual void End() OVERRIDE; | 48 virtual void End() OVERRIDE; |
| 49 virtual void SetSelectedColor(SkColor color) OVERRIDE; | 49 virtual void SetSelectedColor(SkColor color) OVERRIDE; |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 static ColorChooserMac* current_color_chooser_; | 52 static ColorChooserMac* current_color_chooser_; |
| 53 | 53 |
| 54 // The web contents invoking the color chooser. No ownership because it will | 54 // The web contents invoking the color chooser. No ownership because it will |
| 55 // outlive this class. | 55 // outlive this class. |
| 56 content::WebContents* web_contents_; | 56 content::WebContents* web_contents_; |
| 57 scoped_nsobject<ColorPanelCocoa> panel_; | 57 base::scoped_nsobject<ColorPanelCocoa> panel_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 ColorChooserMac* ColorChooserMac::current_color_chooser_ = NULL; | 60 ColorChooserMac* ColorChooserMac::current_color_chooser_ = NULL; |
| 61 | 61 |
| 62 // static | 62 // static |
| 63 ColorChooserMac* ColorChooserMac::Open(content::WebContents* web_contents, | 63 ColorChooserMac* ColorChooserMac::Open(content::WebContents* web_contents, |
| 64 SkColor initial_color) { | 64 SkColor initial_color) { |
| 65 if (current_color_chooser_) | 65 if (current_color_chooser_) |
| 66 current_color_chooser_->End(); | 66 current_color_chooser_->End(); |
| 67 DCHECK(!current_color_chooser_); | 67 DCHECK(!current_color_chooser_); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 namespace chrome { | 152 namespace chrome { |
| 153 | 153 |
| 154 content::ColorChooser* ShowColorChooser(content::WebContents* web_contents, | 154 content::ColorChooser* ShowColorChooser(content::WebContents* web_contents, |
| 155 SkColor initial_color) { | 155 SkColor initial_color) { |
| 156 return ColorChooserMac::Open(web_contents, initial_color); | 156 return ColorChooserMac::Open(web_contents, initial_color); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namepace chrome | 159 } // namepace chrome |
| 160 | 160 |
| 161 @end | 161 @end |
| OLD | NEW |