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