Chromium Code Reviews| Index: chrome/browser/color_select_helper.h |
| diff --git a/chrome/browser/color_select_helper.h b/chrome/browser/color_select_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..60bf46ef0396c0f6c6b52c0246a9b1a5e3d16a9a |
| --- /dev/null |
| +++ b/chrome/browser/color_select_helper.h |
| @@ -0,0 +1,84 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_COLOR_SELECT_HELPER_H_ |
| +#define CHROME_BROWSER_COLOR_SELECT_HELPER_H_ |
| +#pragma once |
| + |
| +#if defined(ENABLE_INPUT_COLOR) |
| + |
| +#include "content/browser/tab_contents/tab_contents_observer.h" |
| + |
| +#if defined(OS_WIN) |
| +#include "chrome/browser/ui/color_chooser_dialog.h" |
| +#else |
| +#include "chrome/browser/ui/color_chooser.h" |
| +#endif |
| + |
| +class RenderViewHost; |
| +struct ViewHostMsg_SetSelectedColorInColorChooser_Params; |
| + |
| +// This class requests to the color chooser. It implements listener interface |
| +// for the color chooser. |
| +class ColorSelectHelper |
| +#if defined(OS_WIN) |
| + : public ColorChooserDialog::Listener { |
| +#else |
| + : public ColorChooser::Listener { |
| +#endif |
| + public: |
| + explicit ColorSelectHelper(); |
| + virtual ~ColorSelectHelper(); |
| + |
| + void OpenColorChooser(RenderViewHost* render_view_host, |
| + WebKit::WebColor color); |
| + void CleanupColorChooser(RenderViewHost* render_view_host); |
| + void SetSelectedColorInColorChooser(RenderViewHost* render_view_host, |
| + WebKit::WebColor color); |
| + |
| + virtual void DidChooseColor(WebKit::WebColor color); |
| + virtual void DidCleanup(); |
| + |
| + private: |
| + // The RenderViewHost for the page showing the color chooser. |
| + // CleanupColorChooser and SetSelectedColorInColorChooser from other |
| + // RenderViewHosts will be ignored. |
| + RenderViewHost* render_view_host_; |
| +#if defined(OS_WIN) |
| + // Dialog box used for choosing color. |
| + scoped_refptr<ColorChooserDialog> color_chooser_dialog_; |
| +#endif |
|
yosin_UTC9
2011/12/06 07:11:17
We want to have
DISALLOW_COPY_AND_ASSIGN(ColorSele
|
| +}; |
| + |
| +class ColorSelectObserver : public TabContentsObserver { |
| + public: |
| + explicit ColorSelectObserver(TabContents* tab_contents); |
| + virtual ~ColorSelectObserver(); |
| + |
| + private: |
| + // TabContentsObserver overrides. |
| + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| + |
| + // Called when web page asks to open the color chooser. |
| + void OnOpenColorChooser( |
| + const ViewHostMsg_SetSelectedColorInColorChooser_Params& params); |
| + |
| + // Called when the originating element is no longer available and the color |
| + // chooser should cleanup. |
| + void OnCleanupColorChooser(); |
| + |
| + // Called when input element's value changes and the color chooser should |
| + // reflect that. |
| + void OnSetSelectedColorInColorChooser( |
| + const ViewHostMsg_SetSelectedColorInColorChooser_Params& params); |
| + |
| + // ColorSelectHelper, lazily created. |
| + scoped_ptr<ColorSelectHelper> color_select_helper_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ColorSelectObserver); |
| +}; |
| + |
| +#endif // defined(ENABLE_INPUT_COLOR) |
| + |
| +#endif // CHROME_BROWSER_COLOR_SELECT_HELPER_H_ |