| Index: chrome/browser/color_select_helper.cc
|
| diff --git a/chrome/browser/color_select_helper.cc b/chrome/browser/color_select_helper.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2fe3ffdf4783ef627bed08e0a5b3ed17699bdfac
|
| --- /dev/null
|
| +++ b/chrome/browser/color_select_helper.cc
|
| @@ -0,0 +1,57 @@
|
| +// 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.
|
| +
|
| +#include "chrome/browser/color_select_helper.h"
|
| +
|
| +#include "content/browser/renderer_host/render_view_host.h"
|
| +#include "content/browser/renderer_host/render_widget_host_view.h"
|
| +#include "content/browser/tab_contents/tab_contents.h"
|
| +#include "content/common/view_messages.h"
|
| +
|
| +ColorSelectHelper::ColorSelectHelper() {
|
| +}
|
| +
|
| +ColorSelectHelper::~ColorSelectHelper() {
|
| +}
|
| +
|
| +void ColorSelectHelper::OpenColorChooser(content::WebContents* tab,
|
| + const WebKit::WebColor& color) {
|
| + tab_ = tab;
|
| + if (!color_chooser_.get())
|
| + color_chooser_.reset(ColorChooser::Create());
|
| + color_chooser_->Open(this, color);
|
| +}
|
| +
|
| +void ColorSelectHelper::EndColorChooser(content::WebContents* tab) {
|
| + if (tab_ != tab)
|
| + return;
|
| + if (!color_chooser_.get())
|
| + return;
|
| + color_chooser_->End(this);
|
| +}
|
| +
|
| +void ColorSelectHelper::SetSelectedColorInColorChooser(
|
| + content::WebContents* tab,
|
| + const WebKit::WebColor& color) {
|
| + if (tab_ != tab)
|
| + return;
|
| + if (!color_chooser_.get())
|
| + return;
|
| + color_chooser_ ->SetSelectedColor(color);
|
| +}
|
| +
|
| +void ColorSelectHelper::DidChooseColor(WebKit::WebColor color) {
|
| + tab_->GetRenderViewHost()->DidChooseColorInColorChooser(color);
|
| +}
|
| +
|
| +void ColorSelectHelper::DidEnd() {
|
| + tab_->GetRenderViewHost()->DidEndColorChooser();
|
| + color_chooser_.reset(NULL);
|
| +}
|
| +
|
| +RenderViewHost* ColorSelectHelper::GetRenderViewHost() {
|
| + if (!tab_)
|
| + return NULL;
|
| + return tab_->GetRenderViewHost();
|
| +}
|
|
|