OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_H_ | 5 #ifndef COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_H_ |
6 #define COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_H_ | 6 #define COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/observer_list.h" | |
12 #include "components/html_viewer/ax_provider_impl.h" | 13 #include "components/html_viewer/ax_provider_impl.h" |
13 #include "components/html_viewer/touch_handler.h" | 14 #include "components/html_viewer/touch_handler.h" |
14 #include "components/view_manager/public/cpp/view_manager_client_factory.h" | 15 #include "components/view_manager/public/cpp/view_manager_client_factory.h" |
15 #include "components/view_manager/public/cpp/view_manager_delegate.h" | 16 #include "components/view_manager/public/cpp/view_manager_delegate.h" |
16 #include "components/view_manager/public/cpp/view_observer.h" | 17 #include "components/view_manager/public/cpp/view_observer.h" |
17 #include "mandoline/services/navigation/public/interfaces/navigation.mojom.h" | 18 #include "mandoline/services/navigation/public/interfaces/navigation.mojom.h" |
18 #include "mojo/application/public/cpp/app_lifetime_helper.h" | 19 #include "mojo/application/public/cpp/app_lifetime_helper.h" |
19 #include "mojo/application/public/cpp/interface_factory.h" | 20 #include "mojo/application/public/cpp/interface_factory.h" |
20 #include "mojo/application/public/cpp/lazy_interface_ptr.h" | 21 #include "mojo/application/public/cpp/lazy_interface_ptr.h" |
21 #include "mojo/application/public/cpp/service_provider_impl.h" | 22 #include "mojo/application/public/cpp/service_provider_impl.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
34 class ViewManager; | 35 class ViewManager; |
35 class View; | 36 class View; |
36 } | 37 } |
37 | 38 |
38 namespace html_viewer { | 39 namespace html_viewer { |
39 | 40 |
40 class AxProviderImpl; | 41 class AxProviderImpl; |
41 class DevToolsAgentImpl; | 42 class DevToolsAgentImpl; |
42 class GeolocationClientImpl; | 43 class GeolocationClientImpl; |
43 class GlobalState; | 44 class GlobalState; |
45 class StatsCollectionController; | |
44 class WebLayerTreeViewImpl; | 46 class WebLayerTreeViewImpl; |
45 | 47 |
46 // A view for a single HTML document. | 48 // A view for a single HTML document. |
47 // | 49 // |
48 // HTMLDocument is deleted in one of two ways: | 50 // HTMLDocument is deleted in one of two ways: |
49 // . When the View the HTMLDocument is embedded in is destroyed. | 51 // . When the View the HTMLDocument is embedded in is destroyed. |
50 // . Explicitly by way of Destroy(). | 52 // . Explicitly by way of Destroy(). |
51 class HTMLDocument : public blink::WebViewClient, | 53 class HTMLDocument : public blink::WebViewClient, |
52 public blink::WebFrameClient, | 54 public blink::WebFrameClient, |
53 public mojo::ViewManagerDelegate, | 55 public mojo::ViewManagerDelegate, |
(...skipping 10 matching lines...) Expand all Loading... | |
64 const DeleteCallback& delete_callback); | 66 const DeleteCallback& delete_callback); |
65 ~CreateParams(); | 67 ~CreateParams(); |
66 | 68 |
67 mojo::ApplicationImpl* html_document_app; | 69 mojo::ApplicationImpl* html_document_app; |
68 mojo::ApplicationConnection* connection; | 70 mojo::ApplicationConnection* connection; |
69 mojo::URLResponsePtr response; | 71 mojo::URLResponsePtr response; |
70 GlobalState* global_state; | 72 GlobalState* global_state; |
71 DeleteCallback delete_callback; | 73 DeleteCallback delete_callback; |
72 }; | 74 }; |
73 | 75 |
76 class Observer { | |
sky
2015/08/12 23:54:36
I'm hoping to nuke HTMLDocument soon. Can you move
msw
2015/08/14 23:20:34
Nothing actually uses StatsCollectionController::G
| |
77 public: | |
78 explicit Observer(HTMLDocument* html_document); | |
79 virtual ~Observer(); | |
80 virtual void DidStartLoading() {} | |
81 virtual void DidStopLoading() {} | |
82 HTMLDocument* html_document() const { return html_document_; } | |
83 private: | |
84 HTMLDocument* html_document_; | |
85 DISALLOW_COPY_AND_ASSIGN(Observer); | |
86 }; | |
87 | |
74 // Load a new HTMLDocument with |response|. | 88 // Load a new HTMLDocument with |response|. |
75 // |html_document_app| is the application this app was created in, and | 89 // |html_document_app| is the application this app was created in, and |
76 // |connection| the specific connection triggering this new instance. | 90 // |connection| the specific connection triggering this new instance. |
77 // |setup| is used to obtain init type state (such as resources). | 91 // |setup| is used to obtain init type state (such as resources). |
78 explicit HTMLDocument(CreateParams* params); | 92 explicit HTMLDocument(CreateParams* params); |
79 | 93 |
80 // Deletes this object. | 94 // Deletes this object. |
81 void Destroy(); | 95 void Destroy(); |
82 | 96 |
97 void AddObserver(HTMLDocument::Observer* observer); | |
sky
2015/08/12 23:54:36
Can these two be private since Observer takes care
msw
2015/08/14 23:20:34
Removed.
| |
98 void RemoveObserver(HTMLDocument::Observer* observer); | |
99 | |
83 blink::WebView* web_view() const { return web_view_; } | 100 blink::WebView* web_view() const { return web_view_; } |
84 | 101 |
85 protected: | 102 protected: |
86 ~HTMLDocument() override; | 103 ~HTMLDocument() override; |
87 | 104 |
88 // WebViewClient methods: | 105 // WebViewClient methods: |
89 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); | 106 virtual blink::WebStorageNamespace* createSessionStorageNamespace(); |
90 | 107 |
91 // WebWidgetClient methods: | 108 // WebWidgetClient methods: |
92 void initializeLayerTreeView() override; | 109 void initializeLayerTreeView() override; |
(...skipping 14 matching lines...) Expand all Loading... | |
107 virtual void frameDetached(blink::WebFrame* frame, DetachType type); | 124 virtual void frameDetached(blink::WebFrame* frame, DetachType type); |
108 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); | 125 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); |
109 virtual blink::WebNavigationPolicy decidePolicyForNavigation( | 126 virtual blink::WebNavigationPolicy decidePolicyForNavigation( |
110 const NavigationPolicyInfo& info); | 127 const NavigationPolicyInfo& info); |
111 virtual blink::WebGeolocationClient* geolocationClient(); | 128 virtual blink::WebGeolocationClient* geolocationClient(); |
112 | 129 |
113 virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message, | 130 virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message, |
114 const blink::WebString& source_name, | 131 const blink::WebString& source_name, |
115 unsigned source_line, | 132 unsigned source_line, |
116 const blink::WebString& stack_trace); | 133 const blink::WebString& stack_trace); |
134 virtual void didStartLoading(bool toDifferentDocument); | |
yzshen1
2015/08/13 15:59:11
naming style: to_different_document, so it is cons
msw
2015/08/14 23:20:34
Removed.
| |
135 virtual void didStopLoading(); | |
136 virtual void didHandleOnloadEvents(blink::WebLocalFrame* frame); | |
117 virtual void didFinishLoad(blink::WebLocalFrame* frame); | 137 virtual void didFinishLoad(blink::WebLocalFrame* frame); |
118 virtual void didNavigateWithinPage(blink::WebLocalFrame* frame, | 138 virtual void didNavigateWithinPage(blink::WebLocalFrame* frame, |
119 const blink::WebHistoryItem& history_item, | 139 const blink::WebHistoryItem& history_item, |
120 blink::WebHistoryCommitType commit_type); | 140 blink::WebHistoryCommitType commit_type); |
141 virtual void didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame); | |
121 virtual blink::WebEncryptedMediaClient* encryptedMediaClient(); | 142 virtual blink::WebEncryptedMediaClient* encryptedMediaClient(); |
122 | 143 |
123 private: | 144 private: |
124 // Data associated with a child iframe. | 145 // Data associated with a child iframe. |
125 struct ChildFrameData { | 146 struct ChildFrameData { |
126 mojo::View* view; | 147 mojo::View* view; |
127 blink::WebTreeScopeType scope; | 148 blink::WebTreeScopeType scope; |
128 }; | 149 }; |
129 | 150 |
130 // Updates the size and scale factor of the webview and related classes from | 151 // Updates the size and scale factor of the webview and related classes from |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 bool did_finish_load_ = false; | 203 bool did_finish_load_ = false; |
183 | 204 |
184 GlobalState* global_state_; | 205 GlobalState* global_state_; |
185 | 206 |
186 scoped_ptr<TouchHandler> touch_handler_; | 207 scoped_ptr<TouchHandler> touch_handler_; |
187 | 208 |
188 scoped_ptr<DevToolsAgentImpl> devtools_agent_; | 209 scoped_ptr<DevToolsAgentImpl> devtools_agent_; |
189 | 210 |
190 DeleteCallback delete_callback_; | 211 DeleteCallback delete_callback_; |
191 | 212 |
213 StatsCollectionController* stats_collection_controller_; | |
yzshen1
2015/08/13 15:59:11
Please comment about ownership and when it is null
msw
2015/08/14 23:20:34
Hmm, holding gin::Wrappable objects on the heap is
| |
214 base::ObserverList<HTMLDocument::Observer> observers_; | |
215 | |
192 DISALLOW_COPY_AND_ASSIGN(HTMLDocument); | 216 DISALLOW_COPY_AND_ASSIGN(HTMLDocument); |
193 }; | 217 }; |
194 | 218 |
195 } // namespace html_viewer | 219 } // namespace html_viewer |
196 | 220 |
197 #endif // COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_H_ | 221 #endif // COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_H_ |
OLD | NEW |