OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 "content/shell/renderer/test_runner/mock_color_chooser.h" |
| 6 |
| 7 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
| 8 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
| 9 |
| 10 namespace content { |
| 11 |
| 12 namespace { |
| 13 class HostMethodTask : public WebMethodTask<MockColorChooser> { |
| 14 public: |
| 15 typedef void (MockColorChooser::*CallbackMethodType)(); |
| 16 HostMethodTask(MockColorChooser* object, CallbackMethodType callback) |
| 17 : WebMethodTask<MockColorChooser>(object), |
| 18 callback_(callback) {} |
| 19 |
| 20 virtual void runIfValid() OVERRIDE { (m_object->*callback_)(); } |
| 21 |
| 22 private: |
| 23 CallbackMethodType callback_; |
| 24 }; |
| 25 |
| 26 } // namespace |
| 27 |
| 28 MockColorChooser::MockColorChooser(blink::WebColorChooserClient* client, |
| 29 WebTestDelegate* delegate, |
| 30 WebTestProxyBase* proxy) |
| 31 : client_(client), |
| 32 delegate_(delegate), |
| 33 proxy_(proxy) { |
| 34 proxy_->DidOpenChooser(); |
| 35 } |
| 36 |
| 37 MockColorChooser::~MockColorChooser() { |
| 38 proxy_->DidCloseChooser(); |
| 39 } |
| 40 |
| 41 void MockColorChooser::setSelectedColor(const blink::WebColor color) {} |
| 42 |
| 43 void MockColorChooser::endChooser() { |
| 44 delegate_->postDelayedTask(new HostMethodTask(this, &MockColorChooser::InvokeD
idEndChooser), 0); |
| 45 } |
| 46 |
| 47 void MockColorChooser::InvokeDidEndChooser() { |
| 48 client_->didEndChooser(); |
| 49 } |
| 50 |
| 51 } // namespace content |
OLD | NEW |