| 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 #ifndef CONTENT_PUBLIC_BROWSER_COLOR_CHOOSER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_COLOR_CHOOSER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_COLOR_CHOOSER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_COLOR_CHOOSER_H_ |
| 7 | 7 |
| 8 #include "third_party/skia/include/core/SkColor.h" | 8 #include "third_party/skia/include/core/SkColor.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 class WebContents; | 12 class WebContents; |
| 13 | 13 |
| 14 // Abstraction object for color choosers for each platform. | 14 // Abstraction object for color choosers for each platform. |
| 15 class ColorChooser { | 15 class ColorChooser { |
| 16 public: | 16 public: |
| 17 static ColorChooser* Create(int identifier, | 17 static ColorChooser* Create(int identifier, |
| 18 WebContents* web_contents, | 18 WebContents* web_contents, |
| 19 SkColor initial_color); | 19 SkColor initial_color); |
| 20 ColorChooser(int identifier) : identifier_(identifier) {} | 20 explicit ColorChooser(int identifier) : identifier_(identifier) {} |
| 21 virtual ~ColorChooser() {} | 21 virtual ~ColorChooser() {} |
| 22 | 22 |
| 23 // Returns a unique identifier for this chooser. Identifiers are unique | 23 // Returns a unique identifier for this chooser. Identifiers are unique |
| 24 // across a renderer process. This avoids race conditions in synchronizing | 24 // across a renderer process. This avoids race conditions in synchronizing |
| 25 // the browser and renderer processes. For example, if a renderer closes one | 25 // the browser and renderer processes. For example, if a renderer closes one |
| 26 // chooser and opens another, and simultaneously the user picks a color in the | 26 // chooser and opens another, and simultaneously the user picks a color in the |
| 27 // first chooser, the IDs can be used to drop the "chose a color" message | 27 // first chooser, the IDs can be used to drop the "chose a color" message |
| 28 // rather than erroneously tell the renderer that the user picked a color in | 28 // rather than erroneously tell the renderer that the user picked a color in |
| 29 // the second chooser. | 29 // the second chooser. |
| 30 int identifier() const { return identifier_; } | 30 int identifier() const { return identifier_; } |
| 31 | 31 |
| 32 // Ends connection with color chooser. Closes color chooser depending on the | 32 // Ends connection with color chooser. Closes color chooser depending on the |
| 33 // platform. | 33 // platform. |
| 34 virtual void End() = 0; | 34 virtual void End() = 0; |
| 35 | 35 |
| 36 // Sets the selected color. | 36 // Sets the selected color. |
| 37 virtual void SetSelectedColor(SkColor color) = 0; | 37 virtual void SetSelectedColor(SkColor color) = 0; |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 int identifier_; | 40 int identifier_; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 } // namespace content | 43 } // namespace content |
| 44 | 44 |
| 45 #endif // CONTENT_PUBLIC_BROWSER_COLOR_CHOOSER_H_ | 45 #endif // CONTENT_PUBLIC_BROWSER_COLOR_CHOOSER_H_ |
| OLD | NEW |