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_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_COLOR_SELECT_OBSERVER_H_ |
| 7 #pragma once |
| 8 |
| 9 #if defined(ENABLE_INPUT_COLOR) |
| 10 |
| 11 #include "content/public/browser/web_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 class ColorSelectObserver |
| 23 : public content::WebContentsObserver, |
| 24 #if defined(OS_WIN) |
| 25 public ColorChooserDialog::Listener { |
| 26 #else |
| 27 public ColorChooser::Listener { |
| 28 #endif |
| 29 public: |
| 30 explicit ColorSelectObserver(content::WebContents* web_contents); |
| 31 virtual ~ColorSelectObserver(); |
| 32 |
| 33 virtual void DidChooseColor(WebKit::WebColor color) OVERRIDE; |
| 34 virtual void DidDetach() OVERRIDE; |
| 35 |
| 36 private: |
| 37 // TabContentsObserver overrides. |
| 38 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 39 |
| 40 // Called when web page asks to open the color chooser. |
| 41 void OnOpenColorChooser( |
| 42 const ViewHostMsg_SetSelectedColorInColorChooser_Params& params); |
| 43 |
| 44 // Called when the originating element is no longer available and the color |
| 45 // chooser should detach. |
| 46 void OnDetachColorChooser(); |
| 47 |
| 48 // Called when input element's value changes and the color chooser should |
| 49 // reflect that. |
| 50 void OnSetSelectedColorInColorChooser( |
| 51 const ViewHostMsg_SetSelectedColorInColorChooser_Params& params); |
| 52 |
| 53 // The RenderViewHost for the page showing the color chooser. |
| 54 // DetachColorChooser and SetSelectedColorInColorChooser from other |
| 55 // RenderViewHosts will be ignored. |
| 56 RenderViewHost* render_view_host_; |
| 57 #if defined(OS_WIN) |
| 58 // Dialog box used for choosing color. |
| 59 scoped_refptr<ColorChooserDialog> color_chooser_dialog_; |
| 60 #endif |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(ColorSelectObserver); |
| 63 }; |
| 64 |
| 65 #endif // defined(ENABLE_INPUT_COLOR) |
| 66 |
| 67 #endif // CHROME_BROWSER_COLOR_SELECT_OBSERVER_H_ |
OLD | NEW |