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.
5 #ifndef MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_
6 #define MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h"
10 #include "mojo/public/cpp/application/lazy_interface_ptr.h"
11 #include "mojo/services/public/cpp/view_manager/view_observer.h"
12 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h"
13 #include "mojo/services/public/interfaces/network/url_loader.mojom.h"
14 #include "third_party/WebKit/public/web/WebFrameClient.h"
15 #include "third_party/WebKit/public/web/WebViewClient.h"
22 // A view for a single HTML document.
23 class HTMLDocumentView : public blink::WebViewClient,
24 public blink::WebFrameClient,
27 HTMLDocumentView(ServiceProvider* service_provider,
28 ViewManager* view_manager);
29 virtual ~HTMLDocumentView();
31 void AttachToView(View* view);
33 void Load(URLResponsePtr response);
36 // WebViewClient methods:
37 virtual blink::WebStorageNamespace* createSessionStorageNamespace();
39 // WebWidgetClient methods:
40 virtual void didInvalidateRect(const blink::WebRect& rect);
41 virtual bool allowsBrokenNullLayerTreeView() const;
43 // WebFrameClient methods:
44 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame);
45 virtual blink::WebNavigationPolicy decidePolicyForNavigation(
46 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data,
47 const blink::WebURLRequest& request, blink::WebNavigationType nav_type,
48 blink::WebNavigationPolicy default_policy, bool isRedirect);
49 virtual void didAddMessageToConsole(
50 const blink::WebConsoleMessage& message,
51 const blink::WebString& source_name,
53 const blink::WebString& stack_trace);
54 virtual void didNavigateWithinPage(
55 blink::WebLocalFrame* frame,
56 const blink::WebHistoryItem& history_item,
57 blink::WebHistoryCommitType commit_type);
59 // ViewObserver methods:
60 virtual void OnViewBoundsChanged(View* view,
61 const gfx::Rect& old_bounds,
62 const gfx::Rect& new_bounds) OVERRIDE;
63 virtual void OnViewDestroyed(View* view) OVERRIDE;
64 virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE;
68 ViewManager* view_manager_;
70 blink::WebView* web_view_;
72 bool repaint_pending_;
73 LazyInterfacePtr<NavigatorHost> navigator_host_;
75 base::WeakPtrFactory<HTMLDocumentView> weak_factory_;
76 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentView);
81 #endif // MOJO_SERVICES_HTML_VIEWER_HTML_DOCUMENT_VIEW_H_