OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_COLOR_SELECT_HELPER_H_ | |
6 #define CHROME_BROWSER_COLOR_SELECT_HELPER_H_ | |
7 #pragma once | |
8 | |
9 #if defined(ENABLE_INPUT_COLOR) | |
10 | |
11 #include "content/browser/tab_contents/tab_contents_observer.h" | |
12 | |
13 #if defined(OS_WIN) | |
14 #include "chrome/browser/ui/color_chooser_dialog.h" | |
15 #else | |
16 #include "chrome/browser/ui/color_chooser.h" | |
17 #endif | |
18 | |
19 class RenderViewHost; | |
20 struct ViewHostMsg_SetSelectedColorInColorChooser_Params; | |
21 | |
22 // This class requests to the color chooser. It implements listener interface | |
23 // for the color chooser. | |
24 class ColorSelectHelper | |
25 #if defined(OS_WIN) | |
26 : public ColorChooserDialog::Listener { | |
27 #else | |
28 : public ColorChooser::Listener { | |
29 #endif | |
30 public: | |
31 explicit ColorSelectHelper(); | |
32 virtual ~ColorSelectHelper(); | |
33 | |
34 void OpenColorChooser(RenderViewHost* render_view_host, | |
35 WebKit::WebColor color); | |
36 void CleanupColorChooser(RenderViewHost* render_view_host); | |
37 void SetSelectedColorInColorChooser(RenderViewHost* render_view_host, | |
38 WebKit::WebColor color); | |
39 | |
40 virtual void DidChooseColor(WebKit::WebColor color); | |
41 virtual void DidCleanup(); | |
42 | |
43 private: | |
44 // The RenderViewHost for the page showing the color chooser. | |
45 // CleanupColorChooser and SetSelectedColorInColorChooser from other | |
46 // RenderViewHosts will be ignored. | |
47 RenderViewHost* render_view_host_; | |
48 #if defined(OS_WIN) | |
49 // Dialog box used for choosing color. | |
50 scoped_refptr<ColorChooserDialog> color_chooser_dialog_; | |
51 #endif | |
yosin_UTC9
2011/12/06 07:11:17
We want to have
DISALLOW_COPY_AND_ASSIGN(ColorSele
| |
52 }; | |
53 | |
54 class ColorSelectObserver : public TabContentsObserver { | |
55 public: | |
56 explicit ColorSelectObserver(TabContents* tab_contents); | |
57 virtual ~ColorSelectObserver(); | |
58 | |
59 private: | |
60 // TabContentsObserver overrides. | |
61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
62 | |
63 // Called when web page asks to open the color chooser. | |
64 void OnOpenColorChooser( | |
65 const ViewHostMsg_SetSelectedColorInColorChooser_Params& params); | |
66 | |
67 // Called when the originating element is no longer available and the color | |
68 // chooser should cleanup. | |
69 void OnCleanupColorChooser(); | |
70 | |
71 // Called when input element's value changes and the color chooser should | |
72 // reflect that. | |
73 void OnSetSelectedColorInColorChooser( | |
74 const ViewHostMsg_SetSelectedColorInColorChooser_Params& params); | |
75 | |
76 // ColorSelectHelper, lazily created. | |
77 scoped_ptr<ColorSelectHelper> color_select_helper_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(ColorSelectObserver); | |
80 }; | |
81 | |
82 #endif // defined(ENABLE_INPUT_COLOR) | |
83 | |
84 #endif // CHROME_BROWSER_COLOR_SELECT_HELPER_H_ | |
OLD | NEW |