| 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 #include "chrome/browser/color_select_helper.h" |
| 6 |
| 7 #include "content/browser/renderer_host/render_view_host.h" |
| 8 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 9 #include "content/browser/tab_contents/tab_contents.h" |
| 10 #include "content/common/view_messages.h" |
| 11 |
| 12 ColorSelectHelper::ColorSelectHelper() { |
| 13 } |
| 14 |
| 15 ColorSelectHelper::~ColorSelectHelper() { |
| 16 } |
| 17 |
| 18 void ColorSelectHelper::OpenColorChooser(content::WebContents* tab, |
| 19 const WebKit::WebColor& color) { |
| 20 tab_ = tab; |
| 21 if (!color_chooser_.get()) |
| 22 color_chooser_.reset(ColorChooser::Create()); |
| 23 color_chooser_->Open(this, color); |
| 24 } |
| 25 |
| 26 void ColorSelectHelper::EndColorChooser(content::WebContents* tab) { |
| 27 if (tab_ != tab) |
| 28 return; |
| 29 if (!color_chooser_.get()) |
| 30 return; |
| 31 color_chooser_->End(this); |
| 32 } |
| 33 |
| 34 void ColorSelectHelper::SetSelectedColorInColorChooser( |
| 35 content::WebContents* tab, |
| 36 const WebKit::WebColor& color) { |
| 37 if (tab_ != tab) |
| 38 return; |
| 39 if (!color_chooser_.get()) |
| 40 return; |
| 41 color_chooser_ ->SetSelectedColor(color); |
| 42 } |
| 43 |
| 44 void ColorSelectHelper::DidChooseColor(WebKit::WebColor color) { |
| 45 tab_->GetRenderViewHost()->DidChooseColorInColorChooser(color); |
| 46 } |
| 47 |
| 48 void ColorSelectHelper::DidEnd() { |
| 49 tab_->GetRenderViewHost()->DidEndColorChooser(); |
| 50 color_chooser_.reset(NULL); |
| 51 } |
| 52 |
| 53 RenderViewHost* ColorSelectHelper::GetRenderViewHost() { |
| 54 if (!tab_) |
| 55 return NULL; |
| 56 return tab_->GetRenderViewHost(); |
| 57 } |
| OLD | NEW |