OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 COMPONENTS_DOM_DISTILLER_CORE_TEST_REQUEST_VIEW_HANDLE_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_CORE_TEST_REQUEST_VIEW_HANDLE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "components/dom_distiller/core/distilled_page_prefs.h" |
| 11 #include "components/dom_distiller/core/dom_distiller_request_view_base.h" |
| 12 |
| 13 namespace dom_distiller { |
| 14 |
| 15 // TestRequestViewHandle allows the javascript buffer to be collected at any |
| 16 // point and viewed. This class is for testing only. |
| 17 class TestRequestViewHandle : public DomDistillerRequestViewBase { |
| 18 public: |
| 19 TestRequestViewHandle(DistilledPagePrefs* prefs); |
| 20 ~TestRequestViewHandle() override; |
| 21 |
| 22 std::string GetJavaScriptBuffer(); |
| 23 void ClearJavaScriptBuffer(); |
| 24 |
| 25 private: |
| 26 void SendJavaScript(const std::string& buffer) override; |
| 27 std::string buffer_; |
| 28 }; |
| 29 |
| 30 TestRequestViewHandle::TestRequestViewHandle(DistilledPagePrefs* prefs) |
| 31 : DomDistillerRequestViewBase(prefs) { |
| 32 } |
| 33 |
| 34 TestRequestViewHandle::~TestRequestViewHandle() { |
| 35 distilled_page_prefs_->RemoveObserver(this); |
| 36 } |
| 37 |
| 38 std::string TestRequestViewHandle::GetJavaScriptBuffer() { |
| 39 return buffer_; |
| 40 } |
| 41 |
| 42 void TestRequestViewHandle::ClearJavaScriptBuffer() { |
| 43 buffer_ = ""; |
| 44 } |
| 45 |
| 46 void TestRequestViewHandle::SendJavaScript(const std::string& buffer) { |
| 47 buffer_ += buffer; |
| 48 } |
| 49 |
| 50 } // namespace dom_distiller |
| 51 |
| 52 #endif // COMPONENTS_DOM_DISTILLER_CORE_TEST_REQUEST_VIEW_HANDLE_H_ |
OLD | NEW |