1// Copyright 2014 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 MOJO_EXAMPLES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ 6#define MOJO_EXAMPLES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ 7 8#include "base/memory/weak_ptr.h" 9#include "mojo/services/public/interfaces/network/url_loader.mojom.h" 10#include "third_party/WebKit/public/web/WebFrameClient.h" 11#include "third_party/WebKit/public/web/WebViewClient.h" 12 13namespace mojo { 14 15namespace view_manager { 16class Node; 17class ViewManager; 18class View; 19} 20 21namespace examples { 22 23// A view for a single HTML document. 24class HTMLDocumentView : public blink::WebViewClient, 25 public blink::WebFrameClient { 26 public: 27 explicit HTMLDocumentView(view_manager::ViewManager* view_manager); 28 virtual ~HTMLDocumentView(); 29 30 void AttachToNode(view_manager::Node* node); 31 32 void Load(URLResponsePtr response, 33 ScopedDataPipeConsumerHandle response_body_stream); 34 35 private: 36 // WebWidgetClient methods: 37 virtual void didInvalidateRect(const blink::WebRect& rect); 38 virtual bool allowsBrokenNullLayerTreeView() const; 39 40 // WebFrameClient methods: 41 virtual void didAddMessageToConsole( 42 const blink::WebConsoleMessage& message, 43 const blink::WebString& source_name, 44 unsigned source_line, 45 const blink::WebString& stack_trace); 46 47 void Repaint(); 48 49 view_manager::ViewManager* view_manager_; 50 view_manager::View* view_; 51 blink::WebView* web_view_; 52 bool repaint_pending_; 53 54 base::WeakPtrFactory<HTMLDocumentView> weak_factory_; 55 56 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentView); 57}; 58 59} // namespace examples 60} // namespace mojo 61 62#endif // MOJO_EXAMPLES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_ 63