Merge lp:~chrisccoulson/oxide/web-frame-rework into lp:~oxide-developers/oxide/oxide.trunk
- web-frame-rework
- Merge into oxide.trunk
Status: | Merged |
---|---|
Merged at revision: | 347 |
Proposed branch: | lp:~chrisccoulson/oxide/web-frame-rework |
Merge into: | lp:~oxide-developers/oxide/oxide.trunk |
Diff against target: |
4624 lines (+2137/-839) 60 files modified
patches/add-frame-attached-to-web-contents-observer.patch (+177/-0) patches/add-frame-created-for-render-view.patch (+0/-73) patches/series (+1/-1) qt/core/api/internal/oxideqwebpreferences_p.cc (+53/-0) qt/core/api/oxideqwebpreferences.cc (+197/-0) qt/core/api/oxideqwebpreferences.h (+212/-0) qt/core/api/oxideqwebpreferences_p.h (+59/-0) qt/core/browser/oxide_qt_content_browser_client.cc (+9/-0) qt/core/browser/oxide_qt_content_browser_client.h (+2/-0) qt/core/browser/oxide_qt_web_frame.cc (+15/-13) qt/core/browser/oxide_qt_web_frame.h (+6/-2) qt/core/browser/oxide_qt_web_preferences.cc (+41/-0) qt/core/browser/oxide_qt_web_preferences.h (+34/-0) qt/core/core.gyp (+13/-2) qt/core/glue/oxide_qt_web_frame_adapter.cc (+30/-2) qt/core/glue/oxide_qt_web_frame_adapter_p.h (+1/-3) qt/core/glue/oxide_qt_web_view_adapter.cc (+44/-9) qt/core/glue/oxide_qt_web_view_adapter.h (+10/-3) qt/core/glue/private/oxide_qt_message_handler_adapter_p.cc (+1/-1) qt/core/glue/private/oxide_qt_outgoing_message_request_adapter_p.cc (+1/-2) qt/core/glue/private/oxide_qt_web_frame_adapter_p.cc (+0/-64) qt/core/glue/private/oxide_qt_web_view_adapter_p.cc (+12/-7) qt/core/glue/private/oxide_qt_web_view_adapter_p.h (+4/-3) qt/quick/api/oxideqquickwebframe.cc (+2/-2) qt/quick/api/oxideqquickwebframe_p.h (+2/-8) qt/quick/api/oxideqquickwebview.cc (+46/-14) qt/quick/api/oxideqquickwebview_p.h (+9/-2) qt/quick/api/oxideqquickwebview_p_p.h (+5/-2) qt/quick/oxide_qml_plugin.cc (+2/-0) qt/tests/qmltests/api/tst_WebFrame_tree.qml (+51/-78) qt/tests/qmltests/api/tst_WebFrame_url.qml (+1/-1) qt/tests/qmltests/api/tst_WebView_preferences.qml (+64/-0) qt/tests/qmltests/api/tst_WebView_rootFrame.qml (+13/-31) qt/tests/qmltests/oxide_qml_testing_plugin.cc (+8/-0) shared/app/oxide_content_main_delegate.cc (+8/-0) shared/browser/oxide_content_browser_client.cc (+14/-12) shared/browser/oxide_content_browser_client.h (+5/-2) shared/browser/oxide_incoming_message.cc (+10/-17) shared/browser/oxide_message_dispatcher_browser.cc (+209/-0) shared/browser/oxide_message_dispatcher_browser.h (+42/-0) shared/browser/oxide_message_handler.cc (+6/-11) shared/browser/oxide_outgoing_message_request.cc (+3/-3) shared/browser/oxide_outgoing_message_request.h (+1/-1) shared/browser/oxide_web_frame.cc (+52/-44) shared/browser/oxide_web_frame.h (+20/-23) shared/browser/oxide_web_preferences.cc (+271/-0) shared/browser/oxide_web_preferences.h (+138/-0) shared/browser/oxide_web_view.cc (+107/-165) shared/browser/oxide_web_view.h (+19/-30) shared/common/oxide_message_enums.h (+2/-7) shared/common/oxide_messages.h (+1/-2) shared/renderer/oxide_content_renderer_client.cc (+12/-6) shared/renderer/oxide_content_renderer_client.h (+1/-5) shared/renderer/oxide_message_dispatcher_renderer.cc (+57/-39) shared/renderer/oxide_message_dispatcher_renderer.h (+10/-26) shared/renderer/oxide_v8_message_manager.cc (+17/-32) shared/renderer/oxide_v8_message_manager.h (+3/-8) shared/renderer/oxide_web_frame_observer.cc (+0/-40) shared/renderer/oxide_web_frame_observer.h (+0/-41) shared/shared.gyp (+4/-2) |
To merge this branch: | bzr merge lp:~chrisccoulson/oxide/web-frame-rework |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Olivier Tilloy | Pending | ||
Review via email: mp+203854@code.launchpad.net |
Commit message
Description of the change
This refactors WebFrame and the content script message routing in both the browser and renderer to no longer use RenderView. The message routing is now done using RenderFrame, which fixes the problem that this code assumed all document frames live in the same process. This *should* future proof this functionality in preparation for http://
There's a couple of API changes too - WebFrame.
WebView.
- 332. By Chris Coulson
-
Revert some renames - I didn't want to rename all instances of args to payload
- 333. By Chris Coulson
-
Don't build WebFrameAdapter
Private in its own object file, as it's not necessary - 334. By Chris Coulson
-
Merge from trunk
Preview Diff
1 | === added file 'patches/add-frame-attached-to-web-contents-observer.patch' |
2 | --- patches/add-frame-attached-to-web-contents-observer.patch 1970-01-01 00:00:00 +0000 |
3 | +++ patches/add-frame-attached-to-web-contents-observer.patch 2014-02-07 16:51:32 +0000 |
4 | @@ -0,0 +1,177 @@ |
5 | +# Description: Add WebContentsObserver::FrameAttached(), which is the opposite of |
6 | +# the existing FrameDetached() |
7 | +# Author: Chris Coulson <chris.coulson@canonical.com> |
8 | + |
9 | +diff --git a/content/browser/frame_host/frame_tree.cc b/content/browser/frame_host/frame_tree.cc |
10 | +--- a/content/browser/frame_host/frame_tree.cc |
11 | ++++ b/content/browser/frame_host/frame_tree.cc |
12 | +@@ -108,16 +108,21 @@ RenderFrameHostImpl* FrameTree::AddFrame |
13 | + return NULL; |
14 | + |
15 | + scoped_ptr<FrameTreeNode> node(new FrameTreeNode( |
16 | + this, parent->navigator(), render_frame_delegate_, render_view_delegate_, |
17 | + render_widget_delegate_, manager_delegate_, frame_id, frame_name)); |
18 | + FrameTreeNode* node_ptr = node.get(); |
19 | + // AddChild is what creates the RenderFrameHost. |
20 | + parent->AddChild(node.Pass(), frame_routing_id); |
21 | ++ if (!on_frame_added_.is_null()) { |
22 | ++ on_frame_added_.Run( |
23 | ++ node_ptr->current_frame_host()->render_view_host(), |
24 | ++ parent_frame_id, frame_id); |
25 | ++ } |
26 | + return node_ptr->current_frame_host(); |
27 | + } |
28 | + |
29 | + void FrameTree::RemoveFrame(RenderFrameHostImpl* render_frame_host, |
30 | + int64 parent_frame_id, |
31 | + int64 frame_id) { |
32 | + // If switches::kSitePerProcess is not specified, then the FrameTree only |
33 | + // contains a node for the root element. However, even in this case |
34 | +@@ -160,16 +165,21 @@ RenderFrameHostImpl* FrameTree::GetMainF |
35 | + return root_->current_frame_host(); |
36 | + } |
37 | + |
38 | + void FrameTree::SetFrameRemoveListener( |
39 | + const base::Callback<void(RenderViewHostImpl*, int64)>& on_frame_removed) { |
40 | + on_frame_removed_ = on_frame_removed; |
41 | + } |
42 | + |
43 | ++void FrameTree::SetFrameAddListener( |
44 | ++ const base::Callback<void(RenderViewHostImpl*, int64, int64)>& on_frame_added) { |
45 | ++ on_frame_added_ = on_frame_added; |
46 | ++} |
47 | ++ |
48 | + void FrameTree::ClearFrameRemoveListenerForTesting() { |
49 | + on_frame_removed_.Reset(); |
50 | + } |
51 | + |
52 | + RenderViewHostImpl* FrameTree::CreateRenderViewHostForMainFrame( |
53 | + SiteInstance* site_instance, |
54 | + int routing_id, |
55 | + int main_frame_routing_id, |
56 | +diff --git a/content/browser/frame_host/frame_tree.h b/content/browser/frame_host/frame_tree.h |
57 | +--- a/content/browser/frame_host/frame_tree.h |
58 | ++++ b/content/browser/frame_host/frame_tree.h |
59 | +@@ -96,16 +96,18 @@ class CONTENT_EXPORT FrameTree { |
60 | + RenderFrameHostImpl* GetMainFrame() const; |
61 | + |
62 | + // Allows a client to listen for frame removal. The listener should expect |
63 | + // to receive the RenderViewHostImpl containing the frame and the renderer- |
64 | + // specific frame ID of the removed frame. |
65 | + // TODO(creis): These parameters will later change to be the RenderFrameHost. |
66 | + void SetFrameRemoveListener( |
67 | + const base::Callback<void(RenderViewHostImpl*, int64)>& on_frame_removed); |
68 | ++ void SetFrameAddListener( |
69 | ++ const base::Callback<void(RenderViewHostImpl*, int64, int64)>& on_frame_added); |
70 | + |
71 | + void ClearFrameRemoveListenerForTesting(); |
72 | + |
73 | + // Creates a RenderViewHost for a new main frame RenderFrameHost in the given |
74 | + // |site_instance|. The RenderViewHost will have its Shutdown method called |
75 | + // when all of the RenderFrameHosts using it are deleted. |
76 | + RenderViewHostImpl* CreateRenderViewHostForMainFrame( |
77 | + SiteInstance* site_instance, |
78 | +@@ -147,15 +149,16 @@ class CONTENT_EXPORT FrameTree { |
79 | + // |
80 | + // Must be declared before |root_| so that it is deleted afterward. Otherwise |
81 | + // the map will be cleared before we delete the RenderFrameHosts in the tree. |
82 | + RenderViewHostMap render_view_host_map_; |
83 | + |
84 | + scoped_ptr<FrameTreeNode> root_; |
85 | + |
86 | + base::Callback<void(RenderViewHostImpl*, int64)> on_frame_removed_; |
87 | ++ base::Callback<void(RenderViewHostImpl*, int64, int64)> on_frame_added_; |
88 | + |
89 | + DISALLOW_COPY_AND_ASSIGN(FrameTree); |
90 | + }; |
91 | + |
92 | + } // namespace content |
93 | + |
94 | + #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_H_ |
95 | +diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc |
96 | +--- a/content/browser/web_contents/web_contents_impl.cc |
97 | ++++ b/content/browser/web_contents/web_contents_impl.cc |
98 | +@@ -397,16 +397,19 @@ WebContentsImpl::WebContentsImpl( |
99 | + render_view_message_source_(NULL), |
100 | + fullscreen_widget_routing_id_(MSG_ROUTING_NONE), |
101 | + is_subframe_(false) { |
102 | + for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
103 | + g_created_callbacks.Get().at(i).Run(this); |
104 | + frame_tree_.SetFrameRemoveListener( |
105 | + base::Bind(&WebContentsImpl::OnFrameRemoved, |
106 | + base::Unretained(this))); |
107 | ++ frame_tree_.SetFrameAddListener( |
108 | ++ base::Bind(&WebContentsImpl::OnFrameAdded, |
109 | ++ base::Unretained(this))); |
110 | + } |
111 | + |
112 | + WebContentsImpl::~WebContentsImpl() { |
113 | + is_being_destroyed_ = true; |
114 | + |
115 | + ClearAllPowerSaveBlockers(); |
116 | + |
117 | + for (std::set<RenderWidgetHostImpl*>::iterator iter = |
118 | +@@ -3840,9 +3843,18 @@ gfx::Size WebContentsImpl::GetSizeForNew |
119 | + |
120 | + void WebContentsImpl::OnFrameRemoved( |
121 | + RenderViewHostImpl* render_view_host, |
122 | + int64 frame_id) { |
123 | + FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
124 | + FrameDetached(render_view_host, frame_id)); |
125 | + } |
126 | + |
127 | ++void WebContentsImpl::OnFrameAdded( |
128 | ++ RenderViewHostImpl* render_view_host, |
129 | ++ int64 parent_frame_id, |
130 | ++ int64 frame_id) { |
131 | ++ FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
132 | ++ FrameAttached(render_view_host, parent_frame_id, frame_id)); |
133 | ++ |
134 | ++} |
135 | ++ |
136 | + } // namespace content |
137 | +diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h |
138 | +--- a/content/browser/web_contents/web_contents_impl.h |
139 | ++++ b/content/browser/web_contents/web_contents_impl.h |
140 | +@@ -825,16 +825,18 @@ class CONTENT_EXPORT WebContentsImpl |
141 | + |
142 | + // Clear all PowerSaveBlockers, leave power_save_blocker_ empty. |
143 | + void ClearAllPowerSaveBlockers(); |
144 | + |
145 | + // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView(). |
146 | + gfx::Size GetSizeForNewRenderView() const; |
147 | + |
148 | + void OnFrameRemoved(RenderViewHostImpl* render_view_host, int64 frame_id); |
149 | ++ void OnFrameAdded(RenderViewHostImpl* render_view_host, |
150 | ++ int64 parent_frame_id, int64 frame_id); |
151 | + |
152 | + // Adds/removes a callback called on creation of each new WebContents. |
153 | + // Deprecated, about to remove. |
154 | + static void AddCreatedCallback(const CreatedCallback& callback); |
155 | + static void RemoveCreatedCallback(const CreatedCallback& callback); |
156 | + |
157 | + // Data for core operation --------------------------------------------------- |
158 | + |
159 | +diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h |
160 | +--- a/content/public/browser/web_contents_observer.h |
161 | ++++ b/content/public/browser/web_contents_observer.h |
162 | +@@ -229,16 +229,19 @@ class CONTENT_EXPORT WebContentsObserver |
163 | + const GURL& url, |
164 | + const Referrer& referrer, |
165 | + WindowOpenDisposition disposition, |
166 | + PageTransition transition, |
167 | + int64 source_frame_id) {} |
168 | + |
169 | + virtual void FrameDetached(RenderViewHost* render_view_host, |
170 | + int64 frame_id) {} |
171 | ++ virtual void FrameAttached(RenderViewHost* render_view_host, |
172 | ++ int64 parent_frame_id, |
173 | ++ int64 frame_id) {} |
174 | + |
175 | + // This method is invoked when the renderer has completed its first paint |
176 | + // after a non-empty layout. |
177 | + virtual void DidFirstVisuallyNonEmptyPaint(int32 page_id) {} |
178 | + |
179 | + // These two methods correspond to the points in time when the spinner of the |
180 | + // tab starts and stops spinning. |
181 | + virtual void DidStartLoading(RenderViewHost* render_view_host) {} |
182 | |
183 | === removed file 'patches/add-frame-created-for-render-view.patch' |
184 | --- patches/add-frame-created-for-render-view.patch 2014-01-20 12:35:23 +0000 |
185 | +++ patches/add-frame-created-for-render-view.patch 1970-01-01 00:00:00 +0000 |
186 | @@ -1,73 +0,0 @@ |
187 | -# Description: Make content::RenderViewObserver::FrameCreated() work correctly, |
188 | -# so that we can track frames in the browser process |
189 | -# Author: Chris Coulson <chris.coulson@canonical.com> |
190 | - |
191 | -diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc |
192 | ---- a/content/renderer/render_frame_impl.cc |
193 | -+++ b/content/renderer/render_frame_impl.cc |
194 | -@@ -587,16 +587,18 @@ blink::WebFrame* RenderFrameImpl::create |
195 | - // TODO(nasko): Over-conservative check for debugging. |
196 | - CHECK(child_render_frame); |
197 | - blink::WebFrame* web_frame = WebFrame::create(child_render_frame, |
198 | - child_frame_identifier); |
199 | - // TODO(nasko): Over-conservative check for debugging. |
200 | - CHECK(web_frame); |
201 | - child_render_frame->SetWebFrame(web_frame); |
202 | - |
203 | -+ render_view_->FrameCreated(parent, web_frame); |
204 | -+ |
205 | - return web_frame; |
206 | - } |
207 | - |
208 | - void RenderFrameImpl::didDisownOpener(blink::WebFrame* frame) { |
209 | - render_view_->didDisownOpener(frame); |
210 | - } |
211 | - |
212 | - void RenderFrameImpl::frameDetached(blink::WebFrame* frame) { |
213 | -diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc |
214 | ---- a/content/renderer/render_view_impl.cc |
215 | -+++ b/content/renderer/render_view_impl.cc |
216 | -@@ -4297,16 +4297,21 @@ void RenderViewImpl::DidPause(blink::Web |
217 | - player->hasAudio(), |
218 | - false)); |
219 | - } |
220 | - |
221 | - void RenderViewImpl::PlayerGone(blink::WebMediaPlayer* player) { |
222 | - DidPause(player); |
223 | - } |
224 | - |
225 | -+void RenderViewImpl::FrameCreated(blink::WebFrame* parent, |
226 | -+ blink::WebFrame* frame) { |
227 | -+ FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameCreated(parent, frame)); |
228 | -+} |
229 | -+ |
230 | - void RenderViewImpl::SyncNavigationState() { |
231 | - if (!webview()) |
232 | - return; |
233 | - |
234 | - const WebHistoryItem& item = webview()->mainFrame()->currentHistoryItem(); |
235 | - SendUpdateState(item); |
236 | - } |
237 | - |
238 | -diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h |
239 | ---- a/content/renderer/render_view_impl.h |
240 | -+++ b/content/renderer/render_view_impl.h |
241 | -@@ -680,16 +680,18 @@ class CONTENT_EXPORT RenderViewImpl |
242 | - // appropriate section, add it there. If not, there are some random functions |
243 | - // nearer to the top you can add it to. |
244 | - |
245 | - // Cannot use std::set unfortunately since linked_ptr<> does not support |
246 | - // operator<. |
247 | - typedef std::vector<linked_ptr<ImageResourceFetcher> > |
248 | - ImageResourceFetcherList; |
249 | - |
250 | -+ void FrameCreated(blink::WebFrame* parent, blink::WebFrame* frame); |
251 | -+ |
252 | - protected: |
253 | - // RenderWidget overrides: |
254 | - virtual void Close() OVERRIDE; |
255 | - virtual void OnResize(const ViewMsg_Resize_Params& params) OVERRIDE; |
256 | - virtual void DidInitiatePaint() OVERRIDE; |
257 | - virtual void DidFlushPaint() OVERRIDE; |
258 | - virtual PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint( |
259 | - const gfx::Rect& paint_bounds, |
260 | |
261 | === modified file 'patches/series' |
262 | --- patches/series 2014-02-07 16:15:16 +0000 |
263 | +++ patches/series 2014-02-07 16:51:32 +0000 |
264 | @@ -3,7 +3,6 @@ |
265 | gyp-support-library-version.patch |
266 | support-native-popup-menus.patch |
267 | add-oxide-messages.patch |
268 | -add-frame-created-for-render-view.patch |
269 | add-oxide-resources.patch |
270 | share-gl-resources-with-embedder.patch |
271 | arm-icu.patch |
272 | @@ -12,3 +11,4 @@ |
273 | dont-depend-on-gtk.patch |
274 | arm-neon.patch |
275 | dont-use-egl-create-context-robustness.patch |
276 | +add-frame-attached-to-web-contents-observer.patch |
277 | |
278 | === added directory 'qt/core/api/internal' |
279 | === added file 'qt/core/api/internal/oxideqwebpreferences_p.cc' |
280 | --- qt/core/api/internal/oxideqwebpreferences_p.cc 1970-01-01 00:00:00 +0000 |
281 | +++ qt/core/api/internal/oxideqwebpreferences_p.cc 2014-02-07 16:51:32 +0000 |
282 | @@ -0,0 +1,53 @@ |
283 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
284 | +// Copyright (C) 2013 Canonical Ltd. |
285 | + |
286 | +// This library is free software; you can redistribute it and/or |
287 | +// modify it under the terms of the GNU Lesser General Public |
288 | +// License as published by the Free Software Foundation; either |
289 | +// version 2.1 of the License, or (at your option) any later version. |
290 | + |
291 | +// This library is distributed in the hope that it will be useful, |
292 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
293 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
294 | +// Lesser General Public License for more details. |
295 | + |
296 | +// You should have received a copy of the GNU Lesser General Public |
297 | +// License along with this library; if not, write to the Free Software |
298 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
299 | + |
300 | +#include "../oxideqwebpreferences_p.h" |
301 | +#include "../oxideqwebpreferences.h" |
302 | + |
303 | +#include "qt/core/glue/oxide_qt_web_view_adapter.h" |
304 | + |
305 | +OxideQWebPreferencesPrivate::OxideQWebPreferencesPrivate() : |
306 | + in_destructor_(false) {} |
307 | + |
308 | +OxideQWebPreferencesPrivate::~OxideQWebPreferencesPrivate() { |
309 | + in_destructor_ = true; |
310 | + |
311 | + for (std::set<oxide::qt::WebViewAdapter *>::const_iterator it = views_.begin(); |
312 | + it != views_.end(); ++it) { |
313 | + oxide::qt::WebViewAdapter* view = *it; |
314 | + view->NotifyWebPreferencesDestroyed(); |
315 | + } |
316 | +} |
317 | + |
318 | +void OxideQWebPreferencesPrivate::AddWebView(oxide::qt::WebViewAdapter* view) { |
319 | + Q_ASSERT(!in_destructor_); |
320 | + views_.insert(view); |
321 | +} |
322 | + |
323 | +void OxideQWebPreferencesPrivate::RemoveWebView( |
324 | + oxide::qt::WebViewAdapter* view) { |
325 | + if (in_destructor_) { |
326 | + return; |
327 | + } |
328 | + |
329 | + views_.erase(view); |
330 | +} |
331 | + |
332 | +// static |
333 | +OxideQWebPreferencesPrivate* OxideQWebPreferencesPrivate::get(OxideQWebPreferences* q) { |
334 | + return q->d_func(); |
335 | +} |
336 | |
337 | === added file 'qt/core/api/oxideqwebpreferences.cc' |
338 | --- qt/core/api/oxideqwebpreferences.cc 1970-01-01 00:00:00 +0000 |
339 | +++ qt/core/api/oxideqwebpreferences.cc 2014-02-07 16:51:32 +0000 |
340 | @@ -0,0 +1,197 @@ |
341 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
342 | +// Copyright (C) 2013 Canonical Ltd. |
343 | + |
344 | +// This library is free software; you can redistribute it and/or |
345 | +// modify it under the terms of the GNU Lesser General Public |
346 | +// License as published by the Free Software Foundation; either |
347 | +// version 2.1 of the License, or (at your option) any later version. |
348 | + |
349 | +// This library is distributed in the hope that it will be useful, |
350 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
351 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
352 | +// Lesser General Public License for more details. |
353 | + |
354 | +// You should have received a copy of the GNU Lesser General Public |
355 | +// License along with this library; if not, write to the Free Software |
356 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
357 | + |
358 | +#include "oxideqwebpreferences.h" |
359 | +#include "oxideqwebpreferences_p.h" |
360 | + |
361 | +OxideQWebPreferences::~OxideQWebPreferences() {} |
362 | + |
363 | +OxideQWebPreferences::OxideQWebPreferences(QObject* parent) : |
364 | + QObject(parent), |
365 | + d_ptr(new OxideQWebPreferencesPrivate()) {} |
366 | + |
367 | +QString OxideQWebPreferences::standardFontFamily() const { |
368 | + Q_D(const OxideQWebPreferences); |
369 | + return QString::fromStdString(d->preferences().StandardFontFamily()); |
370 | +} |
371 | + |
372 | +void OxideQWebPreferences::setStandardFontFamily(const QString& font) { |
373 | + Q_D(OxideQWebPreferences); |
374 | + |
375 | + if (font == standardFontFamily()) { |
376 | + return; |
377 | + } |
378 | + |
379 | + d->preferences().SetStandardFontFamily(font.toStdString()); |
380 | + Q_EMIT standardFontFamilyChanged(); |
381 | +} |
382 | + |
383 | +QString OxideQWebPreferences::fixedFontFamily() const { |
384 | + Q_D(const OxideQWebPreferences); |
385 | + return QString::fromStdString(d->preferences().FixedFontFamily()); |
386 | +} |
387 | + |
388 | +void OxideQWebPreferences::setFixedFontFamily(const QString& font) { |
389 | + Q_D(OxideQWebPreferences); |
390 | + |
391 | + if (font == fixedFontFamily()) { |
392 | + return; |
393 | + } |
394 | + |
395 | + d->preferences().SetFixedFontFamily(font.toStdString()); |
396 | + Q_EMIT fixedFontFamilyChanged(); |
397 | +} |
398 | + |
399 | +QString OxideQWebPreferences::serifFontFamily() const { |
400 | + Q_D(const OxideQWebPreferences); |
401 | + return QString::fromStdString(d->preferences().SerifFontFamily()); |
402 | +} |
403 | + |
404 | +void OxideQWebPreferences::setSerifFontFamily(const QString& font) { |
405 | + Q_D(OxideQWebPreferences); |
406 | + |
407 | + if (font == serifFontFamily()) { |
408 | + return; |
409 | + } |
410 | + |
411 | + d->preferences().SetSerifFontFamily(font.toStdString()); |
412 | + Q_EMIT serifFontFamilyChanged(); |
413 | +} |
414 | + |
415 | +QString OxideQWebPreferences::sansSerifFontFamily() const { |
416 | + Q_D(const OxideQWebPreferences); |
417 | + return QString::fromStdString(d->preferences().SansSerifFontFamily()); |
418 | +} |
419 | + |
420 | +void OxideQWebPreferences::setSansSerifFontFamily(const QString& font) { |
421 | + Q_D(OxideQWebPreferences); |
422 | + |
423 | + if (font == sansSerifFontFamily()) { |
424 | + return; |
425 | + } |
426 | + |
427 | + d->preferences().SetSansSerifFontFamily(font.toStdString()); |
428 | + Q_EMIT sansSerifFontFamilyChanged(); |
429 | +} |
430 | + |
431 | +QString OxideQWebPreferences::defaultEncoding() const { |
432 | + Q_D(const OxideQWebPreferences); |
433 | + return QString::fromStdString(d->preferences().default_encoding()); |
434 | +} |
435 | + |
436 | +void OxideQWebPreferences::setDefaultEncoding(const QString& encoding) { |
437 | + Q_D(OxideQWebPreferences); |
438 | + |
439 | + if (encoding == defaultEncoding()) { |
440 | + return; |
441 | + } |
442 | + |
443 | + d->preferences().SetDefaultEncoding(encoding.toStdString()); |
444 | + Q_EMIT defaultEncodingChanged(); |
445 | +} |
446 | + |
447 | +unsigned OxideQWebPreferences::defaultFontSize() const { |
448 | + Q_D(const OxideQWebPreferences); |
449 | + return d->preferences().default_font_size(); |
450 | +} |
451 | + |
452 | +void OxideQWebPreferences::setDefaultFontSize(unsigned size) { |
453 | + Q_D(OxideQWebPreferences); |
454 | + |
455 | + if (size == defaultFontSize()) { |
456 | + return; |
457 | + } |
458 | + |
459 | + d->preferences().SetDefaultFontSize(size); |
460 | + Q_EMIT defaultFontSizeChanged(); |
461 | +} |
462 | + |
463 | +unsigned OxideQWebPreferences::defaultFixedFontSize() const { |
464 | + Q_D(const OxideQWebPreferences); |
465 | + return d->preferences().default_fixed_font_size(); |
466 | +} |
467 | + |
468 | +void OxideQWebPreferences::setDefaultFixedFontSize(unsigned size) { |
469 | + Q_D(OxideQWebPreferences); |
470 | + |
471 | + if (size == defaultFixedFontSize()) { |
472 | + return; |
473 | + } |
474 | + |
475 | + d->preferences().SetDefaultFixedFontSize(size); |
476 | + Q_EMIT defaultFixedFontSizeChanged(); |
477 | +} |
478 | + |
479 | +unsigned OxideQWebPreferences::minimumFontSize() const { |
480 | + Q_D(const OxideQWebPreferences); |
481 | + return d->preferences().minimum_font_size(); |
482 | +} |
483 | + |
484 | +void OxideQWebPreferences::setMinimumFontSize(unsigned size) { |
485 | + Q_D(OxideQWebPreferences); |
486 | + |
487 | + if (size == minimumFontSize()) { |
488 | + return; |
489 | + } |
490 | + |
491 | + d->preferences().SetMinimumFontSize(size); |
492 | + Q_EMIT minimumFontSizeChanged(); |
493 | +} |
494 | + |
495 | +#define BOOLEAN_PREF_IMPL(getter, setter, attr) \ |
496 | + bool OxideQWebPreferences::getter() const { \ |
497 | + Q_D(const OxideQWebPreferences); \ |
498 | + return d->preferences().TestAttribute( \ |
499 | + oxide::WebPreferences::ATTR_##attr); \ |
500 | + } \ |
501 | +\ |
502 | + void OxideQWebPreferences::setter(bool val) { \ |
503 | + Q_D(OxideQWebPreferences); \ |
504 | + if (val == getter()) { \ |
505 | + return; \ |
506 | + } \ |
507 | + d->preferences().SetAttribute( \ |
508 | + oxide::WebPreferences::ATTR_##attr, val); \ |
509 | + Q_EMIT getter##Changed(); \ |
510 | + } |
511 | + |
512 | +BOOLEAN_PREF_IMPL(remoteFontsEnabled, setRemoteFontsEnabled, REMOTE_FONTS_ENABLED) |
513 | +BOOLEAN_PREF_IMPL(javascriptEnabled, setJavascriptEnabled, JAVASCRIPT_ENABLED) |
514 | +BOOLEAN_PREF_IMPL(webSecurityEnabled, setWebSecurityEnabled, WEB_SECURITY_ENABLED) |
515 | +BOOLEAN_PREF_IMPL(popupBlockerEnabled, setPopupBlockerEnabled, POPUP_BLOCKER_ENABLED) |
516 | +BOOLEAN_PREF_IMPL(allowScriptsToCloseWindows, setAllowScriptsToCloseWindows, ALLOW_SCRIPTS_TO_CLOSE_WINDOWS) |
517 | +BOOLEAN_PREF_IMPL(javascriptCanAccessClipboard, setJavascriptCanAccessClipboard, JAVASCRIPT_CAN_ACCESS_CLIPBOARD) |
518 | +BOOLEAN_PREF_IMPL(hyperlinkAuditingEnabled, setHyperlinkAuditingEnabled, HYPERLINK_AUDITING_ENABLED) |
519 | +BOOLEAN_PREF_IMPL(allowUniversalAccessFromFileUrls, setAllowUniversalAccessFromFileUrls, ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS) |
520 | +BOOLEAN_PREF_IMPL(allowFileAccessFromFileUrls, setAllowFileAccessFromFileUrls, ALLOW_FILE_ACCESS_FROM_FILE_URLS) |
521 | +BOOLEAN_PREF_IMPL(canDisplayInsecureContent, setCanDisplayInsecureContent, CAN_DISPLAY_INSECURE_CONTENT) |
522 | +BOOLEAN_PREF_IMPL(canRunInsecureContent, setCanRunInsecureContent, CAN_RUN_INSECURE_CONTENT) |
523 | +BOOLEAN_PREF_IMPL(passwordEchoEnabled, setPasswordEchoEnabled, PASSWORD_ECHO_ENABLED) |
524 | +BOOLEAN_PREF_IMPL(loadsImagesAutomatically, setLoadsImagesAutomatically, LOADS_IMAGES_AUTOMATICALLY) |
525 | +BOOLEAN_PREF_IMPL(shrinksStandaloneImagesToFit, setShrinksStandaloneImagesToFit, SHRINKS_STANDALONE_IMAGES_TO_FIT) |
526 | +BOOLEAN_PREF_IMPL(textAreasAreResizable, setTextAreasAreResizable, TEXT_AREAS_ARE_RESIZABLE) |
527 | +BOOLEAN_PREF_IMPL(localStorageEnabled, setLocalStorageEnabled, LOCAL_STORAGE_ENABLED) |
528 | +BOOLEAN_PREF_IMPL(databasesEnabled, setDatabasesEnabled, DATABASES_ENABLED) |
529 | +BOOLEAN_PREF_IMPL(appCacheEnabled, setAppCacheEnabled, APP_CACHE_ENABLED) |
530 | +BOOLEAN_PREF_IMPL(fullscreenEnabled, setFullscreenEnabled, FULLSCREEN_ENABLED) |
531 | +BOOLEAN_PREF_IMPL(tabsToLinks, setTabsToLinks, TABS_TO_LINKS) |
532 | +BOOLEAN_PREF_IMPL(caretBrowsingEnabled, setCaretBrowsingEnabled, CARET_BROWSING_ENABLED) |
533 | +BOOLEAN_PREF_IMPL(acceleratedCompositingEnabled, setAcceleratedCompositingEnabled, ACCELERATED_COMPOSITING_ENABLED) |
534 | +BOOLEAN_PREF_IMPL(smoothScrollingEnabled, setSmoothScrollingEnabled, SMOOTH_SCROLLING_ENABLED) |
535 | +BOOLEAN_PREF_IMPL(touchEnabled, setTouchEnabled, TOUCH_ENABLED) |
536 | +BOOLEAN_PREF_IMPL(supportsMultipleWindows, setSupportsMultipleWindows, SUPPORTS_MULTIPLE_WINDOWS) |
537 | +BOOLEAN_PREF_IMPL(viewportEnabled, setViewportEnabled, VIEWPORT_ENABLED) |
538 | |
539 | === added file 'qt/core/api/oxideqwebpreferences.h' |
540 | --- qt/core/api/oxideqwebpreferences.h 1970-01-01 00:00:00 +0000 |
541 | +++ qt/core/api/oxideqwebpreferences.h 2014-02-07 16:51:32 +0000 |
542 | @@ -0,0 +1,212 @@ |
543 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
544 | +// Copyright (C) 2013 Canonical Ltd. |
545 | + |
546 | +// This library is free software; you can redistribute it and/or |
547 | +// modify it under the terms of the GNU Lesser General Public |
548 | +// License as published by the Free Software Foundation; either |
549 | +// version 2.1 of the License, or (at your option) any later version. |
550 | + |
551 | +// This library is distributed in the hope that it will be useful, |
552 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
553 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
554 | +// Lesser General Public License for more details. |
555 | + |
556 | +// You should have received a copy of the GNU Lesser General Public |
557 | +// License along with this library; if not, write to the Free Software |
558 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
559 | + |
560 | +#ifndef OXIDE_Q_WEB_PREFERENCES |
561 | +#define OXIDE_Q_WEB_PREFERENCES |
562 | + |
563 | +#include <QObject> |
564 | +#include <QScopedPointer> |
565 | +#include <QString> |
566 | +#include <QtGlobal> |
567 | + |
568 | +class OxideQWebPreferencesPrivate; |
569 | + |
570 | +class Q_DECL_EXPORT OxideQWebPreferences : public QObject { |
571 | + Q_OBJECT |
572 | + |
573 | + Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily NOTIFY standardFontFamilyChanged) |
574 | + Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily NOTIFY fixedFontFamilyChanged) |
575 | + Q_PROPERTY(QString serifFontFamily READ serifFontFamily WRITE setSerifFontFamily NOTIFY serifFontFamilyChanged) |
576 | + Q_PROPERTY(QString sanSerifFontFamily READ sansSerifFontFamily WRITE setSansSerifFontFamily NOTIFY sansSerifFontFamilyChanged) |
577 | + |
578 | + Q_PROPERTY(bool remoteFontsEnabled READ remoteFontsEnabled WRITE setRemoteFontsEnabled NOTIFY remoteFontsEnabledChanged) |
579 | + |
580 | + Q_PROPERTY(QString defaultEncoding READ defaultEncoding WRITE setDefaultEncoding NOTIFY defaultEncodingChanged) |
581 | + |
582 | + Q_PROPERTY(unsigned defaultFontSize READ defaultFontSize WRITE setDefaultFontSize NOTIFY defaultFontSizeChanged) |
583 | + Q_PROPERTY(unsigned defaultFixedFontSize READ defaultFixedFontSize WRITE setDefaultFixedFontSize NOTIFY defaultFixedFontSizeChanged) |
584 | + Q_PROPERTY(unsigned minimumFontSize READ minimumFontSize WRITE setMinimumFontSize NOTIFY minimumFontSizeChanged) |
585 | + |
586 | + Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled NOTIFY javascriptEnabledChanged) |
587 | + Q_PROPERTY(bool webSecurityEnabled READ webSecurityEnabled WRITE setWebSecurityEnabled NOTIFY webSecurityEnabledChanged) |
588 | + Q_PROPERTY(bool popupBlockerEnabled READ popupBlockerEnabled WRITE setPopupBlockerEnabled NOTIFY popupBlockerEnabledChanged) |
589 | + Q_PROPERTY(bool allowScriptsToCloseWindows READ allowScriptsToCloseWindows WRITE setAllowScriptsToCloseWindows NOTIFY allowScriptsToCloseWindowsChanged) |
590 | + Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard NOTIFY javascriptCanAccessClipboardChanged) |
591 | + |
592 | + Q_PROPERTY(bool hyperlinkAuditingEnabled READ hyperlinkAuditingEnabled WRITE setHyperlinkAuditingEnabled NOTIFY hyperlinkAuditingEnabledChanged) |
593 | + Q_PROPERTY(bool allowUniversalAccessFromFileUrls READ allowUniversalAccessFromFileUrls WRITE setAllowUniversalAccessFromFileUrls NOTIFY allowUniversalAccessFromFileUrlsChanged) |
594 | + Q_PROPERTY(bool allowFileAccessFromFileUrls READ allowFileAccessFromFileUrls WRITE setAllowFileAccessFromFileUrls NOTIFY allowFileAccessFromFileUrlsChanged) |
595 | + Q_PROPERTY(bool canDisplayInsecureContent READ canDisplayInsecureContent WRITE setCanDisplayInsecureContent NOTIFY canDisplayInsecureContentChanged) |
596 | + Q_PROPERTY(bool canRunInsecureContent READ canRunInsecureContent WRITE setCanRunInsecureContent NOTIFY canRunInsecureContentChanged) |
597 | + Q_PROPERTY(bool passwordEchoEnabled READ passwordEchoEnabled WRITE setPasswordEchoEnabled NOTIFY passwordEchoEnabledChanged) |
598 | + |
599 | + Q_PROPERTY(bool loadsImagesAutomatically READ loadsImagesAutomatically WRITE setLoadsImagesAutomatically NOTIFY loadsImagesAutomaticallyChanged) |
600 | + Q_PROPERTY(bool shrinksStandaloneImagesToFit READ shrinksStandaloneImagesToFit WRITE setShrinksStandaloneImagesToFit NOTIFY shrinksStandaloneImagesToFitChanged) |
601 | + |
602 | + Q_PROPERTY(bool textAreasAreResizable READ textAreasAreResizable WRITE setTextAreasAreResizable NOTIFY textAreasAreResizableChanged) |
603 | + |
604 | + Q_PROPERTY(bool localStorageEnabled READ localStorageEnabled WRITE setLocalStorageEnabled NOTIFY localStorageEnabledChanged) |
605 | + Q_PROPERTY(bool databasesEnabled READ databasesEnabled WRITE setDatabasesEnabled NOTIFY databasesEnabledChanged) |
606 | + Q_PROPERTY(bool appCacheEnabled READ appCacheEnabled WRITE setAppCacheEnabled NOTIFY appCacheEnabledChanged) |
607 | + Q_PROPERTY(bool fullscreenEnabled READ fullscreenEnabled WRITE setFullscreenEnabled NOTIFY fullscreenEnabledChanged) |
608 | + |
609 | + Q_PROPERTY(bool tabsToLinks READ tabsToLinks WRITE setTabsToLinks NOTIFY tabsToLinksChanged) |
610 | + Q_PROPERTY(bool caretBrowsingEnabled READ caretBrowsingEnabled WRITE setCaretBrowsingEnabled NOTIFY caretBrowsingEnabledChanged) |
611 | + |
612 | + Q_PROPERTY(bool acceleratedCompositingEnabled READ acceleratedCompositingEnabled WRITE setAcceleratedCompositingEnabled NOTIFY acceleratedCompositingEnabledChanged) |
613 | + Q_PROPERTY(bool smoothScrollingEnabled READ smoothScrollingEnabled WRITE setSmoothScrollingEnabled NOTIFY smoothScrollingEnabledChanged) |
614 | + Q_PROPERTY(bool touchEnabled READ touchEnabled WRITE setTouchEnabled NOTIFY touchEnabledChanged) |
615 | + Q_PROPERTY(bool supportsMultipleWindows READ supportsMultipleWindows WRITE setSupportsMultipleWindows NOTIFY supportsMultipleWindowsChanged) |
616 | + Q_PROPERTY(bool viewportEnabled READ viewportEnabled WRITE setViewportEnabled NOTIFY viewportEnabledChanged) |
617 | + |
618 | + Q_DECLARE_PRIVATE(OxideQWebPreferences) |
619 | + Q_DISABLE_COPY(OxideQWebPreferences) |
620 | + |
621 | + public: |
622 | + virtual ~OxideQWebPreferences(); |
623 | + OxideQWebPreferences(QObject* parent = NULL); |
624 | + |
625 | + QString standardFontFamily() const; |
626 | + void setStandardFontFamily(const QString& font); |
627 | + QString fixedFontFamily() const; |
628 | + void setFixedFontFamily(const QString& font); |
629 | + QString serifFontFamily() const; |
630 | + void setSerifFontFamily(const QString& font); |
631 | + QString sansSerifFontFamily() const; |
632 | + void setSansSerifFontFamily(const QString& font); |
633 | + |
634 | + bool remoteFontsEnabled() const; |
635 | + void setRemoteFontsEnabled(bool enabled); |
636 | + |
637 | + QString defaultEncoding() const; |
638 | + void setDefaultEncoding(const QString& encoding); |
639 | + |
640 | + unsigned defaultFontSize() const; |
641 | + void setDefaultFontSize(unsigned size); |
642 | + unsigned defaultFixedFontSize() const; |
643 | + void setDefaultFixedFontSize(unsigned size); |
644 | + unsigned minimumFontSize() const; |
645 | + void setMinimumFontSize(unsigned size); |
646 | + |
647 | + bool javascriptEnabled() const; |
648 | + void setJavascriptEnabled(bool enabled); |
649 | + bool webSecurityEnabled() const; |
650 | + void setWebSecurityEnabled(bool enabled); |
651 | + bool popupBlockerEnabled() const; |
652 | + void setPopupBlockerEnabled(bool enabled); |
653 | + bool allowScriptsToCloseWindows() const; |
654 | + void setAllowScriptsToCloseWindows(bool allow); |
655 | + bool javascriptCanAccessClipboard() const; |
656 | + void setJavascriptCanAccessClipboard(bool allow); |
657 | + |
658 | + bool hyperlinkAuditingEnabled() const; |
659 | + void setHyperlinkAuditingEnabled(bool enabled); |
660 | + bool allowUniversalAccessFromFileUrls() const; |
661 | + void setAllowUniversalAccessFromFileUrls(bool allow); |
662 | + bool allowFileAccessFromFileUrls() const; |
663 | + void setAllowFileAccessFromFileUrls(bool allow); |
664 | + bool canDisplayInsecureContent() const; |
665 | + void setCanDisplayInsecureContent(bool allow); |
666 | + bool canRunInsecureContent() const; |
667 | + void setCanRunInsecureContent(bool allow); |
668 | + bool passwordEchoEnabled() const; |
669 | + void setPasswordEchoEnabled(bool enabled); |
670 | + |
671 | + bool loadsImagesAutomatically() const; |
672 | + void setLoadsImagesAutomatically(bool enabled); |
673 | + bool shrinksStandaloneImagesToFit() const; |
674 | + void setShrinksStandaloneImagesToFit(bool enabled); |
675 | + |
676 | + bool textAreasAreResizable() const; |
677 | + void setTextAreasAreResizable(bool enabled); |
678 | + |
679 | + bool localStorageEnabled() const; |
680 | + void setLocalStorageEnabled(bool enabled); |
681 | + bool databasesEnabled() const; |
682 | + void setDatabasesEnabled(bool enabled); |
683 | + bool appCacheEnabled() const; |
684 | + void setAppCacheEnabled(bool enabled); |
685 | + bool fullscreenEnabled() const; |
686 | + void setFullscreenEnabled(bool enabled); |
687 | + |
688 | + bool tabsToLinks() const; |
689 | + void setTabsToLinks(bool enabled); |
690 | + bool caretBrowsingEnabled() const; |
691 | + void setCaretBrowsingEnabled(bool enabled); |
692 | + |
693 | + bool acceleratedCompositingEnabled() const; |
694 | + void setAcceleratedCompositingEnabled(bool enabled); |
695 | + bool smoothScrollingEnabled() const; |
696 | + void setSmoothScrollingEnabled(bool enabled); |
697 | + bool touchEnabled() const; |
698 | + void setTouchEnabled(bool enabled); |
699 | + bool supportsMultipleWindows() const; |
700 | + void setSupportsMultipleWindows(bool enabled); |
701 | + bool viewportEnabled() const; |
702 | + void setViewportEnabled(bool enabled); |
703 | + |
704 | + Q_SIGNALS: |
705 | + void standardFontFamilyChanged(); |
706 | + void fixedFontFamilyChanged(); |
707 | + void serifFontFamilyChanged(); |
708 | + void sansSerifFontFamilyChanged(); |
709 | + |
710 | + void remoteFontsEnabledChanged(); |
711 | + |
712 | + void defaultEncodingChanged(); |
713 | + |
714 | + void defaultFontSizeChanged(); |
715 | + void defaultFixedFontSizeChanged(); |
716 | + void minimumFontSizeChanged(); |
717 | + |
718 | + void javascriptEnabledChanged(); |
719 | + void webSecurityEnabledChanged(); |
720 | + void popupBlockerEnabledChanged(); |
721 | + void allowScriptsToCloseWindowsChanged(); |
722 | + void javascriptCanAccessClipboardChanged(); |
723 | + |
724 | + void hyperlinkAuditingEnabledChanged(); |
725 | + void allowUniversalAccessFromFileUrlsChanged(); |
726 | + void allowFileAccessFromFileUrlsChanged(); |
727 | + void canDisplayInsecureContentChanged(); |
728 | + void canRunInsecureContentChanged(); |
729 | + void passwordEchoEnabledChanged(); |
730 | + |
731 | + void loadsImagesAutomaticallyChanged(); |
732 | + void shrinksStandaloneImagesToFitChanged(); |
733 | + |
734 | + void textAreasAreResizableChanged(); |
735 | + |
736 | + void localStorageEnabledChanged(); |
737 | + void databasesEnabledChanged(); |
738 | + void appCacheEnabledChanged(); |
739 | + void fullscreenEnabledChanged(); |
740 | + |
741 | + void tabsToLinksChanged(); |
742 | + void caretBrowsingEnabledChanged(); |
743 | + |
744 | + void acceleratedCompositingEnabledChanged(); |
745 | + void smoothScrollingEnabledChanged(); |
746 | + void touchEnabledChanged(); |
747 | + void supportsMultipleWindowsChanged(); |
748 | + void viewportEnabledChanged(); |
749 | + |
750 | + private: |
751 | + QScopedPointer<OxideQWebPreferencesPrivate> d_ptr; |
752 | +}; |
753 | + |
754 | +#endif // OXIDE_Q_WEB_PREFERENCES |
755 | |
756 | === added file 'qt/core/api/oxideqwebpreferences_p.h' |
757 | --- qt/core/api/oxideqwebpreferences_p.h 1970-01-01 00:00:00 +0000 |
758 | +++ qt/core/api/oxideqwebpreferences_p.h 2014-02-07 16:51:32 +0000 |
759 | @@ -0,0 +1,59 @@ |
760 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
761 | +// Copyright (C) 2013 Canonical Ltd. |
762 | + |
763 | +// This library is free software; you can redistribute it and/or |
764 | +// modify it under the terms of the GNU Lesser General Public |
765 | +// License as published by the Free Software Foundation; either |
766 | +// version 2.1 of the License, or (at your option) any later version. |
767 | + |
768 | +// This library is distributed in the hope that it will be useful, |
769 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
770 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
771 | +// Lesser General Public License for more details. |
772 | + |
773 | +// You should have received a copy of the GNU Lesser General Public |
774 | +// License along with this library; if not, write to the Free Software |
775 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
776 | + |
777 | +#ifndef _OXIDE_QT_CORE_API_WEB_PREFERENCES_P_H_ |
778 | +#define _OXIDE_QT_CORE_API_WEB_PREFERENCES_P_H_ |
779 | + |
780 | +#include <set> |
781 | +#include <QtGlobal> |
782 | + |
783 | +#include "qt/core/browser/oxide_qt_web_preferences.h" |
784 | + |
785 | +class OxideQWebPreferences; |
786 | + |
787 | +namespace oxide { |
788 | +namespace qt { |
789 | +class WebViewAdapter; |
790 | +} // namespace qt |
791 | +} // namespace oxide |
792 | + |
793 | +class OxideQWebPreferencesPrivate Q_DECL_FINAL { |
794 | + public: |
795 | + OxideQWebPreferencesPrivate(); |
796 | + ~OxideQWebPreferencesPrivate(); |
797 | + |
798 | + oxide::qt::WebPreferences& preferences() { |
799 | + return preferences_; |
800 | + } |
801 | + const oxide::qt::WebPreferences& preferences() const { |
802 | + return preferences_; |
803 | + } |
804 | + |
805 | + bool in_destructor() const { return in_destructor_; } |
806 | + |
807 | + void AddWebView(oxide::qt::WebViewAdapter* view); |
808 | + void RemoveWebView(oxide::qt::WebViewAdapter* view); |
809 | + |
810 | + static OxideQWebPreferencesPrivate* get(OxideQWebPreferences* q); |
811 | + |
812 | + private: |
813 | + oxide::qt::WebPreferences preferences_; |
814 | + std::set<oxide::qt::WebViewAdapter *> views_; |
815 | + bool in_destructor_; |
816 | +}; |
817 | + |
818 | +#endif // _OXIDE_QT_CORE_API_WEB_PREFERENCES_P_H_ |
819 | |
820 | === modified file 'qt/core/browser/oxide_qt_content_browser_client.cc' |
821 | --- qt/core/browser/oxide_qt_content_browser_client.cc 2014-02-03 13:41:53 +0000 |
822 | +++ qt/core/browser/oxide_qt_content_browser_client.cc 2014-02-07 16:51:32 +0000 |
823 | @@ -21,6 +21,7 @@ |
824 | #include <QString> |
825 | #include <QtGui/qpa/qplatformnativeinterface.h> |
826 | |
827 | +#include "base/lazy_instance.h" |
828 | #include "base/logging.h" |
829 | |
830 | #include "shared/gl/oxide_shared_gl_context.h" |
831 | @@ -29,12 +30,16 @@ |
832 | |
833 | #include "oxide_qt_message_pump.h" |
834 | #include "oxide_qt_render_widget_host_view.h" |
835 | +#include "oxide_qt_web_preferences.h" |
836 | |
837 | namespace oxide { |
838 | namespace qt { |
839 | |
840 | namespace { |
841 | |
842 | +base::LazyInstance<WebPreferences> g_default_web_preferences = |
843 | + LAZY_INSTANCE_INITIALIZER; |
844 | + |
845 | class SharedGLContext : public oxide::SharedGLContext { |
846 | public: |
847 | SharedGLContext(QOpenGLContext* context, oxide::GLShareGroup* share_group) : |
848 | @@ -120,5 +125,9 @@ |
849 | QGuiApplication::primaryScreen(), result); |
850 | } |
851 | |
852 | +oxide::WebPreferences* ContentBrowserClient::GetDefaultWebPreferences() { |
853 | + return g_default_web_preferences.Pointer(); |
854 | +} |
855 | + |
856 | } // namespace qt |
857 | } // namespace oxide |
858 | |
859 | === modified file 'qt/core/browser/oxide_qt_content_browser_client.h' |
860 | --- qt/core/browser/oxide_qt_content_browser_client.h 2014-01-13 22:06:04 +0000 |
861 | +++ qt/core/browser/oxide_qt_content_browser_client.h 2014-02-07 16:51:32 +0000 |
862 | @@ -42,6 +42,8 @@ |
863 | |
864 | void GetDefaultScreenInfo(blink::WebScreenInfo* result) FINAL; |
865 | |
866 | + oxide::WebPreferences* GetDefaultWebPreferences() FINAL; |
867 | + |
868 | private: |
869 | // Limit default constructor access to the lazy instance initializer |
870 | friend struct base::DefaultLazyInstanceTraits<ContentBrowserClient>; |
871 | |
872 | === modified file 'qt/core/browser/oxide_qt_web_frame.cc' |
873 | --- qt/core/browser/oxide_qt_web_frame.cc 2013-10-29 01:06:23 +0000 |
874 | +++ qt/core/browser/oxide_qt_web_frame.cc 2014-02-07 16:51:32 +0000 |
875 | @@ -22,55 +22,57 @@ |
876 | #include "base/logging.h" |
877 | |
878 | #include "qt/core/glue/oxide_qt_web_frame_adapter.h" |
879 | +#include "qt/core/glue/oxide_qt_web_frame_adapter_p.h" |
880 | #include "qt/core/glue/private/oxide_qt_message_handler_adapter_p.h" |
881 | #include "qt/core/glue/private/oxide_qt_outgoing_message_request_adapter_p.h" |
882 | -#include "qt/core/glue/private/oxide_qt_web_frame_adapter_p.h" |
883 | |
884 | namespace oxide { |
885 | namespace qt { |
886 | |
887 | WebFrame::~WebFrame() { |
888 | - delete adapterToQObject(adapter); |
889 | - DCHECK(!adapter); |
890 | + delete adapterToQObject(adapter_); |
891 | } |
892 | |
893 | void WebFrame::OnChildAdded(oxide::WebFrame* child) { |
894 | - adapterToQObject(static_cast<WebFrame *>(child)->adapter)->setParent( |
895 | - adapterToQObject(adapter)); |
896 | + adapterToQObject(static_cast<WebFrame *>(child)->adapter())->setParent( |
897 | + adapterToQObject(adapter_)); |
898 | } |
899 | |
900 | void WebFrame::OnChildRemoved(oxide::WebFrame* child) { |
901 | - adapterToQObject(static_cast<WebFrame *>(child)->adapter)->setParent(NULL); |
902 | + adapterToQObject(static_cast<WebFrame *>(child)->adapter())->setParent(NULL); |
903 | } |
904 | |
905 | void WebFrame::OnURLChanged() { |
906 | - adapter->URLChanged(); |
907 | + adapter_->URLChanged(); |
908 | } |
909 | |
910 | -WebFrame::WebFrame(WebFrameAdapter* adapter) : |
911 | - adapter(adapter) { |
912 | +WebFrame::WebFrame(WebFrameAdapter* adapter, |
913 | + content::FrameTreeNode* node, |
914 | + oxide::WebView* view) : |
915 | + oxide::WebFrame(node, view), |
916 | + adapter_(adapter) { |
917 | WebFrameAdapterPrivate::get(adapter)->owner = this; |
918 | } |
919 | |
920 | size_t WebFrame::GetMessageHandlerCount() const { |
921 | - return adapter->message_handlers().size(); |
922 | + return adapter_->message_handlers().size(); |
923 | } |
924 | |
925 | oxide::MessageHandler* WebFrame::GetMessageHandlerAt( |
926 | size_t index) const { |
927 | - MessageHandlerAdapter* handler = adapter->message_handlers().at(index); |
928 | + MessageHandlerAdapter* handler = adapter_->message_handlers().at(index); |
929 | return &MessageHandlerAdapterPrivate::get(handler)->handler(); |
930 | } |
931 | |
932 | size_t WebFrame::GetOutgoingMessageRequestCount() const { |
933 | return WebFrameAdapterPrivate::get( |
934 | - adapter)->outgoing_message_requests().size(); |
935 | + adapter_)->outgoing_message_requests().size(); |
936 | } |
937 | |
938 | oxide::OutgoingMessageRequest* WebFrame::GetOutgoingMessageRequestAt( |
939 | size_t index) const { |
940 | OutgoingMessageRequestAdapter* req = |
941 | - WebFrameAdapterPrivate::get(adapter)->outgoing_message_requests().at(index); |
942 | + WebFrameAdapterPrivate::get(adapter_)->outgoing_message_requests().at(index); |
943 | return &OutgoingMessageRequestAdapterPrivate::get(req)->request(); |
944 | } |
945 | |
946 | |
947 | === modified file 'qt/core/browser/oxide_qt_web_frame.h' |
948 | --- qt/core/browser/oxide_qt_web_frame.h 2013-10-28 15:56:40 +0000 |
949 | +++ qt/core/browser/oxide_qt_web_frame.h 2014-02-07 16:51:32 +0000 |
950 | @@ -30,7 +30,9 @@ |
951 | |
952 | class WebFrame FINAL : public oxide::WebFrame { |
953 | public: |
954 | - WebFrame(WebFrameAdapter* adapter); |
955 | + WebFrame(WebFrameAdapter* adapter, |
956 | + content::FrameTreeNode* node, |
957 | + oxide::WebView* view); |
958 | |
959 | size_t GetMessageHandlerCount() const FINAL; |
960 | oxide::MessageHandler* GetMessageHandlerAt(size_t index) const FINAL; |
961 | @@ -39,7 +41,7 @@ |
962 | oxide::OutgoingMessageRequest* |
963 | GetOutgoingMessageRequestAt(size_t index) const FINAL; |
964 | |
965 | - WebFrameAdapter* adapter; |
966 | + WebFrameAdapter* adapter() const { return adapter_; } |
967 | |
968 | private: |
969 | ~WebFrame(); |
970 | @@ -48,6 +50,8 @@ |
971 | void OnChildRemoved(oxide::WebFrame* child) FINAL; |
972 | void OnURLChanged() FINAL; |
973 | |
974 | + WebFrameAdapter* adapter_; |
975 | + |
976 | DISALLOW_COPY_AND_ASSIGN(WebFrame); |
977 | }; |
978 | |
979 | |
980 | === added file 'qt/core/browser/oxide_qt_web_preferences.cc' |
981 | --- qt/core/browser/oxide_qt_web_preferences.cc 1970-01-01 00:00:00 +0000 |
982 | +++ qt/core/browser/oxide_qt_web_preferences.cc 2014-02-07 16:51:32 +0000 |
983 | @@ -0,0 +1,41 @@ |
984 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
985 | +// copyright (c) 2013 canonical ltd. |
986 | + |
987 | +// this library is free software; you can redistribute it and/or |
988 | +// modify it under the terms of the gnu lesser general public |
989 | +// license as published by the free software foundation; either |
990 | +// version 2.1 of the license, or (at your option) any later version. |
991 | + |
992 | +// this library is distributed in the hope that it will be useful, |
993 | +// but without any warranty; without even the implied warranty of |
994 | +// merchantability or fitness for a particular purpose. see the gnu |
995 | +// lesser general public license for more details. |
996 | + |
997 | +// you should have received a copy of the gnu lesser general public |
998 | +// license along with this library; if not, write to the free software |
999 | +// foundation, inc., 51 franklin street, fifth floor, boston, ma 02110-1301 usa |
1000 | + |
1001 | +#include "oxide_qt_web_preferences.h" |
1002 | + |
1003 | +#include <QFont> |
1004 | +#include <QString> |
1005 | + |
1006 | +namespace oxide { |
1007 | +namespace qt { |
1008 | + |
1009 | +WebPreferences::WebPreferences() { |
1010 | + QFont font; |
1011 | + |
1012 | + font.setStyleHint(QFont::Serif); |
1013 | + SetStandardFontFamily(font.defaultFamily().toStdString()); |
1014 | + SetSerifFontFamily(font.defaultFamily().toStdString()); |
1015 | + |
1016 | + font.setStyleHint(QFont::SansSerif); |
1017 | + SetSansSerifFontFamily(font.defaultFamily().toStdString()); |
1018 | + |
1019 | + font.setStyleHint(QFont::Monospace); |
1020 | + SetFixedFontFamily(font.defaultFamily().toStdString()); |
1021 | +} |
1022 | + |
1023 | +} // namespace qt |
1024 | +} // namespace oxide |
1025 | |
1026 | === added file 'qt/core/browser/oxide_qt_web_preferences.h' |
1027 | --- qt/core/browser/oxide_qt_web_preferences.h 1970-01-01 00:00:00 +0000 |
1028 | +++ qt/core/browser/oxide_qt_web_preferences.h 2014-02-07 16:51:32 +0000 |
1029 | @@ -0,0 +1,34 @@ |
1030 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
1031 | +// copyright (c) 2013 canonical ltd. |
1032 | + |
1033 | +// this library is free software; you can redistribute it and/or |
1034 | +// modify it under the terms of the gnu lesser general public |
1035 | +// license as published by the free software foundation; either |
1036 | +// version 2.1 of the license, or (at your option) any later version. |
1037 | + |
1038 | +// this library is distributed in the hope that it will be useful, |
1039 | +// but without any warranty; without even the implied warranty of |
1040 | +// merchantability or fitness for a particular purpose. see the gnu |
1041 | +// lesser general public license for more details. |
1042 | + |
1043 | +// you should have received a copy of the gnu lesser general public |
1044 | +// license along with this library; if not, write to the free software |
1045 | +// foundation, inc., 51 franklin street, fifth floor, boston, ma 02110-1301 usa |
1046 | + |
1047 | +#ifndef _OXIDE_QT_CORE_BROWSER_WEB_PREFERENCES_H_ |
1048 | +#define _OXIDE_QT_CORE_BROWSER_WEB_PREFERENCES_H_ |
1049 | + |
1050 | +#include "shared/browser/oxide_web_preferences.h" |
1051 | + |
1052 | +namespace oxide { |
1053 | +namespace qt { |
1054 | + |
1055 | +class WebPreferences FINAL : public oxide::WebPreferences { |
1056 | + public: |
1057 | + WebPreferences(); |
1058 | +}; |
1059 | + |
1060 | +} // namespace qt |
1061 | +} // namespace oxide |
1062 | + |
1063 | +#endif // _OXIDE_QT_CORE_BROWSER_WEB_PREFERENCES_H_ |
1064 | |
1065 | === modified file 'qt/core/core.gyp' |
1066 | --- qt/core/core.gyp 2014-01-31 00:54:49 +0000 |
1067 | +++ qt/core/core.gyp 2014-02-07 16:51:32 +0000 |
1068 | @@ -50,6 +50,7 @@ |
1069 | ], |
1070 | 'sources': [ |
1071 | '<(INTERMEDIATE_DIR)/oxide_qt_web_popup_menu_qquick.moc', |
1072 | + 'api/internal/oxideqwebpreferences_p.cc', |
1073 | 'app/oxide_qt_content_main_delegate.cc', |
1074 | 'app/oxide_qt_content_main_delegate.h', |
1075 | 'browser/oxide_qt_backing_store.cc', |
1076 | @@ -64,6 +65,8 @@ |
1077 | 'browser/oxide_qt_web_frame.h', |
1078 | 'browser/oxide_qt_web_popup_menu.cc', |
1079 | 'browser/oxide_qt_web_popup_menu.h', |
1080 | + 'browser/oxide_qt_web_preferences.cc', |
1081 | + 'browser/oxide_qt_web_preferences.h', |
1082 | 'common/oxide_qt_content_client.cc', |
1083 | 'common/oxide_qt_content_client.h', |
1084 | 'glue/private/oxide_qt_message_handler_adapter_p.cc', |
1085 | @@ -74,8 +77,6 @@ |
1086 | 'glue/private/oxide_qt_user_script_adapter_p.h', |
1087 | 'glue/private/oxide_qt_web_context_adapter_p.cc', |
1088 | 'glue/private/oxide_qt_web_context_adapter_p.h', |
1089 | - 'glue/private/oxide_qt_web_frame_adapter_p.cc', |
1090 | - 'glue/private/oxide_qt_web_frame_adapter_p.h', |
1091 | 'glue/private/oxide_qt_web_view_adapter_p.cc', |
1092 | 'glue/private/oxide_qt_web_view_adapter_p.h' |
1093 | ], |
1094 | @@ -101,12 +102,16 @@ |
1095 | 'sources': [ |
1096 | '<(INTERMEDIATE_DIR)/moc_oxideqincomingmessage.cc', |
1097 | '<(INTERMEDIATE_DIR)/moc_oxideqloadevent.cc', |
1098 | + '<(INTERMEDIATE_DIR)/moc_oxideqwebpreferences.cc', |
1099 | 'api/oxideqincomingmessage.cc', |
1100 | 'api/oxideqincomingmessage.h', |
1101 | 'api/oxideqincomingmessage_p.h', |
1102 | 'api/oxideqloadevent.cc', |
1103 | 'api/oxideqloadevent.h', |
1104 | 'api/oxideqloadevent_p.h', |
1105 | + 'api/oxideqwebpreferences.cc', |
1106 | + 'api/oxideqwebpreferences.h', |
1107 | + 'api/oxideqwebpreferences_p.h', |
1108 | 'glue/oxide_qt_adapter_base.h', |
1109 | 'glue/oxide_qt_message_handler_adapter.cc', |
1110 | 'glue/oxide_qt_message_handler_adapter.h', |
1111 | @@ -120,6 +125,7 @@ |
1112 | 'glue/oxide_qt_web_context_adapter.h', |
1113 | 'glue/oxide_qt_web_frame_adapter.cc', |
1114 | 'glue/oxide_qt_web_frame_adapter.h', |
1115 | + 'glue/oxide_qt_web_frame_adapter_p.h', |
1116 | 'glue/oxide_qt_web_popup_menu_delegate.cc', |
1117 | 'glue/oxide_qt_web_popup_menu_delegate.h', |
1118 | 'glue/oxide_qt_web_view_adapter.cc', |
1119 | @@ -136,6 +142,11 @@ |
1120 | 'moc_input': 'api/oxideqloadevent.h', |
1121 | 'includes': [ 'moc.gypi' ] |
1122 | }, |
1123 | + { |
1124 | + 'action_name': 'moc_oxideqwebpreferences.cc', |
1125 | + 'moc_input': 'api/oxideqwebpreferences.h', |
1126 | + 'includes': [ 'moc.gypi' ] |
1127 | + }, |
1128 | ] |
1129 | } |
1130 | ] |
1131 | |
1132 | === modified file 'qt/core/glue/oxide_qt_web_frame_adapter.cc' |
1133 | --- qt/core/glue/oxide_qt_web_frame_adapter.cc 2013-10-29 01:06:23 +0000 |
1134 | +++ qt/core/glue/oxide_qt_web_frame_adapter.cc 2014-02-07 16:51:32 +0000 |
1135 | @@ -16,6 +16,7 @@ |
1136 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1137 | |
1138 | #include "oxide_qt_web_frame_adapter.h" |
1139 | +#include "oxide_qt_web_frame_adapter_p.h" |
1140 | |
1141 | #include <QJsonDocument> |
1142 | #include <QString> |
1143 | @@ -25,13 +26,40 @@ |
1144 | |
1145 | #include "qt/core/browser/oxide_qt_web_frame.h" |
1146 | #include "qt/core/glue/private/oxide_qt_outgoing_message_request_adapter_p.h" |
1147 | -#include "qt/core/glue/private/oxide_qt_web_frame_adapter_p.h" |
1148 | |
1149 | namespace oxide { |
1150 | namespace qt { |
1151 | |
1152 | +WebFrameAdapterPrivate::WebFrameAdapterPrivate() : |
1153 | + owner(NULL) {} |
1154 | + |
1155 | +WebFrameAdapterPrivate::~WebFrameAdapterPrivate() { |
1156 | + while (!outgoing_message_requests_.isEmpty()) { |
1157 | + RemoveOutgoingMessageRequest(outgoing_message_requests_.first()); |
1158 | + } |
1159 | +} |
1160 | + |
1161 | +void WebFrameAdapterPrivate::AddOutgoingMessageRequest( |
1162 | + OutgoingMessageRequestAdapter* request) { |
1163 | + DCHECK(!outgoing_message_requests_.contains(request)); |
1164 | + |
1165 | + OutgoingMessageRequestAdapterPrivate::get(request)->frame = this; |
1166 | + outgoing_message_requests_.append(request); |
1167 | +} |
1168 | + |
1169 | +void WebFrameAdapterPrivate::RemoveOutgoingMessageRequest( |
1170 | + OutgoingMessageRequestAdapter* request) { |
1171 | + outgoing_message_requests_.removeOne(request); |
1172 | + OutgoingMessageRequestAdapterPrivate::get(request)->frame = NULL; |
1173 | +} |
1174 | + |
1175 | +// static |
1176 | +WebFrameAdapterPrivate* WebFrameAdapterPrivate::get(WebFrameAdapter* adapter) { |
1177 | + return adapter->priv.data(); |
1178 | +} |
1179 | + |
1180 | WebFrameAdapter::WebFrameAdapter() : |
1181 | - priv(WebFrameAdapterPrivate::Create()) {} |
1182 | + priv(new WebFrameAdapterPrivate()) {} |
1183 | |
1184 | WebFrameAdapter::~WebFrameAdapter() {} |
1185 | |
1186 | |
1187 | === renamed file 'qt/core/glue/private/oxide_qt_web_frame_adapter_p.h' => 'qt/core/glue/oxide_qt_web_frame_adapter_p.h' |
1188 | --- qt/core/glue/private/oxide_qt_web_frame_adapter_p.h 2013-10-29 01:06:23 +0000 |
1189 | +++ qt/core/glue/oxide_qt_web_frame_adapter_p.h 2014-02-07 16:51:32 +0000 |
1190 | @@ -32,7 +32,7 @@ |
1191 | |
1192 | class WebFrameAdapterPrivate FINAL { |
1193 | public: |
1194 | - static WebFrameAdapterPrivate* Create(); |
1195 | + WebFrameAdapterPrivate(); |
1196 | ~WebFrameAdapterPrivate(); |
1197 | |
1198 | const QList<OutgoingMessageRequestAdapter *>& outgoing_message_requests() const { |
1199 | @@ -47,8 +47,6 @@ |
1200 | WebFrame* owner; |
1201 | |
1202 | private: |
1203 | - WebFrameAdapterPrivate(); |
1204 | - |
1205 | QList<OutgoingMessageRequestAdapter *> outgoing_message_requests_; |
1206 | |
1207 | DISALLOW_COPY_AND_ASSIGN(WebFrameAdapterPrivate); |
1208 | |
1209 | === modified file 'qt/core/glue/oxide_qt_web_view_adapter.cc' |
1210 | --- qt/core/glue/oxide_qt_web_view_adapter.cc 2013-12-17 19:21:18 +0000 |
1211 | +++ qt/core/glue/oxide_qt_web_view_adapter.cc 2014-02-07 16:51:32 +0000 |
1212 | @@ -20,6 +20,8 @@ |
1213 | #include "ui/gfx/size.h" |
1214 | #include "url/gurl.h" |
1215 | |
1216 | +#include "qt/core/api/oxideqwebpreferences.h" |
1217 | +#include "qt/core/api/oxideqwebpreferences_p.h" |
1218 | #include "qt/core/browser/oxide_qt_web_frame.h" |
1219 | #include "qt/core/glue/private/oxide_qt_web_context_adapter_p.h" |
1220 | #include "qt/core/glue/private/oxide_qt_web_view_adapter_p.h" |
1221 | @@ -30,9 +32,14 @@ |
1222 | namespace qt { |
1223 | |
1224 | WebViewAdapter::WebViewAdapter() : |
1225 | - priv(WebViewAdapterPrivate::Create(this)) {} |
1226 | + priv(WebViewAdapterPrivate::Create(this)), |
1227 | + preferences_(NULL) {} |
1228 | |
1229 | -WebViewAdapter::~WebViewAdapter() {} |
1230 | +WebViewAdapter::~WebViewAdapter() { |
1231 | + if (preferences_) { |
1232 | + OxideQWebPreferencesPrivate::get(preferences_)->RemoveWebView(this); |
1233 | + } |
1234 | +} |
1235 | |
1236 | void WebViewAdapter::init(WebContextAdapter* context, |
1237 | const QSize& initial_size, |
1238 | @@ -82,12 +89,7 @@ |
1239 | } |
1240 | |
1241 | WebFrameAdapter* WebViewAdapter::rootFrame() const { |
1242 | - WebFrame* frame = static_cast<WebFrame *>(priv->GetRootFrame()); |
1243 | - if (!frame) { |
1244 | - return NULL; |
1245 | - } |
1246 | - |
1247 | - return frame->adapter; |
1248 | + return static_cast<WebFrame *>(priv->GetRootFrame())->adapter(); |
1249 | } |
1250 | |
1251 | void WebViewAdapter::updateSize(const QSize& size) { |
1252 | @@ -123,7 +125,7 @@ |
1253 | } |
1254 | |
1255 | bool WebViewAdapter::isInitialized() { |
1256 | - return priv->web_contents() != NULL; |
1257 | + return priv->GetWebContents() != NULL; |
1258 | } |
1259 | |
1260 | int WebViewAdapter::getNavigationEntryCount() const { |
1261 | @@ -154,5 +156,38 @@ |
1262 | return QDateTime::fromMSecsSinceEpoch(priv->GetNavigationEntryTimestamp(index).ToJsTime()); |
1263 | } |
1264 | |
1265 | +OxideQWebPreferences* WebViewAdapter::preferences() { |
1266 | + if (!preferences_) { |
1267 | + setPreferences(new OxideQWebPreferences(adapterToQObject(this))); |
1268 | + } |
1269 | + |
1270 | + return preferences_; |
1271 | +} |
1272 | + |
1273 | +void WebViewAdapter::setPreferences(OxideQWebPreferences* prefs) { |
1274 | + OxideQWebPreferences* old = preferences_; |
1275 | + preferences_ = prefs; |
1276 | + |
1277 | + if (prefs) { |
1278 | + OxideQWebPreferencesPrivate* pp = OxideQWebPreferencesPrivate::get(prefs); |
1279 | + pp->AddWebView(this); |
1280 | + priv->SetWebPreferences(&pp->preferences()); |
1281 | + |
1282 | + if (!prefs->parent()) { |
1283 | + prefs->setParent(adapterToQObject(this)); |
1284 | + } |
1285 | + } else { |
1286 | + priv->SetWebPreferences(NULL); |
1287 | + } |
1288 | + |
1289 | + if (old) { |
1290 | + OxideQWebPreferencesPrivate* pp = OxideQWebPreferencesPrivate::get(old); |
1291 | + pp->RemoveWebView(this); |
1292 | + if (!pp->in_destructor() && old->parent() == adapterToQObject(this)) { |
1293 | + delete old; |
1294 | + } |
1295 | + } |
1296 | +} |
1297 | + |
1298 | } // namespace qt |
1299 | } // namespace oxide |
1300 | |
1301 | === modified file 'qt/core/glue/oxide_qt_web_view_adapter.h' |
1302 | --- qt/core/glue/oxide_qt_web_view_adapter.h 2014-01-09 00:25:46 +0000 |
1303 | +++ qt/core/glue/oxide_qt_web_view_adapter.h 2014-02-07 16:51:32 +0000 |
1304 | @@ -33,6 +33,7 @@ |
1305 | QT_END_NAMESPACE |
1306 | |
1307 | class OxideQLoadEvent; |
1308 | +class OxideQWebPreferences; |
1309 | |
1310 | namespace oxide { |
1311 | namespace qt { |
1312 | @@ -89,8 +90,6 @@ |
1313 | |
1314 | virtual void LoadProgressChanged(double progress) = 0; |
1315 | |
1316 | - virtual void RootFrameChanged() = 0; |
1317 | - |
1318 | virtual void LoadEvent(OxideQLoadEvent* event) = 0; |
1319 | |
1320 | virtual void NavigationEntryCommitted() = 0; |
1321 | @@ -113,12 +112,20 @@ |
1322 | QString getNavigationEntryTitle(int index) const; |
1323 | QDateTime getNavigationEntryTimestamp(int index) const; |
1324 | |
1325 | + OxideQWebPreferences* preferences(); |
1326 | + void setPreferences(OxideQWebPreferences* prefs); |
1327 | + virtual void NotifyWebPreferencesDestroyed() = 0; |
1328 | + |
1329 | + virtual void FrameAdded(WebFrameAdapter* frame) = 0; |
1330 | + virtual void FrameRemoved(WebFrameAdapter* frame) = 0; |
1331 | + |
1332 | protected: |
1333 | WebViewAdapter(); |
1334 | |
1335 | private: |
1336 | + QScopedPointer<WebViewAdapterPrivate> priv; |
1337 | QList<MessageHandlerAdapter *> message_handlers_; |
1338 | - QScopedPointer<WebViewAdapterPrivate> priv; |
1339 | + OxideQWebPreferences* preferences_; |
1340 | }; |
1341 | |
1342 | } // namespace qt |
1343 | |
1344 | === modified file 'qt/core/glue/private/oxide_qt_message_handler_adapter_p.cc' |
1345 | --- qt/core/glue/private/oxide_qt_message_handler_adapter_p.cc 2014-01-09 00:10:22 +0000 |
1346 | +++ qt/core/glue/private/oxide_qt_message_handler_adapter_p.cc 2014-02-07 16:51:32 +0000 |
1347 | @@ -43,7 +43,7 @@ |
1348 | |
1349 | *error = !a->OnReceiveMessage( |
1350 | qmessage, |
1351 | - static_cast<WebFrame *>(message->source_frame())->adapter, |
1352 | + static_cast<WebFrame *>(message->source_frame())->adapter(), |
1353 | qerror); |
1354 | |
1355 | if (*error) { |
1356 | |
1357 | === modified file 'qt/core/glue/private/oxide_qt_outgoing_message_request_adapter_p.cc' |
1358 | --- qt/core/glue/private/oxide_qt_outgoing_message_request_adapter_p.cc 2013-10-29 01:06:23 +0000 |
1359 | +++ qt/core/glue/private/oxide_qt_outgoing_message_request_adapter_p.cc 2014-02-07 16:51:32 +0000 |
1360 | @@ -23,8 +23,7 @@ |
1361 | #include <QVariant> |
1362 | |
1363 | #include "qt/core/glue/oxide_qt_outgoing_message_request_adapter.h" |
1364 | - |
1365 | -#include "oxide_qt_web_frame_adapter_p.h" |
1366 | +#include "qt/core/glue/oxide_qt_web_frame_adapter_p.h" |
1367 | |
1368 | namespace oxide { |
1369 | namespace qt { |
1370 | |
1371 | === removed file 'qt/core/glue/private/oxide_qt_web_frame_adapter_p.cc' |
1372 | --- qt/core/glue/private/oxide_qt_web_frame_adapter_p.cc 2013-10-29 01:06:23 +0000 |
1373 | +++ qt/core/glue/private/oxide_qt_web_frame_adapter_p.cc 1970-01-01 00:00:00 +0000 |
1374 | @@ -1,64 +0,0 @@ |
1375 | -// vim:expandtab:shiftwidth=2:tabstop=2: |
1376 | -// Copyright (C) 2013 Canonical Ltd. |
1377 | - |
1378 | -// This library is free software; you can redistribute it and/or |
1379 | -// modify it under the terms of the GNU Lesser General Public |
1380 | -// License as published by the Free Software Foundation; either |
1381 | -// version 2.1 of the License, or (at your option) any later version. |
1382 | - |
1383 | -// This library is distributed in the hope that it will be useful, |
1384 | -// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1385 | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1386 | -// Lesser General Public License for more details. |
1387 | - |
1388 | -// You should have received a copy of the GNU Lesser General Public |
1389 | -// License along with this library; if not, write to the Free Software |
1390 | -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1391 | - |
1392 | -#include "oxide_qt_web_frame_adapter_p.h" |
1393 | - |
1394 | -#include "qt/core/browser/oxide_qt_web_frame.h" |
1395 | -#include "qt/core/glue/oxide_qt_web_frame_adapter.h" |
1396 | - |
1397 | -#include "oxide_qt_outgoing_message_request_adapter_p.h" |
1398 | - |
1399 | -namespace oxide { |
1400 | -namespace qt { |
1401 | - |
1402 | -WebFrameAdapterPrivate::WebFrameAdapterPrivate() : |
1403 | - owner(NULL) {} |
1404 | - |
1405 | -// static |
1406 | -WebFrameAdapterPrivate* WebFrameAdapterPrivate::Create() { |
1407 | - return new WebFrameAdapterPrivate(); |
1408 | -} |
1409 | - |
1410 | -WebFrameAdapterPrivate::~WebFrameAdapterPrivate() { |
1411 | - while (!outgoing_message_requests_.isEmpty()) { |
1412 | - RemoveOutgoingMessageRequest(outgoing_message_requests_.first()); |
1413 | - } |
1414 | - |
1415 | - owner->adapter = NULL; |
1416 | -} |
1417 | - |
1418 | -void WebFrameAdapterPrivate::AddOutgoingMessageRequest( |
1419 | - OutgoingMessageRequestAdapter* request) { |
1420 | - DCHECK(!outgoing_message_requests_.contains(request)); |
1421 | - |
1422 | - OutgoingMessageRequestAdapterPrivate::get(request)->frame = this; |
1423 | - outgoing_message_requests_.append(request); |
1424 | -} |
1425 | - |
1426 | -void WebFrameAdapterPrivate::RemoveOutgoingMessageRequest( |
1427 | - OutgoingMessageRequestAdapter* request) { |
1428 | - outgoing_message_requests_.removeOne(request); |
1429 | - OutgoingMessageRequestAdapterPrivate::get(request)->frame = NULL; |
1430 | -} |
1431 | - |
1432 | -// static |
1433 | -WebFrameAdapterPrivate* WebFrameAdapterPrivate::get(WebFrameAdapter* adapter) { |
1434 | - return adapter->priv.data(); |
1435 | -} |
1436 | - |
1437 | -} // namespace qt |
1438 | -} // namespace oxide |
1439 | |
1440 | === modified file 'qt/core/glue/private/oxide_qt_web_view_adapter_p.cc' |
1441 | --- qt/core/glue/private/oxide_qt_web_view_adapter_p.cc 2014-01-09 00:25:46 +0000 |
1442 | +++ qt/core/glue/private/oxide_qt_web_view_adapter_p.cc 2014-02-07 16:51:32 +0000 |
1443 | @@ -28,10 +28,10 @@ |
1444 | #include "qt/core/browser/oxide_qt_web_frame.h" |
1445 | #include "qt/core/browser/oxide_qt_web_popup_menu.h" |
1446 | #include "qt/core/glue/oxide_qt_web_frame_adapter.h" |
1447 | +#include "qt/core/glue/oxide_qt_web_frame_adapter_p.h" |
1448 | #include "qt/core/glue/oxide_qt_web_view_adapter.h" |
1449 | |
1450 | #include "oxide_qt_message_handler_adapter_p.h" |
1451 | -#include "oxide_qt_web_frame_adapter_p.h" |
1452 | |
1453 | namespace oxide { |
1454 | namespace qt { |
1455 | @@ -55,10 +55,6 @@ |
1456 | a->LoadProgressChanged(progress); |
1457 | } |
1458 | |
1459 | -void WebViewAdapterPrivate::OnRootFrameChanged() { |
1460 | - a->RootFrameChanged(); |
1461 | -} |
1462 | - |
1463 | void WebViewAdapterPrivate::OnLoadStarted(const GURL& validated_url, |
1464 | bool is_error_frame) { |
1465 | OxideQLoadEvent event( |
1466 | @@ -104,8 +100,9 @@ |
1467 | a->NavigationEntryChanged(index); |
1468 | } |
1469 | |
1470 | -oxide::WebFrame* WebViewAdapterPrivate::CreateWebFrame() { |
1471 | - return new WebFrame(a->CreateWebFrame()); |
1472 | +oxide::WebFrame* WebViewAdapterPrivate::CreateWebFrame( |
1473 | + content::FrameTreeNode* node) { |
1474 | + return new WebFrame(a->CreateWebFrame(), node, this); |
1475 | } |
1476 | |
1477 | // static |
1478 | @@ -143,5 +140,13 @@ |
1479 | return new WebPopupMenu(a->CreateWebPopupMenuDelegate(), rvh); |
1480 | } |
1481 | |
1482 | +void WebViewAdapterPrivate::FrameAdded(oxide::WebFrame* frame) { |
1483 | + a->FrameAdded(static_cast<WebFrame *>(frame)->adapter()); |
1484 | +} |
1485 | + |
1486 | +void WebViewAdapterPrivate::FrameRemoved(oxide::WebFrame* frame) { |
1487 | + a->FrameRemoved(static_cast<WebFrame *>(frame)->adapter()); |
1488 | +} |
1489 | + |
1490 | } // namespace qt |
1491 | } // namespace oxide |
1492 | |
1493 | === modified file 'qt/core/glue/private/oxide_qt_web_view_adapter_p.h' |
1494 | --- qt/core/glue/private/oxide_qt_web_view_adapter_p.h 2014-01-07 14:48:46 +0000 |
1495 | +++ qt/core/glue/private/oxide_qt_web_view_adapter_p.h 2014-02-07 16:51:32 +0000 |
1496 | @@ -42,6 +42,9 @@ |
1497 | |
1498 | oxide::WebPopupMenu* CreatePopupMenu(content::RenderViewHost* rvh) FINAL; |
1499 | |
1500 | + void FrameAdded(oxide::WebFrame* frame) FINAL; |
1501 | + void FrameRemoved(oxide::WebFrame* frame) FINAL; |
1502 | + |
1503 | private: |
1504 | WebViewAdapterPrivate(WebViewAdapter* adapter); |
1505 | |
1506 | @@ -51,8 +54,6 @@ |
1507 | |
1508 | void OnLoadProgressChanged(double progress) FINAL; |
1509 | |
1510 | - void OnRootFrameChanged() FINAL; |
1511 | - |
1512 | void OnLoadStarted(const GURL& validated_url, |
1513 | bool is_error_frame) FINAL; |
1514 | void OnLoadStopped(const GURL& validated_url) FINAL; |
1515 | @@ -65,7 +66,7 @@ |
1516 | void OnNavigationListPruned(bool from_front, int count) FINAL; |
1517 | void OnNavigationEntryChanged(int index) FINAL; |
1518 | |
1519 | - oxide::WebFrame* CreateWebFrame() FINAL; |
1520 | + oxide::WebFrame* CreateWebFrame(content::FrameTreeNode* node) FINAL; |
1521 | |
1522 | WebViewAdapter* a; |
1523 | |
1524 | |
1525 | === modified file 'qt/quick/api/oxideqquickwebframe.cc' |
1526 | --- qt/quick/api/oxideqquickwebframe.cc 2013-10-28 15:56:40 +0000 |
1527 | +++ qt/quick/api/oxideqquickwebframe.cc 2014-02-07 16:51:32 +0000 |
1528 | @@ -124,11 +124,11 @@ |
1529 | |
1530 | if (event->added()) { |
1531 | d->children().append(child); |
1532 | - emit childFrameChanged(ChildAdded, child); |
1533 | } else if (event->removed()) { |
1534 | d->children().removeOne(child); |
1535 | - emit childFrameChanged(ChildRemoved, child); |
1536 | } |
1537 | + |
1538 | + emit childFramesChanged(); |
1539 | } |
1540 | |
1541 | OxideQQuickWebFrame::~OxideQQuickWebFrame() {} |
1542 | |
1543 | === modified file 'qt/quick/api/oxideqquickwebframe_p.h' |
1544 | --- qt/quick/api/oxideqquickwebframe_p.h 2013-11-20 19:02:08 +0000 |
1545 | +++ qt/quick/api/oxideqquickwebframe_p.h 2014-02-07 16:51:32 +0000 |
1546 | @@ -35,18 +35,13 @@ |
1547 | Q_OBJECT |
1548 | Q_PROPERTY(QUrl url READ url NOTIFY urlChanged) |
1549 | Q_PROPERTY(OxideQQuickWebFrame* parentFrame READ parentFrame) |
1550 | - Q_PROPERTY(QQmlListProperty<OxideQQuickWebFrame> childFrames READ childFrames NOTIFY childFrameChanged) |
1551 | + Q_PROPERTY(QQmlListProperty<OxideQQuickWebFrame> childFrames READ childFrames NOTIFY childFramesChanged) |
1552 | Q_PROPERTY(QQmlListProperty<OxideQQuickMessageHandler> messageHandlers READ messageHandlers) |
1553 | Q_ENUMS(ChildFrameChangedType) |
1554 | |
1555 | Q_DECLARE_PRIVATE(OxideQQuickWebFrame) |
1556 | |
1557 | public: |
1558 | - enum ChildFrameChangedType { |
1559 | - ChildAdded, |
1560 | - ChildRemoved |
1561 | - }; |
1562 | - |
1563 | virtual ~OxideQQuickWebFrame(); |
1564 | |
1565 | QUrl url() const; |
1566 | @@ -68,8 +63,7 @@ |
1567 | |
1568 | Q_SIGNALS: |
1569 | void urlChanged(); |
1570 | - void childFrameChanged(ChildFrameChangedType type, |
1571 | - OxideQQuickWebFrame* child_frame); |
1572 | + void childFramesChanged(); |
1573 | void messageHandlersChanged(); |
1574 | |
1575 | protected: |
1576 | |
1577 | === modified file 'qt/quick/api/oxideqquickwebview.cc' |
1578 | --- qt/quick/api/oxideqquickwebview.cc 2014-01-20 16:44:30 +0000 |
1579 | +++ qt/quick/api/oxideqquickwebview.cc 2014-02-07 16:51:32 +0000 |
1580 | @@ -19,6 +19,7 @@ |
1581 | #include "oxideqquickwebview_p_p.h" |
1582 | |
1583 | #include <QPointF> |
1584 | +#include <QQmlEngine> |
1585 | #include <QQuickWindow> |
1586 | #include <QRect> |
1587 | #include <QRectF> |
1588 | @@ -103,19 +104,6 @@ |
1589 | emit q->loadProgressChanged(); |
1590 | } |
1591 | |
1592 | -void OxideQQuickWebViewPrivate::RootFrameChanged() { |
1593 | - Q_Q(OxideQQuickWebView); |
1594 | - |
1595 | - // Make the webview the QObject parent of the new root frame, |
1596 | - // to stop Qml from collecting the frame tree |
1597 | - OxideQQuickWebFrame* root = q->rootFrame(); |
1598 | - if (root) { |
1599 | - root->setParent(q); |
1600 | - } |
1601 | - |
1602 | - emit q->rootFrameChanged(); |
1603 | -} |
1604 | - |
1605 | void OxideQQuickWebViewPrivate::LoadEvent(OxideQLoadEvent* event) { |
1606 | Q_Q(OxideQQuickWebView); |
1607 | |
1608 | @@ -135,7 +123,9 @@ |
1609 | } |
1610 | |
1611 | oxide::qt::WebFrameAdapter* OxideQQuickWebViewPrivate::CreateWebFrame() { |
1612 | - return OxideQQuickWebFramePrivate::get(new OxideQQuickWebFrame()); |
1613 | + OxideQQuickWebFrame* frame = new OxideQQuickWebFrame(); |
1614 | + QQmlEngine::setObjectOwnership(frame, QQmlEngine::CppOwnership); |
1615 | + return OxideQQuickWebFramePrivate::get(frame); |
1616 | } |
1617 | |
1618 | QRect OxideQQuickWebViewPrivate::GetContainerBounds() { |
1619 | @@ -151,6 +141,27 @@ |
1620 | q->width(), q->height()).toRect(); |
1621 | } |
1622 | |
1623 | +void OxideQQuickWebViewPrivate::NotifyWebPreferencesDestroyed() { |
1624 | + Q_Q(OxideQQuickWebView); |
1625 | + |
1626 | + qWarning() << "WebPreferences was destroyed whilst still in use"; |
1627 | + q->setPreferences(NULL); |
1628 | +} |
1629 | + |
1630 | +void OxideQQuickWebViewPrivate::FrameAdded( |
1631 | + oxide::qt::WebFrameAdapter* frame) { |
1632 | + Q_Q(OxideQQuickWebView); |
1633 | + |
1634 | + emit q->frameAdded(adapterToQObject<OxideQQuickWebFrame>(frame)); |
1635 | +} |
1636 | + |
1637 | +void OxideQQuickWebViewPrivate::FrameRemoved( |
1638 | + oxide::qt::WebFrameAdapter* frame) { |
1639 | + Q_Q(OxideQQuickWebView); |
1640 | + |
1641 | + emit q->frameRemoved(adapterToQObject<OxideQQuickWebFrame>(frame)); |
1642 | +} |
1643 | + |
1644 | void OxideQQuickWebViewPrivate::componentComplete() { |
1645 | Q_Q(OxideQQuickWebView); |
1646 | |
1647 | @@ -291,6 +302,10 @@ |
1648 | QQuickItem::componentComplete(); |
1649 | |
1650 | d->componentComplete(); |
1651 | + |
1652 | + // Make the webview the QObject parent of the new root frame, |
1653 | + // to stop Qml from collecting the frame tree |
1654 | + rootFrame()->setParent(this); |
1655 | } |
1656 | |
1657 | QUrl OxideQQuickWebView::url() const { |
1658 | @@ -452,6 +467,23 @@ |
1659 | d->context = context; |
1660 | } |
1661 | |
1662 | +OxideQWebPreferences* OxideQQuickWebView::preferences() { |
1663 | + Q_D(OxideQQuickWebView); |
1664 | + |
1665 | + return d->preferences(); |
1666 | +} |
1667 | + |
1668 | +void OxideQQuickWebView::setPreferences(OxideQWebPreferences* prefs) { |
1669 | + Q_D(OxideQQuickWebView); |
1670 | + |
1671 | + if (prefs == d->preferences()) { |
1672 | + return; |
1673 | + } |
1674 | + |
1675 | + d->setPreferences(prefs); |
1676 | + emit preferencesChanged(); |
1677 | +} |
1678 | + |
1679 | OxideQQuickNavigationHistory* OxideQQuickWebView::navigationHistory() { |
1680 | Q_D(OxideQQuickWebView); |
1681 | |
1682 | |
1683 | === modified file 'qt/quick/api/oxideqquickwebview_p.h' |
1684 | --- qt/quick/api/oxideqquickwebview_p.h 2014-01-07 14:48:46 +0000 |
1685 | +++ qt/quick/api/oxideqquickwebview_p.h 2014-02-07 16:51:32 +0000 |
1686 | @@ -32,6 +32,7 @@ |
1687 | QT_USE_NAMESPACE |
1688 | |
1689 | class OxideQLoadEvent; |
1690 | +class OxideQWebPreferences; |
1691 | class OxideQQuickMessageHandler; |
1692 | class OxideQQuickNavigationHistory; |
1693 | class OxideQQuickWebContext; |
1694 | @@ -63,12 +64,13 @@ |
1695 | Q_PROPERTY(bool incognito READ incognito WRITE setIncognito) |
1696 | Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) |
1697 | Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged) |
1698 | - Q_PROPERTY(OxideQQuickWebFrame* rootFrame READ rootFrame NOTIFY rootFrameChanged) |
1699 | + Q_PROPERTY(OxideQQuickWebFrame* rootFrame READ rootFrame CONSTANT) |
1700 | Q_PROPERTY(QQmlListProperty<OxideQQuickMessageHandler> messageHandlers READ messageHandlers NOTIFY messageHandlersChanged) |
1701 | |
1702 | Q_PROPERTY(QQmlComponent* popupMenu READ popupMenu WRITE setPopupMenu NOTIFY popupMenuChanged) |
1703 | |
1704 | Q_PROPERTY(OxideQQuickWebContext* context READ context WRITE setContext) |
1705 | + Q_PROPERTY(OxideQWebPreferences* preferences READ preferences WRITE setPreferences NOTIFY preferencesChanged) |
1706 | |
1707 | Q_PROPERTY(OxideQQuickNavigationHistory* navigationHistory READ navigationHistory CONSTANT) |
1708 | |
1709 | @@ -107,6 +109,9 @@ |
1710 | OxideQQuickWebContext* context() const; |
1711 | void setContext(OxideQQuickWebContext* context); |
1712 | |
1713 | + OxideQWebPreferences* preferences(); |
1714 | + void setPreferences(OxideQWebPreferences* prefs); |
1715 | + |
1716 | OxideQQuickNavigationHistory* navigationHistory(); |
1717 | |
1718 | static OxideQQuickWebViewAttached* qmlAttachedProperties(QObject* object); |
1719 | @@ -123,8 +128,10 @@ |
1720 | void navigationHistoryChanged(); |
1721 | void loadingChanged(OxideQLoadEvent* loadEvent); |
1722 | void loadProgressChanged(); |
1723 | - void rootFrameChanged(); |
1724 | + void frameAdded(OxideQQuickWebFrame* frame); |
1725 | + void frameRemoved(OxideQQuickWebFrame* frame); |
1726 | void popupMenuChanged(); |
1727 | + void preferencesChanged(); |
1728 | void messageHandlersChanged(); |
1729 | |
1730 | private Q_SLOTS: |
1731 | |
1732 | === modified file 'qt/quick/api/oxideqquickwebview_p_p.h' |
1733 | --- qt/quick/api/oxideqquickwebview_p_p.h 2014-01-09 00:25:46 +0000 |
1734 | +++ qt/quick/api/oxideqquickwebview_p_p.h 2014-02-07 16:51:32 +0000 |
1735 | @@ -61,8 +61,6 @@ |
1736 | |
1737 | void LoadProgressChanged(double progress) Q_DECL_FINAL; |
1738 | |
1739 | - void RootFrameChanged() Q_DECL_FINAL; |
1740 | - |
1741 | void LoadEvent(OxideQLoadEvent* event) Q_DECL_FINAL; |
1742 | |
1743 | void NavigationEntryCommitted() Q_DECL_FINAL; |
1744 | @@ -73,6 +71,11 @@ |
1745 | |
1746 | QRect GetContainerBounds() Q_DECL_FINAL; |
1747 | |
1748 | + void NotifyWebPreferencesDestroyed() Q_DECL_FINAL; |
1749 | + |
1750 | + void FrameAdded(oxide::qt::WebFrameAdapter* frame) Q_DECL_FINAL; |
1751 | + void FrameRemoved(oxide::qt::WebFrameAdapter* frame) Q_DECL_FINAL; |
1752 | + |
1753 | void componentComplete(); |
1754 | |
1755 | static void messageHandler_append( |
1756 | |
1757 | === modified file 'qt/quick/oxide_qml_plugin.cc' |
1758 | --- qt/quick/oxide_qml_plugin.cc 2014-01-21 00:47:58 +0000 |
1759 | +++ qt/quick/oxide_qml_plugin.cc 2014-02-07 16:51:32 +0000 |
1760 | @@ -23,6 +23,7 @@ |
1761 | |
1762 | #include "qt/core/api/oxideqincomingmessage.h" |
1763 | #include "qt/core/api/oxideqloadevent.h" |
1764 | +#include "qt/core/api/oxideqwebpreferences.h" |
1765 | #include "qt/quick/api/oxideqquickglobals_p.h" |
1766 | #include "qt/quick/api/oxideqquickmessagehandler_p.h" |
1767 | #include "qt/quick/api/oxideqquicknavigationhistory_p.h" |
1768 | @@ -68,6 +69,7 @@ |
1769 | qmlRegisterType<OxideQQuickWebContext>(uri, 0, 1, "WebContext"); |
1770 | qmlRegisterUncreatableType<OxideQQuickNavigationHistory>(uri, 0, 1, "NavigationHistory", |
1771 | "Each WebView has a NavigationHistory automatically instantiated by Oxide"); |
1772 | + qmlRegisterType<OxideQWebPreferences>(uri, 0, 1, "WebPreferences"); |
1773 | qmlRegisterType<OxideQQuickWebView>(uri, 0, 1, "WebView"); |
1774 | } |
1775 | }; |
1776 | |
1777 | === modified file 'qt/tests/qmltests/api/tst_WebFrame_tree.qml' |
1778 | --- qt/tests/qmltests/api/tst_WebFrame_tree.qml 2013-11-20 19:02:08 +0000 |
1779 | +++ qt/tests/qmltests/api/tst_WebFrame_tree.qml 2014-02-07 16:51:32 +0000 |
1780 | @@ -9,39 +9,21 @@ |
1781 | width: 200 |
1782 | height: 200 |
1783 | |
1784 | - SignalSpy { |
1785 | - id: rootFrameSpy |
1786 | - target: webView |
1787 | - signalName: "rootFrameChanged" |
1788 | - } |
1789 | - |
1790 | - Item { |
1791 | - id: spy |
1792 | - |
1793 | - readonly property alias eventLog: spy.qtest_eventLog |
1794 | - |
1795 | - function clear() { |
1796 | - qtest_eventLog = []; |
1797 | - } |
1798 | - |
1799 | - function childFrameChanged(type, frame) { |
1800 | - qtest_eventLog.push({ type: type, frame: frame.toString() }); |
1801 | - |
1802 | - if (type == WebFrame.ChildAdded) { |
1803 | - frame.childFrameChanged.connect(childFrameChanged); |
1804 | - } |
1805 | - } |
1806 | - |
1807 | - function rootFrameChanged() { |
1808 | - webView.rootFrame.childFrameChanged.connect(childFrameChanged); |
1809 | - } |
1810 | - |
1811 | - property var qtest_eventLog: [] |
1812 | - |
1813 | - Component.onCompleted: { |
1814 | - webView.rootFrameChanged.connect(rootFrameChanged); |
1815 | - } |
1816 | - } |
1817 | + readonly property alias frameEvents: webView.qtest_frameEvents |
1818 | + |
1819 | + function clearFrameEvents() { |
1820 | + qtest_frameEvents = []; |
1821 | + } |
1822 | + |
1823 | + onFrameAdded: { |
1824 | + qtest_frameEvents.push({type: "added", frame: frame.toString()}); |
1825 | + } |
1826 | + |
1827 | + onFrameRemoved: { |
1828 | + qtest_frameEvents.push({type: "removed", frame: frame.toString()}); |
1829 | + } |
1830 | + |
1831 | + property var qtest_frameEvents: [] |
1832 | |
1833 | TestCase { |
1834 | id: test |
1835 | @@ -53,26 +35,27 @@ |
1836 | verify(webView.waitForLoadSucceeded(), |
1837 | "Timed out waiting for successful load"); |
1838 | |
1839 | - spy.clear(); |
1840 | - rootFrameSpy.clear(); |
1841 | + webView.clearFrameEvents(); |
1842 | } |
1843 | |
1844 | function verify_events(data) { |
1845 | - compare(spy.eventLog.length, data.length, "Unexpected number of events"); |
1846 | + compare(webView.frameEvents.length, data.length, "Unexpected number of events"); |
1847 | for (var i = 0; i < data.length; ++i) { |
1848 | - if (i >= spy.eventLog.length) { |
1849 | + if (i >= webView.frameEvents.length) { |
1850 | break; |
1851 | } |
1852 | - compare(spy.eventLog[i].type, data[i].type, "Unexpected event type"); |
1853 | - compare(spy.eventLog[i].frame, data[i].frame, "Unexpected frame"); |
1854 | + compare(webView.frameEvents[i].type, data[i].type, "Unexpected event type"); |
1855 | + compare(webView.frameEvents[i].frame, data[i].frame, "Unexpected frame"); |
1856 | } |
1857 | |
1858 | - spy.clear(); |
1859 | + webView.clearFrameEvents(); |
1860 | } |
1861 | |
1862 | function verify_tree() { |
1863 | compare(webView.rootFrame.parentFrame, null, |
1864 | "Root frame should have no parent"); |
1865 | + compare(Utils.qObjectParent(webView.rootFrame), webView, |
1866 | + "Root frame should be a qobject child of the webview"); |
1867 | |
1868 | var queue = []; |
1869 | queue.push(webView.rootFrame); |
1870 | @@ -82,6 +65,8 @@ |
1871 | for (var i = 0; i < frame.childFrames.length; ++i) { |
1872 | compare(frame.childFrames[i].parentFrame, frame, |
1873 | "Incorrect parent"); |
1874 | + compare(Utils.qObjectParent(frame.childFrames[i]), frame, |
1875 | + "Incorrect qobject parent"); |
1876 | queue.push(frame.childFrames[i]); |
1877 | } |
1878 | } |
1879 | @@ -92,16 +77,14 @@ |
1880 | verify(webView.waitForLoadSucceeded(), |
1881 | "Timed out waiting for successful load"); |
1882 | |
1883 | - compare(rootFrameSpy.count, 0, "Should have the same root frame"); |
1884 | - |
1885 | var frames1 = [ |
1886 | webView.rootFrame.childFrames[0].toString(), |
1887 | webView.rootFrame.childFrames[1].toString() |
1888 | ]; |
1889 | |
1890 | verify_events([ |
1891 | - { type: WebFrame.ChildAdded, frame: frames1[0] }, |
1892 | - { type: WebFrame.ChildAdded, frame: frames1[1] } |
1893 | + { type: "added", frame: frames1[0] }, |
1894 | + { type: "added", frame: frames1[1] } |
1895 | ]); |
1896 | verify_tree(); |
1897 | |
1898 | @@ -109,8 +92,6 @@ |
1899 | verify(webView.waitForLoadSucceeded(), |
1900 | "Timed out waiting for successful load"); |
1901 | |
1902 | - compare(rootFrameSpy.count, 0, "Should have the same root frame"); |
1903 | - |
1904 | var frames2 = [ |
1905 | webView.rootFrame.childFrames[0].toString(), |
1906 | webView.rootFrame.childFrames[1].toString(), |
1907 | @@ -119,12 +100,12 @@ |
1908 | ]; |
1909 | |
1910 | verify_events([ |
1911 | - { type: WebFrame.ChildRemoved, frame: frames1[1] }, |
1912 | - { type: WebFrame.ChildRemoved, frame: frames1[0] }, |
1913 | - { type: WebFrame.ChildAdded, frame: frames2[0] }, |
1914 | - { type: WebFrame.ChildAdded, frame: frames2[1] }, |
1915 | - { type: WebFrame.ChildAdded, frame: frames2[2] }, |
1916 | - { type: WebFrame.ChildAdded, frame: frames2[3] } |
1917 | + { type: "removed", frame: frames1[1] }, |
1918 | + { type: "removed", frame: frames1[0] }, |
1919 | + { type: "added", frame: frames2[0] }, |
1920 | + { type: "added", frame: frames2[1] }, |
1921 | + { type: "added", frame: frames2[2] }, |
1922 | + { type: "added", frame: frames2[3] } |
1923 | ]); |
1924 | verify_tree(); |
1925 | |
1926 | @@ -132,20 +113,18 @@ |
1927 | verify(webView.waitForLoadSucceeded(), |
1928 | "Timed out waiting for successful load"); |
1929 | |
1930 | - compare(rootFrameSpy.count, 0, "Should have the same root frame"); |
1931 | - |
1932 | frames1 = [ |
1933 | webView.rootFrame.childFrames[0].toString(), |
1934 | webView.rootFrame.childFrames[1].toString() |
1935 | ]; |
1936 | |
1937 | verify_events([ |
1938 | - { type: WebFrame.ChildRemoved, frame: frames2[1] }, |
1939 | - { type: WebFrame.ChildRemoved, frame: frames2[3] }, |
1940 | - { type: WebFrame.ChildRemoved, frame: frames2[2] }, |
1941 | - { type: WebFrame.ChildRemoved, frame: frames2[0] }, |
1942 | - { type: WebFrame.ChildAdded, frame: frames1[0] }, |
1943 | - { type: WebFrame.ChildAdded, frame: frames1[1] } |
1944 | + { type: "removed", frame: frames2[1] }, |
1945 | + { type: "removed", frame: frames2[3] }, |
1946 | + { type: "removed", frame: frames2[2] }, |
1947 | + { type: "removed", frame: frames2[0] }, |
1948 | + { type: "added", frame: frames1[0] }, |
1949 | + { type: "added", frame: frames1[1] } |
1950 | ]); |
1951 | verify_tree(); |
1952 | } |
1953 | @@ -155,8 +134,6 @@ |
1954 | verify(webView.waitForLoadSucceeded(), |
1955 | "Timed out waiting for successful load"); |
1956 | |
1957 | - compare(rootFrameSpy.count, 1, "Should have a new root frame"); |
1958 | - |
1959 | var frames = [ |
1960 | webView.rootFrame.childFrames[0].toString(), |
1961 | webView.rootFrame.childFrames[1].toString(), |
1962 | @@ -165,10 +142,10 @@ |
1963 | ]; |
1964 | |
1965 | verify_events([ |
1966 | - { type: WebFrame.ChildAdded, frame: frames[0] }, |
1967 | - { type: WebFrame.ChildAdded, frame: frames[1] }, |
1968 | - { type: WebFrame.ChildAdded, frame: frames[2] }, |
1969 | - { type: WebFrame.ChildAdded, frame: frames[3] } |
1970 | + { type: "added", frame: frames[0] }, |
1971 | + { type: "added", frame: frames[1] }, |
1972 | + { type: "added", frame: frames[2] }, |
1973 | + { type: "added", frame: frames[3] } |
1974 | ]); |
1975 | verify_tree(); |
1976 | |
1977 | @@ -176,13 +153,11 @@ |
1978 | verify(webView.waitForLoadSucceeded(), |
1979 | "Timed out waiting for successful load"); |
1980 | |
1981 | - compare(rootFrameSpy.count, 2, "Should have a new root frame"); |
1982 | - |
1983 | verify_events([ |
1984 | - { type: WebFrame.ChildRemoved, frame: frames[1] }, |
1985 | - { type: WebFrame.ChildRemoved, frame: frames[3] }, |
1986 | - { type: WebFrame.ChildRemoved, frame: frames[2] }, |
1987 | - { type: WebFrame.ChildRemoved, frame: frames[0] } |
1988 | + { type: "removed", frame: frames[2] }, |
1989 | + { type: "removed", frame: frames[3] }, |
1990 | + { type: "removed", frame: frames[0] }, |
1991 | + { type: "removed", frame: frames[1] } |
1992 | ]); |
1993 | verify_tree(); |
1994 | |
1995 | @@ -190,8 +165,6 @@ |
1996 | verify(webView.waitForLoadSucceeded(), |
1997 | "Timed out waiting for successful load"); |
1998 | |
1999 | - compare(rootFrameSpy.count, 3, "Should have a new root frame"); |
2000 | - |
2001 | frames = [ |
2002 | webView.rootFrame.childFrames[0].toString(), |
2003 | webView.rootFrame.childFrames[1].toString(), |
2004 | @@ -200,10 +173,10 @@ |
2005 | ]; |
2006 | |
2007 | verify_events([ |
2008 | - { type: WebFrame.ChildAdded, frame: frames[0] }, |
2009 | - { type: WebFrame.ChildAdded, frame: frames[1] }, |
2010 | - { type: WebFrame.ChildAdded, frame: frames[2] }, |
2011 | - { type: WebFrame.ChildAdded, frame: frames[3] } |
2012 | + { type: "added", frame: frames[0] }, |
2013 | + { type: "added", frame: frames[1] }, |
2014 | + { type: "added", frame: frames[2] }, |
2015 | + { type: "added", frame: frames[3] } |
2016 | ]); |
2017 | verify_tree(); |
2018 | } |
2019 | |
2020 | === modified file 'qt/tests/qmltests/api/tst_WebFrame_url.qml' |
2021 | --- qt/tests/qmltests/api/tst_WebFrame_url.qml 2013-10-08 16:00:27 +0000 |
2022 | +++ qt/tests/qmltests/api/tst_WebFrame_url.qml 2014-02-07 16:51:32 +0000 |
2023 | @@ -13,7 +13,7 @@ |
2024 | signalName: "urlChanged" |
2025 | } |
2026 | |
2027 | - onRootFrameChanged: { |
2028 | + Component.onCompleted: { |
2029 | spy.target = webView.rootFrame; |
2030 | } |
2031 | |
2032 | |
2033 | === added file 'qt/tests/qmltests/api/tst_WebView_preferences.qml' |
2034 | --- qt/tests/qmltests/api/tst_WebView_preferences.qml 1970-01-01 00:00:00 +0000 |
2035 | +++ qt/tests/qmltests/api/tst_WebView_preferences.qml 2014-02-07 16:51:32 +0000 |
2036 | @@ -0,0 +1,64 @@ |
2037 | +import QtQuick 2.0 |
2038 | +import QtTest 1.0 |
2039 | +import com.canonical.Oxide 0.1 |
2040 | +import com.canonical.Oxide.Testing 0.1 |
2041 | + |
2042 | +TestWebView { |
2043 | + id: webView |
2044 | + focus: true |
2045 | + width: 200 |
2046 | + height: 200 |
2047 | + |
2048 | + SignalSpy { |
2049 | + id: spy |
2050 | + target: webView |
2051 | + signalName: "preferencesChanged" |
2052 | + } |
2053 | + |
2054 | + Component { |
2055 | + id: webPreferences |
2056 | + WebPreferences {} |
2057 | + } |
2058 | + |
2059 | + TestCase { |
2060 | + id: test |
2061 | + name: "WebView_preferences" |
2062 | + when: windowShown |
2063 | + |
2064 | + function test_WebView_preferences() { |
2065 | + verify(webView.preferences, "No default preferences"); |
2066 | + compare(spy.count, 0, |
2067 | + "Constructing the default shouldn't have caused a signal"); |
2068 | + compare(OxideTestingUtils.qObjectParent(webView.preferences), webView, |
2069 | + "WebView should own its default preferences"); |
2070 | + |
2071 | + var destructionObserver = OxideTestingUtils.createDestructionObserver( |
2072 | + webView.preferences); |
2073 | + var newPrefs = webPreferences.createObject(null, {}); |
2074 | + webView.preferences = newPrefs; |
2075 | + |
2076 | + compare(spy.count, 1, |
2077 | + "Assigning a new preference object should have caused a signal"); |
2078 | + compare(webView.preferences, newPrefs, |
2079 | + "Should have a new preference object"); |
2080 | + compare(OxideTestingUtils.qObjectParent(webView.preferences), webView, |
2081 | + "WebView should own its default preferences"); |
2082 | + gc(); |
2083 | + verify(webView.waitFor(function() { return destructionObserver.destroyed; }), |
2084 | + "The default preference object should have been destroyed"); |
2085 | + |
2086 | + destructionObserver = OxideTestingUtils.createDestructionObserver( |
2087 | + webView.preferences); |
2088 | + var oldSetting = webView.preferences.javascriptEnabled = !webView.preferences.javascriptEnabled; |
2089 | + webView.preferences.destroy(); |
2090 | + gc(); |
2091 | + verify(webView.waitFor(function() { return destructionObserver.destroyed; })); |
2092 | + |
2093 | + compare(spy.count, 2, |
2094 | + "Deleting our preference object should have caused a signal"); |
2095 | + verify(webView.preferences, "Should have default preferences again"); |
2096 | + compare(webView.preferences.javascriptEnabled, !oldSetting, |
2097 | + "We still have the old preferences object"); |
2098 | + } |
2099 | + } |
2100 | +} |
2101 | |
2102 | === modified file 'qt/tests/qmltests/api/tst_WebView_rootFrame.qml' |
2103 | --- qt/tests/qmltests/api/tst_WebView_rootFrame.qml 2013-10-08 13:58:54 +0000 |
2104 | +++ qt/tests/qmltests/api/tst_WebView_rootFrame.qml 2014-02-07 16:51:32 +0000 |
2105 | @@ -13,39 +13,21 @@ |
2106 | name: "WebView_rootFrame" |
2107 | when: windowShown |
2108 | |
2109 | - SignalSpy { |
2110 | - id: spy |
2111 | - target: webView |
2112 | - signalName: "rootFrameChanged" |
2113 | + function test_WebView_rootFrame1_parent() { |
2114 | + verify(webView.rootFrame, "Should always have a root frame"); |
2115 | + compare(Utils.qObjectParent(webView.rootFrame), webView, |
2116 | + "The root frame should be parented to the webview"); |
2117 | } |
2118 | |
2119 | - function test_WebView_rootFrame1() { |
2120 | - verify(!webView.rootFrame, "Shouldn't have a frame yet"); |
2121 | - |
2122 | - webView.url = "http://localhost:8080/tst_WebView_rootFrame.html"; |
2123 | - verify(webView.waitForLoadSucceeded(), |
2124 | - "Timed out waiting for successful load"); |
2125 | - |
2126 | - compare(spy.count, 1, "Should have a root frame"); |
2127 | - verify(webView.rootFrame, "Should have a root frame"); |
2128 | - |
2129 | - var root = webView.rootFrame; |
2130 | - |
2131 | - webView.url = "about:blank"; |
2132 | - verify(webView.waitForLoadSucceeded(), |
2133 | - "Timed out waiting for successful load"); |
2134 | - |
2135 | - compare(spy.count, 2, "Should have a new root frame"); |
2136 | - verify(webView.rootFrame, "Should have a root frame"); |
2137 | - |
2138 | - compare(root.sendMessage, undefined, "The old root frame should no longer exist"); |
2139 | - |
2140 | - webView.goBack(); |
2141 | - verify(webView.waitForLoadSucceeded(), |
2142 | - "Timed out waiting for successful load"); |
2143 | - |
2144 | - compare(spy.count, 3, "Should have the old root frame back again now"); |
2145 | - verify(webView.rootFrame, "Should have a root frame"); |
2146 | + function test_WebView_rootFrame2_undeletable() { |
2147 | + var caught = false; |
2148 | + try { |
2149 | + webView.rootFrame.destroy(); |
2150 | + } catch(e) { |
2151 | + caught = true; |
2152 | + } |
2153 | + |
2154 | + verify(caught, "WebView.rootFrame.destroy() should have thrown"); |
2155 | } |
2156 | } |
2157 | } |
2158 | |
2159 | === modified file 'qt/tests/qmltests/oxide_qml_testing_plugin.cc' |
2160 | --- qt/tests/qmltests/oxide_qml_testing_plugin.cc 2014-01-25 11:15:30 +0000 |
2161 | +++ qt/tests/qmltests/oxide_qml_testing_plugin.cc 2014-02-07 16:51:32 +0000 |
2162 | @@ -82,6 +82,14 @@ |
2163 | return url; |
2164 | } |
2165 | |
2166 | + Q_INVOKABLE QObject* qObjectParent(QObject* object) { |
2167 | + if (!object) { |
2168 | + return NULL; |
2169 | + } |
2170 | + |
2171 | + return object->parent(); |
2172 | + } |
2173 | + |
2174 | Q_INVOKABLE DestructionObserver* createDestructionObserver(QObject* object) { |
2175 | if (!object) { |
2176 | return NULL; |
2177 | |
2178 | === modified file 'shared/app/oxide_content_main_delegate.cc' |
2179 | --- shared/app/oxide_content_main_delegate.cc 2014-01-30 10:57:52 +0000 |
2180 | +++ shared/app/oxide_content_main_delegate.cc 2014-02-07 16:51:32 +0000 |
2181 | @@ -105,6 +105,11 @@ |
2182 | // This is needed so that we can share GL resources with the embedder |
2183 | command_line->AppendSwitch(switches::kInProcessGPU); |
2184 | |
2185 | + command_line->AppendSwitch(switches::kEnableViewport); |
2186 | + command_line->AppendSwitch(switches::kEnableViewportMeta); |
2187 | + command_line->AppendSwitch(switches::kEnablePinch); |
2188 | + command_line->AppendSwitch(switches::kEnableOverlayScrollbars); |
2189 | + |
2190 | const char* renderer_cmd_prefix = getenv("OXIDE_RENDERER_CMD_PREFIX"); |
2191 | if (renderer_cmd_prefix) { |
2192 | command_line->AppendSwitchASCII(switches::kRendererCmdPrefix, |
2193 | @@ -113,6 +118,9 @@ |
2194 | if (getenv("OXIDE_NO_SANDBOX")) { |
2195 | command_line->AppendSwitch(switches::kNoSandbox); |
2196 | } |
2197 | + if (getenv("OXIDE_SINGLE_PROCESS")) { |
2198 | + command_line->AppendSwitch(switches::kSingleProcess); |
2199 | + } |
2200 | } |
2201 | |
2202 | return false; |
2203 | |
2204 | === modified file 'shared/browser/oxide_content_browser_client.cc' |
2205 | --- shared/browser/oxide_content_browser_client.cc 2014-01-13 22:06:04 +0000 |
2206 | +++ shared/browser/oxide_content_browser_client.cc 2014-02-07 16:51:32 +0000 |
2207 | @@ -44,8 +44,11 @@ |
2208 | |
2209 | #include "oxide_browser_context.h" |
2210 | #include "oxide_browser_process_main.h" |
2211 | +#include "oxide_message_dispatcher_browser.h" |
2212 | #include "oxide_message_pump.h" |
2213 | #include "oxide_web_contents_view.h" |
2214 | +#include "oxide_web_preferences.h" |
2215 | +#include "oxide_web_view.h" |
2216 | |
2217 | namespace oxide { |
2218 | |
2219 | @@ -213,10 +216,11 @@ |
2220 | return view; |
2221 | } |
2222 | |
2223 | -void ContentBrowserClient::RenderProcessHostCreated( |
2224 | +void ContentBrowserClient::RenderProcessWillLaunch( |
2225 | content::RenderProcessHost* host) { |
2226 | host->Send(new OxideMsg_SetIsIncognitoProcess( |
2227 | host->GetBrowserContext()->IsOffTheRecord())); |
2228 | + host->AddFilter(new MessageDispatcherBrowser(host->GetID())); |
2229 | } |
2230 | |
2231 | net::URLRequestContextGetter* ContentBrowserClient::CreateRequestContext( |
2232 | @@ -260,17 +264,11 @@ |
2233 | void ContentBrowserClient::OverrideWebkitPrefs( |
2234 | content::RenderViewHost* render_view_host, |
2235 | const GURL& url, |
2236 | - WebPreferences* prefs) { |
2237 | - // XXX: This is temporary until we expose a WebPreferences API |
2238 | - if (getenv("OXIDE_ENABLE_COMPOSITING") && |
2239 | - g_main_parts->shared_gl_context() && |
2240 | - g_main_parts->shared_gl_context()->GetImplementation() == |
2241 | - gfx::GetGLImplementation()) { |
2242 | - prefs->force_compositing_mode = true; |
2243 | - prefs->accelerated_compositing_enabled = true; |
2244 | - } else { |
2245 | - prefs->force_compositing_mode = false; |
2246 | - prefs->accelerated_compositing_enabled = false; |
2247 | + ::WebPreferences* prefs) { |
2248 | + WebView* view = WebView::FromRenderViewHost(render_view_host); |
2249 | + WebPreferences* web_prefs = view->GetWebPreferences(); |
2250 | + if (web_prefs) { |
2251 | + web_prefs->ApplyToWebkitPrefs(prefs); |
2252 | } |
2253 | } |
2254 | |
2255 | @@ -290,4 +288,8 @@ |
2256 | void ContentBrowserClient::GetAllowedGLImplementations( |
2257 | std::vector<gfx::GLImplementation>* impls) {} |
2258 | |
2259 | +WebPreferences* ContentBrowserClient::GetDefaultWebPreferences() { |
2260 | + return NULL; |
2261 | +} |
2262 | + |
2263 | } // namespace oxide |
2264 | |
2265 | === modified file 'shared/browser/oxide_content_browser_client.h' |
2266 | --- shared/browser/oxide_content_browser_client.h 2014-01-13 22:06:04 +0000 |
2267 | +++ shared/browser/oxide_content_browser_client.h 2014-02-07 16:51:32 +0000 |
2268 | @@ -47,6 +47,7 @@ |
2269 | class GLShareGroup; |
2270 | class SharedGLContext; |
2271 | class WebFrameTree; |
2272 | +class WebPreferences; |
2273 | |
2274 | class ContentBrowserClient : public content::ContentBrowserClient { |
2275 | public: |
2276 | @@ -60,7 +61,7 @@ |
2277 | content::RenderViewHostDelegateView** render_view_host_delegate_view) |
2278 | FINAL; |
2279 | |
2280 | - void RenderProcessHostCreated(content::RenderProcessHost* host) FINAL; |
2281 | + void RenderProcessWillLaunch(content::RenderProcessHost* host) FINAL; |
2282 | |
2283 | net::URLRequestContextGetter* CreateRequestContext( |
2284 | content::BrowserContext* browser_context, |
2285 | @@ -80,7 +81,7 @@ |
2286 | |
2287 | void OverrideWebkitPrefs(content::RenderViewHost* render_view_host, |
2288 | const GURL& url, |
2289 | - WebPreferences* prefs) FINAL; |
2290 | + ::WebPreferences* prefs) FINAL; |
2291 | |
2292 | gfx::GLShareGroup* GetGLShareGroup() FINAL; |
2293 | |
2294 | @@ -94,6 +95,8 @@ |
2295 | |
2296 | virtual void GetDefaultScreenInfo(blink::WebScreenInfo* result) = 0; |
2297 | |
2298 | + virtual WebPreferences* GetDefaultWebPreferences(); |
2299 | + |
2300 | protected: |
2301 | // Limit default constructor access to derived classes |
2302 | ContentBrowserClient(); |
2303 | |
2304 | === modified file 'shared/browser/oxide_incoming_message.cc' |
2305 | --- shared/browser/oxide_incoming_message.cc 2013-11-20 19:02:08 +0000 |
2306 | +++ shared/browser/oxide_incoming_message.cc 2014-02-07 16:51:32 +0000 |
2307 | @@ -17,13 +17,12 @@ |
2308 | |
2309 | #include "oxide_incoming_message.h" |
2310 | |
2311 | -#include "content/public/browser/render_view_host.h" |
2312 | -#include "content/public/browser/web_contents.h" |
2313 | +#include "content/browser/frame_host/frame_tree_node.h" |
2314 | +#include "content/public/browser/render_frame_host.h" |
2315 | |
2316 | #include "shared/common/oxide_messages.h" |
2317 | |
2318 | #include "oxide_web_frame.h" |
2319 | -#include "oxide_web_view.h" |
2320 | |
2321 | namespace oxide { |
2322 | |
2323 | @@ -46,18 +45,15 @@ |
2324 | } |
2325 | |
2326 | OxideMsg_SendMessage_Params params; |
2327 | - params.frame_id = source_frame()->identifier(); |
2328 | params.world_id = world_id_; |
2329 | params.serial = serial_; |
2330 | params.type = OxideMsg_SendMessage_Type::Reply; |
2331 | params.error = OxideMsg_SendMessage_Error::OK; |
2332 | - params.args = args; |
2333 | + params.payload = args; |
2334 | |
2335 | - // FIXME: This is clearly broken for OOPIF |
2336 | - content::WebContents* web_contents = source_frame()->view()->web_contents(); |
2337 | - web_contents->Send(new OxideMsg_SendMessage( |
2338 | - web_contents->GetRenderViewHost()->GetRoutingID(), |
2339 | - params)); |
2340 | + content::RenderFrameHost* rfh = |
2341 | + source_frame()->frame_tree_node()->current_frame_host(); |
2342 | + rfh->Send(new OxideMsg_SendMessage(rfh->GetRoutingID(), params)); |
2343 | } |
2344 | |
2345 | void IncomingMessage::Error(const std::string& msg) { |
2346 | @@ -67,18 +63,15 @@ |
2347 | } |
2348 | |
2349 | OxideMsg_SendMessage_Params params; |
2350 | - params.frame_id = source_frame()->identifier(); |
2351 | params.world_id = world_id_; |
2352 | params.serial = serial_; |
2353 | params.type = OxideMsg_SendMessage_Type::Reply; |
2354 | params.error = OxideMsg_SendMessage_Error::HANDLER_REPORTED_ERROR; |
2355 | - params.args = msg; |
2356 | + params.payload = msg; |
2357 | |
2358 | - // FIXME: This is clearly broken for OOPIF |
2359 | - content::WebContents* web_contents = source_frame()->view()->web_contents(); |
2360 | - web_contents->Send(new OxideMsg_SendMessage( |
2361 | - web_contents->GetRenderViewHost()->GetRoutingID(), |
2362 | - params)); |
2363 | + content::RenderFrameHost* rfh = |
2364 | + source_frame()->frame_tree_node()->current_frame_host(); |
2365 | + rfh->Send(new OxideMsg_SendMessage(rfh->GetRoutingID(), params)); |
2366 | } |
2367 | |
2368 | } // namespace oxide |
2369 | |
2370 | === added file 'shared/browser/oxide_message_dispatcher_browser.cc' |
2371 | --- shared/browser/oxide_message_dispatcher_browser.cc 1970-01-01 00:00:00 +0000 |
2372 | +++ shared/browser/oxide_message_dispatcher_browser.cc 2014-02-07 16:51:32 +0000 |
2373 | @@ -0,0 +1,209 @@ |
2374 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
2375 | +// Copyright (C) 2013 Canonical Ltd. |
2376 | + |
2377 | +// This library is free software; you can redistribute it and/or |
2378 | +// modify it under the terms of the GNU Lesser General Public |
2379 | +// License as published by the Free Software Foundation; either |
2380 | +// version 2.1 of the License, or (at your option) any later version. |
2381 | + |
2382 | +// This library is distributed in the hope that it will be useful, |
2383 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
2384 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2385 | +// Lesser General Public License for more details. |
2386 | + |
2387 | +// You should have received a copy of the GNU Lesser General Public |
2388 | +// License along with this library; if not, write to the Free Software |
2389 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2390 | + |
2391 | +#include "oxide_message_dispatcher_browser.h" |
2392 | + |
2393 | +#include <string> |
2394 | +#include <vector> |
2395 | + |
2396 | +#include "base/bind.h" |
2397 | +#include "base/callback.h" |
2398 | +#include "base/logging.h" |
2399 | +#include "content/browser/frame_host/render_frame_host_impl.h" |
2400 | +#include "content/public/browser/browser_thread.h" |
2401 | +#include "content/public/browser/render_frame_host.h" |
2402 | +#include "content/public/browser/render_process_host.h" |
2403 | +#include "ipc/ipc_message.h" |
2404 | +#include "ipc/ipc_message_macros.h" |
2405 | + |
2406 | +#include "shared/common/oxide_messages.h" |
2407 | + |
2408 | +#include "oxide_incoming_message.h" |
2409 | +#include "oxide_message_handler.h" |
2410 | +#include "oxide_message_target.h" |
2411 | +#include "oxide_outgoing_message_request.h" |
2412 | +#include "oxide_web_frame.h" |
2413 | +#include "oxide_web_view.h" |
2414 | + |
2415 | +namespace oxide { |
2416 | + |
2417 | +namespace { |
2418 | + |
2419 | +class MessageReceiver { |
2420 | + public: |
2421 | + MessageReceiver(int render_process_id, int routing_id) : |
2422 | + render_process_id_(render_process_id), |
2423 | + routing_id_(routing_id) {} |
2424 | + |
2425 | + ~MessageReceiver() {} |
2426 | + |
2427 | + void OnReceiveMessage(const OxideMsg_SendMessage_Params& params) { |
2428 | + params_ = params; |
2429 | + |
2430 | + content::BrowserThread::PostTask( |
2431 | + content::BrowserThread::UI, FROM_HERE, |
2432 | + base::Bind(&MessageReceiver::ReceiveMessageOnUIThread, |
2433 | + base::Owned(this))); |
2434 | + } |
2435 | + |
2436 | + void ReceiveMessageOnUIThread() { |
2437 | + bool is_reply = params_.type == OxideMsg_SendMessage_Type::Reply; |
2438 | + |
2439 | + content::RenderFrameHostImpl* rfh = |
2440 | + content::RenderFrameHostImpl::FromID(render_process_id_, routing_id_); |
2441 | + if (!rfh) { |
2442 | + if (!is_reply) { |
2443 | + ReturnError(NULL, OxideMsg_SendMessage_Error::INVALID_DESTINATION, |
2444 | + "Could not find a RenderFrameHost corresponding to the " |
2445 | + "specified routing ID"); |
2446 | + } |
2447 | + return; |
2448 | + } |
2449 | + |
2450 | + WebFrame* frame = WebFrame::FromFrameTreeNode(rfh->frame_tree_node()); |
2451 | + if (!frame) { |
2452 | + if (!is_reply) { |
2453 | + ReturnError(rfh, OxideMsg_SendMessage_Error::INVALID_DESTINATION, |
2454 | + "The RenderFrameHost does not have a corresponding WebFrame"); |
2455 | + } |
2456 | + return; |
2457 | + } |
2458 | + |
2459 | + if (!is_reply) { |
2460 | + if (params_.type != OxideMsg_SendMessage_Type::Message) { |
2461 | + LOG(ERROR) << "Invalid message type from renderer"; |
2462 | + rfh->GetProcess()->ReceivedBadMessage(); |
2463 | + return; |
2464 | + } |
2465 | + |
2466 | + WebFrame* target = frame; |
2467 | + WebView* view = frame->view(); |
2468 | + |
2469 | + while (target) { |
2470 | + DCHECK_EQ(target->view(), view); |
2471 | + if (TryDispatchMessageToTarget(target, frame)) { |
2472 | + break; |
2473 | + } |
2474 | + |
2475 | + target = target->parent(); |
2476 | + } |
2477 | + |
2478 | + if (!target && !TryDispatchMessageToTarget(view, frame)) { |
2479 | + ReturnError( |
2480 | + rfh, OxideMsg_SendMessage_Error::NO_HANDLER, |
2481 | + std::string("Could not find a handler for message")); |
2482 | + } |
2483 | + |
2484 | + return; |
2485 | + } |
2486 | + |
2487 | + for (size_t i = 0; i < frame->GetOutgoingMessageRequestCount(); ++i) { |
2488 | + OutgoingMessageRequest* request = frame->GetOutgoingMessageRequestAt(i); |
2489 | + |
2490 | + if (request->serial() == params_.serial) { |
2491 | + request->OnReceiveResponse(params_.payload, params_.error); |
2492 | + return; |
2493 | + } |
2494 | + } |
2495 | + } |
2496 | + |
2497 | + private: |
2498 | + bool TryDispatchMessageToTarget(MessageTarget* target, |
2499 | + WebFrame* source_frame) { |
2500 | + for (size_t i = 0; i < target->GetMessageHandlerCount(); ++i) { |
2501 | + MessageHandler* handler = target->GetMessageHandlerAt(i); |
2502 | + |
2503 | + if (!handler->IsValid()) { |
2504 | + continue; |
2505 | + } |
2506 | + |
2507 | + if (handler->msg_id() != params_.msg_id) { |
2508 | + continue; |
2509 | + } |
2510 | + |
2511 | + const std::vector<std::string>& world_ids = handler->world_ids(); |
2512 | + |
2513 | + for (std::vector<std::string>::const_iterator it = world_ids.begin(); |
2514 | + it != world_ids.end(); ++it) { |
2515 | + if ((*it) == params_.world_id) { |
2516 | + handler->OnReceiveMessage( |
2517 | + new IncomingMessage(source_frame, params_.serial, |
2518 | + params_.world_id, params_.msg_id, |
2519 | + params_.payload)); |
2520 | + return true; |
2521 | + } |
2522 | + } |
2523 | + } |
2524 | + |
2525 | + return false; |
2526 | + } |
2527 | + |
2528 | + void ReturnError(content::RenderFrameHost* rfh, |
2529 | + OxideMsg_SendMessage_Error::Value type, |
2530 | + const std::string& msg) { |
2531 | + OxideMsg_SendMessage_Params params; |
2532 | + params.world_id = params_.world_id; |
2533 | + params.serial = params_.serial; |
2534 | + params.type = OxideMsg_SendMessage_Type::Reply; |
2535 | + params.msg_id = params_.msg_id; |
2536 | + |
2537 | + params.error = type; |
2538 | + params.payload = msg; |
2539 | + |
2540 | + content::RenderProcessHost* process = NULL; |
2541 | + if (rfh) { |
2542 | + process = rfh->GetProcess(); |
2543 | + } |
2544 | + if (!process) { |
2545 | + process = content::RenderProcessHost::FromID(render_process_id_); |
2546 | + } |
2547 | + if (!process) { |
2548 | + return; |
2549 | + } |
2550 | + |
2551 | + process->Send(new OxideMsg_SendMessage(routing_id_, params)); |
2552 | + } |
2553 | + |
2554 | + OxideMsg_SendMessage_Params params_; |
2555 | + |
2556 | + const int render_process_id_; |
2557 | + const int routing_id_; |
2558 | +}; |
2559 | + |
2560 | +} // namespace |
2561 | + |
2562 | +MessageDispatcherBrowser::MessageDispatcherBrowser( |
2563 | + int render_process_id) : |
2564 | + render_process_id_(render_process_id) {} |
2565 | + |
2566 | +MessageDispatcherBrowser::~MessageDispatcherBrowser() {} |
2567 | + |
2568 | +bool MessageDispatcherBrowser::OnMessageReceived(const IPC::Message& message, |
2569 | + bool* message_was_ok) { |
2570 | + bool handled = true; |
2571 | + IPC_BEGIN_MESSAGE_MAP_EX(MessageDispatcherBrowser, message, *message_was_ok) |
2572 | + IPC_MESSAGE_FORWARD(OxideHostMsg_SendMessage, |
2573 | + new MessageReceiver(render_process_id_, |
2574 | + message.routing_id()), |
2575 | + MessageReceiver::OnReceiveMessage) |
2576 | + IPC_MESSAGE_UNHANDLED(handled = false) |
2577 | + IPC_END_MESSAGE_MAP_EX() |
2578 | + |
2579 | + return handled; |
2580 | +} |
2581 | + |
2582 | +} // namespace oxide |
2583 | |
2584 | === added file 'shared/browser/oxide_message_dispatcher_browser.h' |
2585 | --- shared/browser/oxide_message_dispatcher_browser.h 1970-01-01 00:00:00 +0000 |
2586 | +++ shared/browser/oxide_message_dispatcher_browser.h 2014-02-07 16:51:32 +0000 |
2587 | @@ -0,0 +1,42 @@ |
2588 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
2589 | +// Copyright (C) 2013 Canonical Ltd. |
2590 | + |
2591 | +// This library is free software; you can redistribute it and/or |
2592 | +// modify it under the terms of the GNU Lesser General Public |
2593 | +// License as published by the Free Software Foundation; either |
2594 | +// version 2.1 of the License, or (at your option) any later version. |
2595 | + |
2596 | +// This library is distributed in the hope that it will be useful, |
2597 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
2598 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2599 | +// Lesser General Public License for more details. |
2600 | + |
2601 | +// You should have received a copy of the GNU Lesser General Public |
2602 | +// License along with this library; if not, write to the Free Software |
2603 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2604 | + |
2605 | +#ifndef _OXIDE_SHARED_BROWSER_MESSAGE_DISPATCHER_H_ |
2606 | +#define _OXIDE_SHARED_BROWSER_MESSAGE_DISPATCHER_H_ |
2607 | + |
2608 | +#include "base/basictypes.h" |
2609 | +#include "base/compiler_specific.h" |
2610 | +#include "content/public/browser/browser_message_filter.h" |
2611 | + |
2612 | +namespace oxide { |
2613 | + |
2614 | +class MessageDispatcherBrowser FINAL : public content::BrowserMessageFilter { |
2615 | + public: |
2616 | + MessageDispatcherBrowser(int render_process_id); |
2617 | + ~MessageDispatcherBrowser(); |
2618 | + |
2619 | + bool OnMessageReceived(const IPC::Message& message, |
2620 | + bool* message_was_ok) FINAL; |
2621 | + private: |
2622 | + const int render_process_id_; |
2623 | + |
2624 | + DISALLOW_IMPLICIT_CONSTRUCTORS(MessageDispatcherBrowser); |
2625 | +}; |
2626 | + |
2627 | +} // namespace oxide |
2628 | + |
2629 | +#endif // _OXIDE_SHARED_BROWSER_MESSAGE_DISPATCHER_H_ |
2630 | |
2631 | === modified file 'shared/browser/oxide_message_handler.cc' |
2632 | --- shared/browser/oxide_message_handler.cc 2013-11-20 19:02:08 +0000 |
2633 | +++ shared/browser/oxide_message_handler.cc 2014-02-07 16:51:32 +0000 |
2634 | @@ -18,14 +18,13 @@ |
2635 | #include "oxide_message_handler.h" |
2636 | |
2637 | #include "base/logging.h" |
2638 | -#include "content/public/browser/render_view_host.h" |
2639 | -#include "content/public/browser/web_contents.h" |
2640 | +#include "content/browser/frame_host/frame_tree_node.h" |
2641 | +#include "content/public/browser/render_frame_host.h" |
2642 | |
2643 | #include "shared/common/oxide_messages.h" |
2644 | |
2645 | #include "oxide_incoming_message.h" |
2646 | #include "oxide_web_frame.h" |
2647 | -#include "oxide_web_view.h" |
2648 | |
2649 | namespace oxide { |
2650 | |
2651 | @@ -50,19 +49,15 @@ |
2652 | |
2653 | if (error) { |
2654 | OxideMsg_SendMessage_Params params; |
2655 | - params.frame_id = message->source_frame()->identifier(); |
2656 | params.world_id = message->world_id(); |
2657 | params.serial = message->serial(); |
2658 | params.type = OxideMsg_SendMessage_Type::Reply; |
2659 | params.error = OxideMsg_SendMessage_Error::UNCAUGHT_EXCEPTION; |
2660 | - params.args = error_desc; |
2661 | + params.payload = error_desc; |
2662 | |
2663 | - // FIXME: This is clearly broken for OOPIF |
2664 | - content::WebContents* web_contents = |
2665 | - message->source_frame()->view()->web_contents(); |
2666 | - web_contents->Send(new OxideMsg_SendMessage( |
2667 | - web_contents->GetRenderViewHost()->GetRoutingID(), |
2668 | - params)); |
2669 | + content::RenderFrameHost* rfh = |
2670 | + message->source_frame()->frame_tree_node()->current_frame_host(); |
2671 | + rfh->Send(new OxideMsg_SendMessage(rfh->GetRoutingID(), params)); |
2672 | } |
2673 | } |
2674 | |
2675 | |
2676 | === modified file 'shared/browser/oxide_outgoing_message_request.cc' |
2677 | --- shared/browser/oxide_outgoing_message_request.cc 2013-11-20 19:02:08 +0000 |
2678 | +++ shared/browser/oxide_outgoing_message_request.cc 2014-02-07 16:51:32 +0000 |
2679 | @@ -38,7 +38,7 @@ |
2680 | } |
2681 | |
2682 | void OutgoingMessageRequest::OnReceiveResponse( |
2683 | - const std::string& args, |
2684 | + const std::string& payload, |
2685 | OxideMsg_SendMessage_Error::Value error) { |
2686 | if (had_response_) { |
2687 | return; |
2688 | @@ -48,11 +48,11 @@ |
2689 | |
2690 | if (error != OxideMsg_SendMessage_Error::OK) { |
2691 | if (!error_callback_.is_null()) { |
2692 | - error_callback_.Run(error, args); |
2693 | + error_callback_.Run(error, payload); |
2694 | } |
2695 | } else { |
2696 | if (!reply_callback_.is_null()) { |
2697 | - reply_callback_.Run(args); |
2698 | + reply_callback_.Run(payload); |
2699 | } |
2700 | } |
2701 | } |
2702 | |
2703 | === modified file 'shared/browser/oxide_outgoing_message_request.h' |
2704 | --- shared/browser/oxide_outgoing_message_request.h 2013-11-20 19:02:08 +0000 |
2705 | +++ shared/browser/oxide_outgoing_message_request.h 2014-02-07 16:51:32 +0000 |
2706 | @@ -47,7 +47,7 @@ |
2707 | void SetReplyCallback(const ReplyCallback& callback); |
2708 | void SetErrorCallback(const ErrorCallback& callback); |
2709 | |
2710 | - void OnReceiveResponse(const std::string& args, |
2711 | + void OnReceiveResponse(const std::string& payload, |
2712 | OxideMsg_SendMessage_Error::Value error); |
2713 | |
2714 | private: |
2715 | |
2716 | === modified file 'shared/browser/oxide_web_frame.cc' |
2717 | --- shared/browser/oxide_web_frame.cc 2013-11-20 19:02:08 +0000 |
2718 | +++ shared/browser/oxide_web_frame.cc 2014-02-07 16:51:32 +0000 |
2719 | @@ -17,7 +17,12 @@ |
2720 | |
2721 | #include "oxide_web_frame.h" |
2722 | |
2723 | +#include <map> |
2724 | +#include <utility> |
2725 | + |
2726 | +#include "base/lazy_instance.h" |
2727 | #include "base/logging.h" |
2728 | +#include "content/browser/frame_host/frame_tree_node.h" |
2729 | #include "content/public/browser/render_view_host.h" |
2730 | #include "content/public/browser/web_contents.h" |
2731 | |
2732 | @@ -28,21 +33,27 @@ |
2733 | |
2734 | namespace oxide { |
2735 | |
2736 | -void WebFrame::AddChildFrame(WebFrame* frame) { |
2737 | - DCHECK_NE(frame->identifier(), -1); |
2738 | +namespace { |
2739 | +typedef std::map<int64, WebFrame*> FrameMap; |
2740 | +typedef FrameMap::iterator FrameMapIterator; |
2741 | +base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER; |
2742 | +} |
2743 | |
2744 | +void WebFrame::AddChild(WebFrame* frame) { |
2745 | child_frames_.push_back(frame); |
2746 | OnChildAdded(frame); |
2747 | + view()->FrameAdded(frame); |
2748 | } |
2749 | |
2750 | -void WebFrame::RemoveChildFrame(WebFrame* frame) { |
2751 | +void WebFrame::RemoveChild(WebFrame* frame) { |
2752 | for (ChildVector::iterator it = child_frames_.begin(); |
2753 | it != child_frames_.end(); ++it) { |
2754 | WebFrame* f = *it; |
2755 | |
2756 | if (f == frame) { |
2757 | + OnChildRemoved(frame); |
2758 | + view()->FrameRemoved(frame); |
2759 | child_frames_.erase(it); |
2760 | - OnChildRemoved(frame); |
2761 | return; |
2762 | } |
2763 | } |
2764 | @@ -52,22 +63,33 @@ |
2765 | void WebFrame::OnChildRemoved(WebFrame* child) {} |
2766 | void WebFrame::OnURLChanged() {} |
2767 | |
2768 | -WebFrame::WebFrame() : |
2769 | - id_(-1), |
2770 | +WebFrame::WebFrame( |
2771 | + content::FrameTreeNode* node, |
2772 | + WebView* view) : |
2773 | + frame_tree_node_(node), |
2774 | parent_(NULL), |
2775 | - view_(NULL), |
2776 | + view_(view), |
2777 | next_message_serial_(0), |
2778 | - destroyed_(false), |
2779 | - weak_factory_(this) {} |
2780 | + weak_factory_(this) { |
2781 | + std::pair<FrameMapIterator, bool> rv = |
2782 | + g_frame_map.Get().insert(std::make_pair(node->frame_tree_node_id(), |
2783 | + this)); |
2784 | + CHECK(rv.second); |
2785 | +} |
2786 | |
2787 | WebFrame::~WebFrame() { |
2788 | - DCHECK(destroyed_) << |
2789 | - "WebFrame's destructor must only be called via DestroyFrame"; |
2790 | -} |
2791 | - |
2792 | -void WebFrame::DestroyFrame() { |
2793 | + g_frame_map.Get().erase(frame_tree_node_->frame_tree_node_id()); |
2794 | +} |
2795 | + |
2796 | +// static |
2797 | +WebFrame* WebFrame::FromFrameTreeNode(content::FrameTreeNode* node) { |
2798 | + FrameMapIterator it = g_frame_map.Get().find(node->frame_tree_node_id()); |
2799 | + return it == g_frame_map.Get().end() ? NULL : it->second; |
2800 | +} |
2801 | + |
2802 | +void WebFrame::Destroy() { |
2803 | while (ChildCount() > 0) { |
2804 | - ChildAt(ChildCount() - 1)->DestroyFrame(); |
2805 | + ChildAt(0)->Destroy(); |
2806 | } |
2807 | |
2808 | while (true) { |
2809 | @@ -86,19 +108,21 @@ |
2810 | |
2811 | request->OnReceiveResponse( |
2812 | "The frame disappeared whilst waiting for a response", |
2813 | - OxideMsg_SendMessage_Error::FRAME_DISAPPEARED); |
2814 | + OxideMsg_SendMessage_Error::INVALID_DESTINATION); |
2815 | } |
2816 | |
2817 | if (parent_) { |
2818 | - parent_->RemoveChildFrame(this); |
2819 | + parent_->RemoveChild(this); |
2820 | parent_ = NULL; |
2821 | } |
2822 | |
2823 | - destroyed_ = true; |
2824 | - |
2825 | delete this; |
2826 | } |
2827 | |
2828 | +int64 WebFrame::FrameTreeNodeID() const { |
2829 | + return frame_tree_node()->frame_tree_node_id(); |
2830 | +} |
2831 | + |
2832 | void WebFrame::SetURL(const GURL& url) { |
2833 | url_ = url; |
2834 | OnURLChanged(); |
2835 | @@ -107,7 +131,7 @@ |
2836 | void WebFrame::SetParent(WebFrame* parent) { |
2837 | DCHECK(!parent_) << "Changing parents is not supported"; |
2838 | parent_ = parent; |
2839 | - parent_->AddChildFrame(this); |
2840 | + parent_->AddChild(this); |
2841 | } |
2842 | |
2843 | size_t WebFrame::ChildCount() const { |
2844 | @@ -122,17 +146,9 @@ |
2845 | return child_frames_.at(index); |
2846 | } |
2847 | |
2848 | -void WebFrame::AddChildrenToQueue(std::queue<WebFrame *>* queue) const { |
2849 | - for (ChildVector::const_iterator it = child_frames_.begin(); |
2850 | - it != child_frames_.end(); ++it) { |
2851 | - WebFrame* frame = *it; |
2852 | - queue->push(frame); |
2853 | - } |
2854 | -} |
2855 | - |
2856 | bool WebFrame::SendMessage(const std::string& world_id, |
2857 | const std::string& msg_id, |
2858 | - const std::string& args, |
2859 | + const std::string& payload, |
2860 | OutgoingMessageRequest* req) { |
2861 | DCHECK(req); |
2862 | |
2863 | @@ -141,36 +157,28 @@ |
2864 | req->set_serial(serial); |
2865 | |
2866 | OxideMsg_SendMessage_Params params; |
2867 | - params.frame_id = identifier(); |
2868 | params.world_id = world_id; |
2869 | params.serial = serial; |
2870 | params.type = OxideMsg_SendMessage_Type::Message; |
2871 | params.msg_id = msg_id; |
2872 | - params.args = args; |
2873 | + params.payload = payload; |
2874 | |
2875 | - // FIXME: This is clearly broken for OOPIF |
2876 | - content::WebContents* web_contents = view()->web_contents(); |
2877 | - return web_contents->Send(new OxideMsg_SendMessage( |
2878 | - web_contents->GetRenderViewHost()->GetRoutingID(), |
2879 | - params)); |
2880 | + content::RenderFrameHost* rfh = frame_tree_node()->current_frame_host(); |
2881 | + return rfh->Send(new OxideMsg_SendMessage(rfh->GetRoutingID(), params)); |
2882 | } |
2883 | |
2884 | bool WebFrame::SendMessageNoReply(const std::string& world_id, |
2885 | const std::string& msg_id, |
2886 | - const std::string& args) { |
2887 | + const std::string& payload) { |
2888 | OxideMsg_SendMessage_Params params; |
2889 | - params.frame_id = identifier(); |
2890 | params.world_id = world_id; |
2891 | params.serial = -1; |
2892 | params.type = OxideMsg_SendMessage_Type::Message; |
2893 | params.msg_id = msg_id; |
2894 | - params.args = args; |
2895 | + params.payload = payload; |
2896 | |
2897 | - // FIXME: This is clearly broken for OOPIF |
2898 | - content::WebContents* web_contents = view()->web_contents(); |
2899 | - return web_contents->Send(new OxideMsg_SendMessage( |
2900 | - web_contents->GetRenderViewHost()->GetRoutingID(), |
2901 | - params)); |
2902 | + content::RenderFrameHost* rfh = frame_tree_node()->current_frame_host(); |
2903 | + return rfh->Send(new OxideMsg_SendMessage(rfh->GetRoutingID(), params)); |
2904 | } |
2905 | |
2906 | size_t WebFrame::GetMessageHandlerCount() const { |
2907 | |
2908 | === modified file 'shared/browser/oxide_web_frame.h' |
2909 | --- shared/browser/oxide_web_frame.h 2013-11-20 19:02:08 +0000 |
2910 | +++ shared/browser/oxide_web_frame.h 2014-02-07 16:51:32 +0000 |
2911 | @@ -23,10 +23,15 @@ |
2912 | |
2913 | #include "base/basictypes.h" |
2914 | #include "base/memory/weak_ptr.h" |
2915 | +#include "ipc/ipc_sender.h" |
2916 | #include "url/gurl.h" |
2917 | |
2918 | #include "shared/browser/oxide_message_target.h" |
2919 | |
2920 | +namespace content { |
2921 | +class FrameTreeNode; |
2922 | +} |
2923 | + |
2924 | namespace oxide { |
2925 | |
2926 | class OutgoingMessageRequest; |
2927 | @@ -37,17 +42,11 @@ |
2928 | // of this will typically own a publicly exposed webframe |
2929 | class WebFrame : public MessageTarget { |
2930 | public: |
2931 | - // Use this to delete a WebFrame rather than calling the destructor, so |
2932 | - // that we can remove the frame from its parent before the derived destructor |
2933 | - // is called |
2934 | - void DestroyFrame(); |
2935 | - |
2936 | - int64 identifier() const { |
2937 | - return id_; |
2938 | - } |
2939 | - void set_identifier(int64 id) { |
2940 | - id_ = id; |
2941 | - } |
2942 | + static WebFrame* FromFrameTreeNode(content::FrameTreeNode* node); |
2943 | + |
2944 | + void Destroy(); |
2945 | + |
2946 | + int64 FrameTreeNodeID() const; |
2947 | |
2948 | GURL url() const { |
2949 | return url_; |
2950 | @@ -60,29 +59,28 @@ |
2951 | WebView* view() const { |
2952 | return view_; |
2953 | } |
2954 | - void set_view(WebView* view) { |
2955 | - view_ = view; |
2956 | - } |
2957 | |
2958 | base::WeakPtr<WebFrame> GetWeakPtr() { |
2959 | return weak_factory_.GetWeakPtr(); |
2960 | } |
2961 | |
2962 | + content::FrameTreeNode* frame_tree_node() const { |
2963 | + return frame_tree_node_; |
2964 | + } |
2965 | + |
2966 | void SetURL(const GURL& url); |
2967 | void SetParent(WebFrame* parent); |
2968 | |
2969 | size_t ChildCount() const; |
2970 | WebFrame* ChildAt(size_t index) const; |
2971 | |
2972 | - void AddChildrenToQueue(std::queue<WebFrame *>* queue) const; |
2973 | - |
2974 | bool SendMessage(const std::string& world_id, |
2975 | const std::string& msg_id, |
2976 | - const std::string& args, |
2977 | + const std::string& payload, |
2978 | OutgoingMessageRequest* req); |
2979 | bool SendMessageNoReply(const std::string& world_id, |
2980 | const std::string& msg_id, |
2981 | - const std::string& args); |
2982 | + const std::string& payload); |
2983 | |
2984 | virtual size_t GetMessageHandlerCount() const OVERRIDE; |
2985 | virtual MessageHandler* GetMessageHandlerAt(size_t index) const OVERRIDE; |
2986 | @@ -91,26 +89,25 @@ |
2987 | virtual OutgoingMessageRequest* GetOutgoingMessageRequestAt(size_t index) const; |
2988 | |
2989 | protected: |
2990 | - WebFrame(); |
2991 | + WebFrame(content::FrameTreeNode* node, WebView* view); |
2992 | virtual ~WebFrame(); |
2993 | |
2994 | private: |
2995 | typedef std::vector<WebFrame *> ChildVector; |
2996 | |
2997 | - void AddChildFrame(WebFrame* frame); |
2998 | - void RemoveChildFrame(WebFrame* frame); |
2999 | + void AddChild(WebFrame* frame); |
3000 | + void RemoveChild(WebFrame* frame); |
3001 | |
3002 | virtual void OnChildAdded(WebFrame* child); |
3003 | virtual void OnChildRemoved(WebFrame* child); |
3004 | virtual void OnURLChanged(); |
3005 | |
3006 | - int64 id_; |
3007 | + content::FrameTreeNode* frame_tree_node_; |
3008 | GURL url_; |
3009 | ChildVector child_frames_; |
3010 | WebFrame* parent_; |
3011 | WebView* view_; |
3012 | int next_message_serial_; |
3013 | - bool destroyed_; |
3014 | base::WeakPtrFactory<WebFrame> weak_factory_; |
3015 | |
3016 | DISALLOW_COPY_AND_ASSIGN(WebFrame); |
3017 | |
3018 | === added file 'shared/browser/oxide_web_preferences.cc' |
3019 | --- shared/browser/oxide_web_preferences.cc 1970-01-01 00:00:00 +0000 |
3020 | +++ shared/browser/oxide_web_preferences.cc 2014-02-07 16:51:32 +0000 |
3021 | @@ -0,0 +1,271 @@ |
3022 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
3023 | +// Copyright (C) 2013 Canonical Ltd. |
3024 | + |
3025 | +// This library is free software; you can redistribute it and/or |
3026 | +// modify it under the terms of the GNU Lesser General Public |
3027 | +// License as published by the Free Software Foundation; either |
3028 | +// version 2.1 of the License, or (at your option) any later version. |
3029 | + |
3030 | +// This library is distributed in the hope that it will be useful, |
3031 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
3032 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3033 | +// Lesser General Public License for more details. |
3034 | + |
3035 | +// You should have received a copy of the GNU Lesser General Public |
3036 | +// License along with this library; if not, write to the Free Software |
3037 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
3038 | + |
3039 | +#include "oxide_web_preferences.h" |
3040 | + |
3041 | +#include "base/logging.h" |
3042 | +#include "base/strings/utf_string_conversions.h" |
3043 | +#include "content/public/browser/render_view_host.h" |
3044 | +#include "content/public/browser/web_contents.h" |
3045 | +#include "ui/gl/gl_context.h" |
3046 | +#include "ui/gl/gl_implementation.h" |
3047 | +#include "ui/gl/gl_share_group.h" |
3048 | +#include "webkit/common/webpreferences.h" |
3049 | + |
3050 | +#include "shared/common/oxide_content_client.h" |
3051 | +#include "shared/gl/oxide_shared_gl_context.h" |
3052 | + |
3053 | +#include "oxide_content_browser_client.h" |
3054 | +#include "oxide_web_view.h" |
3055 | + |
3056 | +namespace oxide { |
3057 | + |
3058 | +namespace { |
3059 | + |
3060 | +bool SupportsCompositing() { |
3061 | + gfx::GLShareGroup* group = |
3062 | + ContentClient::instance()->browser()->GetGLShareGroup(); |
3063 | + if (!group) { |
3064 | + return false; |
3065 | + } |
3066 | + |
3067 | + SharedGLContext* context = SharedGLContext::FromGfx(group->GetContext()); |
3068 | + if (!context) { |
3069 | + return false; |
3070 | + } |
3071 | + |
3072 | + return context->GetImplementation() == gfx::GetGLImplementation(); |
3073 | +} |
3074 | + |
3075 | +} // namespace |
3076 | + |
3077 | +void WebPreferences::UpdateViews() { |
3078 | + for (std::set<WebView *>::const_iterator it = views_.begin(); |
3079 | + it != views_.end(); ++it) { |
3080 | + WebView* view = *it; |
3081 | + content::WebContents* contents = view->web_contents(); |
3082 | + if (!contents) { |
3083 | + continue; |
3084 | + } |
3085 | + contents->GetRenderViewHost()->UpdateWebkitPreferences( |
3086 | + contents->GetRenderViewHost()->GetWebkitPreferences()); |
3087 | + } |
3088 | +} |
3089 | + |
3090 | +WebPreferences::WebPreferences() : |
3091 | + standard_font_family_(base::UTF8ToUTF16("Times New Roman")), |
3092 | + fixed_font_family_(base::UTF8ToUTF16("Courier New")), |
3093 | + serif_font_family_(base::UTF8ToUTF16("Times New Roman")), |
3094 | + sans_serif_font_family_(base::UTF8ToUTF16("Arial")), |
3095 | + default_encoding_("ISO-8859-1"), |
3096 | + default_font_size_(16), |
3097 | + default_fixed_font_size_(13), |
3098 | + minimum_font_size_(0) { |
3099 | + for (unsigned int i = 0; i < ATTR_LAST; ++i) { |
3100 | + attributes_[i] = false; |
3101 | + } |
3102 | + |
3103 | + SetAttribute(ATTR_REMOTE_FONTS_ENABLED, true); |
3104 | + SetAttribute(ATTR_JAVASCRIPT_ENABLED, true); |
3105 | + SetAttribute(ATTR_WEB_SECURITY_ENABLED, true); |
3106 | + SetAttribute(ATTR_POPUP_BLOCKER_ENABLED, true); |
3107 | + |
3108 | + // ATTR_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS |
3109 | + // ATTR_JAVASCRIPT_CAN_ACCESS_CLIPBOARD |
3110 | + |
3111 | + SetAttribute(ATTR_HYPERLINK_AUDITING_ENABLED, true); |
3112 | + |
3113 | + // ATTR_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS |
3114 | + // ATTR_ALLOW_FILE_ACCESS_FROM_FILE_URLS |
3115 | + // ATTR_CAN_DISPLAY_INSECURE_CONTENT |
3116 | + // ATTR_CAN_RUN_INSECURE_CONTENT |
3117 | + // ATTR_PASSWORD_ECHO_ENABLED |
3118 | + |
3119 | + SetAttribute(ATTR_LOADS_IMAGES_AUTOMATICALLY, true); |
3120 | + SetAttribute(ATTR_SHRINKS_STANDALONE_IMAGES_TO_FIT, true); |
3121 | + |
3122 | + SetAttribute(ATTR_TEXT_AREAS_ARE_RESIZABLE, true); |
3123 | + |
3124 | + // ATTR_LOCAL_STORAGE_ENABLED |
3125 | + // ATTR_DATABASES_ENABLED |
3126 | + // ATTR_APP_CACHE_ENABLED |
3127 | + // ATTR_FULLSCREEN_ENABLED |
3128 | + |
3129 | + SetAttribute(ATTR_TABS_TO_LINKS, true); |
3130 | + |
3131 | + // ATTR_CARET_BROWSING_ENABLED |
3132 | + |
3133 | + SetAttribute(ATTR_ACCELERATED_COMPOSITING_ENABLED, true); |
3134 | + SetAttribute(ATTR_SMOOTH_SCROLLING_ENABLED, true); |
3135 | + |
3136 | + // ATTR_TOUCH_ENABLED |
3137 | + // ATTR_SUPPORTS_MULTIPLE_WINDOWS |
3138 | + // ATTR_VIEWPORT_ENABLED |
3139 | +} |
3140 | + |
3141 | +WebPreferences::~WebPreferences() { |
3142 | + CHECK(views_.empty()); |
3143 | +} |
3144 | + |
3145 | +std::string WebPreferences::StandardFontFamily() const { |
3146 | + return base::UTF16ToUTF8(standard_font_family_); |
3147 | +} |
3148 | + |
3149 | +void WebPreferences::SetStandardFontFamily(const std::string& font) { |
3150 | + standard_font_family_ = base::UTF8ToUTF16(font); |
3151 | + UpdateViews(); |
3152 | +} |
3153 | + |
3154 | +std::string WebPreferences::FixedFontFamily() const { |
3155 | + return base::UTF16ToUTF8(fixed_font_family_); |
3156 | +} |
3157 | + |
3158 | +void WebPreferences::SetFixedFontFamily(const std::string& font) { |
3159 | + fixed_font_family_ = base::UTF8ToUTF16(font); |
3160 | + UpdateViews(); |
3161 | +} |
3162 | + |
3163 | +std::string WebPreferences::SerifFontFamily() const { |
3164 | + return base::UTF16ToUTF8(serif_font_family_); |
3165 | +} |
3166 | + |
3167 | +void WebPreferences::SetSerifFontFamily(const std::string& font) { |
3168 | + serif_font_family_ = base::UTF8ToUTF16(font); |
3169 | + UpdateViews(); |
3170 | +} |
3171 | + |
3172 | +std::string WebPreferences::SansSerifFontFamily() const { |
3173 | + return base::UTF16ToUTF8(sans_serif_font_family_); |
3174 | +} |
3175 | + |
3176 | +void WebPreferences::SetSansSerifFontFamily(const std::string& font) { |
3177 | + sans_serif_font_family_ = base::UTF8ToUTF16(font); |
3178 | + UpdateViews(); |
3179 | +} |
3180 | + |
3181 | +void WebPreferences::SetDefaultEncoding(const std::string& encoding) { |
3182 | + default_encoding_ = encoding; |
3183 | + UpdateViews(); |
3184 | +} |
3185 | + |
3186 | +void WebPreferences::SetDefaultFontSize(unsigned size) { |
3187 | + default_font_size_ = size; |
3188 | + UpdateViews(); |
3189 | +} |
3190 | + |
3191 | +void WebPreferences::SetDefaultFixedFontSize(unsigned size) { |
3192 | + default_fixed_font_size_ = size; |
3193 | + UpdateViews(); |
3194 | +} |
3195 | + |
3196 | +void WebPreferences::SetMinimumFontSize(unsigned size) { |
3197 | + minimum_font_size_ = size; |
3198 | + UpdateViews(); |
3199 | +} |
3200 | + |
3201 | +bool WebPreferences::TestAttribute(Attr attr) const { |
3202 | + DCHECK(attr < ATTR_LAST && attr >= 0); |
3203 | + return attributes_[attr]; |
3204 | +} |
3205 | + |
3206 | +void WebPreferences::SetAttribute(Attr attr, bool val) { |
3207 | + DCHECK(attr < ATTR_LAST && attr >= 0); |
3208 | + attributes_[attr] = val; |
3209 | + UpdateViews(); |
3210 | +} |
3211 | + |
3212 | +void WebPreferences::AddWebView(WebView* view) { |
3213 | + views_.insert(view); |
3214 | +} |
3215 | + |
3216 | +void WebPreferences::RemoveWebView(WebView* view) { |
3217 | + views_.erase(view); |
3218 | +} |
3219 | + |
3220 | +void WebPreferences::ApplyToWebkitPrefs(::WebPreferences* prefs) { |
3221 | + prefs->standard_font_family_map[webkit_glue::kCommonScript] = |
3222 | + standard_font_family_; |
3223 | + prefs->fixed_font_family_map[webkit_glue::kCommonScript] = |
3224 | + fixed_font_family_; |
3225 | + prefs->serif_font_family_map[webkit_glue::kCommonScript] = |
3226 | + serif_font_family_; |
3227 | + prefs->sans_serif_font_family_map[webkit_glue::kCommonScript] = |
3228 | + sans_serif_font_family_; |
3229 | + |
3230 | + prefs->default_encoding = default_encoding_; |
3231 | + |
3232 | + prefs->default_font_size = default_font_size_; |
3233 | + prefs->default_fixed_font_size = default_fixed_font_size_; |
3234 | + prefs->minimum_font_size = minimum_font_size_; |
3235 | + |
3236 | + prefs->remote_fonts_enabled = attributes_[ATTR_REMOTE_FONTS_ENABLED]; |
3237 | + |
3238 | + prefs->javascript_enabled = attributes_[ATTR_JAVASCRIPT_ENABLED]; |
3239 | + prefs->web_security_enabled = attributes_[ATTR_WEB_SECURITY_ENABLED]; |
3240 | + prefs->javascript_can_open_windows_automatically = |
3241 | + !attributes_[ATTR_POPUP_BLOCKER_ENABLED]; |
3242 | + prefs->allow_scripts_to_close_windows = |
3243 | + attributes_[ATTR_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS]; |
3244 | + prefs->javascript_can_access_clipboard = |
3245 | + attributes_[ATTR_JAVASCRIPT_CAN_ACCESS_CLIPBOARD]; |
3246 | + |
3247 | + prefs->hyperlink_auditing_enabled = |
3248 | + attributes_[ATTR_HYPERLINK_AUDITING_ENABLED]; |
3249 | + prefs->allow_universal_access_from_file_urls = |
3250 | + attributes_[ATTR_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS]; |
3251 | + prefs->allow_file_access_from_file_urls = |
3252 | + attributes_[ATTR_ALLOW_FILE_ACCESS_FROM_FILE_URLS]; |
3253 | + prefs->allow_displaying_insecure_content = |
3254 | + attributes_[ATTR_CAN_DISPLAY_INSECURE_CONTENT]; |
3255 | + prefs->allow_running_insecure_content = |
3256 | + attributes_[ATTR_CAN_RUN_INSECURE_CONTENT]; |
3257 | + prefs->password_echo_enabled = attributes_[ATTR_PASSWORD_ECHO_ENABLED]; |
3258 | + |
3259 | + prefs->loads_images_automatically = |
3260 | + attributes_[ATTR_LOADS_IMAGES_AUTOMATICALLY]; |
3261 | + prefs->shrinks_standalone_images_to_fit = |
3262 | + attributes_[ATTR_SHRINKS_STANDALONE_IMAGES_TO_FIT]; |
3263 | + |
3264 | + prefs->text_areas_are_resizable = attributes_[ATTR_TEXT_AREAS_ARE_RESIZABLE]; |
3265 | + |
3266 | + prefs->local_storage_enabled = attributes_[ATTR_LOCAL_STORAGE_ENABLED]; |
3267 | + prefs->databases_enabled = attributes_[ATTR_DATABASES_ENABLED]; |
3268 | + prefs->application_cache_enabled = attributes_[ATTR_APP_CACHE_ENABLED]; |
3269 | + prefs->fullscreen_enabled = attributes_[ATTR_FULLSCREEN_ENABLED]; |
3270 | + |
3271 | + prefs->tabs_to_links = attributes_[ATTR_TABS_TO_LINKS]; |
3272 | + prefs->caret_browsing_enabled = attributes_[ATTR_CARET_BROWSING_ENABLED]; |
3273 | + |
3274 | + bool compositing = |
3275 | + attributes_[ATTR_ACCELERATED_COMPOSITING_ENABLED] && |
3276 | + SupportsCompositing(); |
3277 | + prefs->accelerated_compositing_enabled = compositing; |
3278 | + prefs->force_compositing_mode = compositing; |
3279 | + |
3280 | + prefs->enable_scroll_animator = attributes_[ATTR_SMOOTH_SCROLLING_ENABLED]; |
3281 | + |
3282 | + prefs->touch_enabled = false; // TODO: Check if touch is supported |
3283 | + |
3284 | + prefs->supports_multiple_windows = attributes_[ATTR_SUPPORTS_MULTIPLE_WINDOWS]; |
3285 | + |
3286 | + // Viewport only works in compositing mode |
3287 | + prefs->viewport_enabled = attributes_[ATTR_VIEWPORT_ENABLED] && compositing; |
3288 | + // XXX: Should this be a separate pref? |
3289 | + prefs->viewport_meta_enabled = prefs->viewport_enabled; |
3290 | +} |
3291 | + |
3292 | +} // namespace oxide |
3293 | |
3294 | === added file 'shared/browser/oxide_web_preferences.h' |
3295 | --- shared/browser/oxide_web_preferences.h 1970-01-01 00:00:00 +0000 |
3296 | +++ shared/browser/oxide_web_preferences.h 2014-02-07 16:51:32 +0000 |
3297 | @@ -0,0 +1,138 @@ |
3298 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
3299 | +// Copyright (C) 2013 Canonical Ltd. |
3300 | + |
3301 | +// This library is free software; you can redistribute it and/or |
3302 | +// modify it under the terms of the GNU Lesser General Public |
3303 | +// License as published by the Free Software Foundation; either |
3304 | +// version 2.1 of the License, or (at your option) any later version. |
3305 | + |
3306 | +// This library is distributed in the hope that it will be useful, |
3307 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
3308 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3309 | +// Lesser General Public License for more details. |
3310 | + |
3311 | +// You should have received a copy of the GNU Lesser General Public |
3312 | +// License along with this library; if not, write to the Free Software |
3313 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
3314 | + |
3315 | +#ifndef _OXIDE_SHARED_BROWSER_WEB_PREFERENCES_H_ |
3316 | +#define _OXIDE_SHARED_BROWSER_WEB_PREFERENCES_H_ |
3317 | + |
3318 | +#include <set> |
3319 | +#include <string> |
3320 | + |
3321 | +#include "base/basictypes.h" |
3322 | +#include "base/compiler_specific.h" |
3323 | +#include "base/strings/string16.h" |
3324 | + |
3325 | +class WebPreferences; |
3326 | + |
3327 | +namespace oxide { |
3328 | + |
3329 | +class WebView; |
3330 | + |
3331 | +class WebPreferences { |
3332 | + public: |
3333 | + WebPreferences(); |
3334 | + virtual ~WebPreferences(); |
3335 | + |
3336 | + enum Attr { |
3337 | + ATTR_REMOTE_FONTS_ENABLED, |
3338 | + |
3339 | + ATTR_JAVASCRIPT_ENABLED, |
3340 | + ATTR_WEB_SECURITY_ENABLED, |
3341 | + ATTR_POPUP_BLOCKER_ENABLED, |
3342 | + ATTR_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS, |
3343 | + ATTR_JAVASCRIPT_CAN_ACCESS_CLIPBOARD, |
3344 | + |
3345 | + ATTR_HYPERLINK_AUDITING_ENABLED, // enables anchor ping |
3346 | + ATTR_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS, |
3347 | + ATTR_ALLOW_FILE_ACCESS_FROM_FILE_URLS, |
3348 | + ATTR_CAN_DISPLAY_INSECURE_CONTENT, // Passive mixed-content blocking |
3349 | + ATTR_CAN_RUN_INSECURE_CONTENT, // Active mixed-content blocking |
3350 | + ATTR_PASSWORD_ECHO_ENABLED, |
3351 | + |
3352 | + ATTR_LOADS_IMAGES_AUTOMATICALLY, |
3353 | + ATTR_SHRINKS_STANDALONE_IMAGES_TO_FIT, |
3354 | + |
3355 | + ATTR_TEXT_AREAS_ARE_RESIZABLE, |
3356 | + |
3357 | + ATTR_LOCAL_STORAGE_ENABLED, |
3358 | + ATTR_DATABASES_ENABLED, |
3359 | + ATTR_APP_CACHE_ENABLED, |
3360 | + ATTR_FULLSCREEN_ENABLED, |
3361 | + |
3362 | + ATTR_TABS_TO_LINKS, // whether pressing |TAB\ focuses links |
3363 | + ATTR_CARET_BROWSING_ENABLED, |
3364 | + |
3365 | + ATTR_ACCELERATED_COMPOSITING_ENABLED, |
3366 | + ATTR_SMOOTH_SCROLLING_ENABLED, |
3367 | + ATTR_TOUCH_ENABLED, |
3368 | + ATTR_SUPPORTS_MULTIPLE_WINDOWS, |
3369 | + ATTR_VIEWPORT_ENABLED, |
3370 | + |
3371 | + ATTR_LAST |
3372 | + }; |
3373 | + |
3374 | + std::string StandardFontFamily() const; |
3375 | + void SetStandardFontFamily(const std::string& font); |
3376 | + |
3377 | + std::string FixedFontFamily() const; |
3378 | + void SetFixedFontFamily(const std::string& font); |
3379 | + |
3380 | + std::string SerifFontFamily() const; |
3381 | + void SetSerifFontFamily(const std::string& font); |
3382 | + |
3383 | + std::string SansSerifFontFamily() const; |
3384 | + void SetSansSerifFontFamily(const std::string& font); |
3385 | + |
3386 | + std::string default_encoding() const { |
3387 | + return default_encoding_; |
3388 | + } |
3389 | + void SetDefaultEncoding(const std::string& encoding); |
3390 | + |
3391 | + unsigned default_font_size() const { |
3392 | + return default_font_size_; |
3393 | + } |
3394 | + void SetDefaultFontSize(unsigned size); |
3395 | + |
3396 | + unsigned default_fixed_font_size() const { |
3397 | + return default_fixed_font_size_; |
3398 | + } |
3399 | + void SetDefaultFixedFontSize(unsigned size); |
3400 | + |
3401 | + unsigned minimum_font_size() const { |
3402 | + return minimum_font_size_; |
3403 | + } |
3404 | + void SetMinimumFontSize(unsigned size); |
3405 | + |
3406 | + bool TestAttribute(Attr attr) const; |
3407 | + void SetAttribute(Attr attr, bool val); |
3408 | + |
3409 | + void AddWebView(WebView* view); |
3410 | + void RemoveWebView(WebView* view); |
3411 | + |
3412 | + void ApplyToWebkitPrefs(::WebPreferences* prefs); |
3413 | + |
3414 | + private: |
3415 | + void UpdateViews(); |
3416 | + |
3417 | + base::string16 standard_font_family_; |
3418 | + base::string16 fixed_font_family_; |
3419 | + base::string16 serif_font_family_; |
3420 | + base::string16 sans_serif_font_family_; |
3421 | + std::string default_encoding_; |
3422 | + unsigned default_font_size_; |
3423 | + unsigned default_fixed_font_size_; |
3424 | + unsigned minimum_font_size_; |
3425 | + |
3426 | + bool attributes_[ATTR_LAST]; |
3427 | + |
3428 | + std::set<WebView *> views_; |
3429 | + |
3430 | + DISALLOW_COPY_AND_ASSIGN(WebPreferences); |
3431 | +}; |
3432 | + |
3433 | +} // namespace oxide |
3434 | + |
3435 | +#endif // _OXIDE_SHARED_BROWSER_WEB_PREFERENCES_H_ |
3436 | |
3437 | === modified file 'shared/browser/oxide_web_view.cc' |
3438 | --- shared/browser/oxide_web_view.cc 2014-01-20 12:35:23 +0000 |
3439 | +++ shared/browser/oxide_web_view.cc 2014-02-07 16:51:32 +0000 |
3440 | @@ -21,7 +21,10 @@ |
3441 | |
3442 | #include "base/logging.h" |
3443 | #include "base/strings/utf_string_conversions.h" |
3444 | +#include "content/browser/frame_host/frame_tree.h" |
3445 | +#include "content/browser/frame_host/frame_tree_node.h" |
3446 | #include "content/browser/renderer_host/render_view_host_impl.h" |
3447 | +#include "content/browser/web_contents/web_contents_impl.h" |
3448 | #include "content/public/browser/invalidate_type.h" |
3449 | #include "content/public/browser/browser_context.h" |
3450 | #include "content/public/browser/navigation_controller.h" |
3451 | @@ -32,22 +35,21 @@ |
3452 | #include "content/public/browser/notification_service.h" |
3453 | #include "content/public/browser/notification_source.h" |
3454 | #include "content/public/browser/notification_types.h" |
3455 | +#include "content/public/browser/render_view_host.h" |
3456 | #include "content/public/browser/web_contents.h" |
3457 | #include "content/public/browser/web_contents_view.h" |
3458 | #include "net/base/net_errors.h" |
3459 | #include "url/gurl.h" |
3460 | +#include "webkit/common/webpreferences.h" |
3461 | |
3462 | #include "shared/common/oxide_content_client.h" |
3463 | -#include "shared/common/oxide_messages.h" |
3464 | |
3465 | #include "oxide_browser_context.h" |
3466 | #include "oxide_browser_process_main.h" |
3467 | #include "oxide_content_browser_client.h" |
3468 | -#include "oxide_incoming_message.h" |
3469 | -#include "oxide_message_handler.h" |
3470 | -#include "oxide_outgoing_message_request.h" |
3471 | #include "oxide_web_contents_view.h" |
3472 | #include "oxide_web_frame.h" |
3473 | +#include "oxide_web_preferences.h" |
3474 | |
3475 | namespace oxide { |
3476 | |
3477 | @@ -87,123 +89,12 @@ |
3478 | } |
3479 | } |
3480 | |
3481 | -void WebView::SendErrorForV8Message(long long frame_id, |
3482 | - const std::string& world_id, |
3483 | - int serial, |
3484 | - OxideMsg_SendMessage_Error::Value error_code, |
3485 | - const std::string& error_desc) { |
3486 | - OxideMsg_SendMessage_Params params; |
3487 | - params.frame_id = frame_id; |
3488 | - params.world_id = world_id; |
3489 | - params.serial = serial; |
3490 | - params.type = OxideMsg_SendMessage_Type::Reply; |
3491 | - params.error = error_code; |
3492 | - params.args = error_desc; |
3493 | - |
3494 | - // FIXME: This is clearly broken for OOPIF, and we don't even know if this |
3495 | - // is going to the correct RVH without OOPIF |
3496 | - web_contents()->Send(new OxideMsg_SendMessage( |
3497 | - web_contents()->GetRenderViewHost()->GetRoutingID(), |
3498 | - params)); |
3499 | -} |
3500 | - |
3501 | -bool WebView::TryDispatchV8MessageToTarget(MessageTarget* target, |
3502 | - WebFrame* source_frame, |
3503 | - const std::string& world_id, |
3504 | - int serial, |
3505 | - const std::string& msg_id, |
3506 | - const std::string& args) { |
3507 | - for (size_t i = 0; i < target->GetMessageHandlerCount(); ++i) { |
3508 | - MessageHandler* handler = target->GetMessageHandlerAt(i); |
3509 | - |
3510 | - if (!handler->IsValid()) { |
3511 | - continue; |
3512 | - } |
3513 | - |
3514 | - if (handler->msg_id() != msg_id) { |
3515 | - continue; |
3516 | - } |
3517 | - |
3518 | - const std::vector<std::string>& world_ids = handler->world_ids(); |
3519 | - |
3520 | - for (std::vector<std::string>::const_iterator it = world_ids.begin(); |
3521 | - it != world_ids.end(); ++it) { |
3522 | - if ((*it) == world_id) { |
3523 | - handler->OnReceiveMessage( |
3524 | - new IncomingMessage(source_frame, serial, world_id, |
3525 | - msg_id, args)); |
3526 | - return true; |
3527 | - } |
3528 | - } |
3529 | - } |
3530 | - |
3531 | - return false; |
3532 | -} |
3533 | - |
3534 | -void WebView::DispatchV8Message(const OxideMsg_SendMessage_Params& params) { |
3535 | - WebFrame* frame = FindFrameWithID(params.frame_id); |
3536 | - |
3537 | - if (params.type == OxideMsg_SendMessage_Type::Message) { |
3538 | - if (!frame) { |
3539 | - // FIXME: In an OOPIF world, how do we know which process to dispatch |
3540 | - // this error too, if we couldn't find a frame? |
3541 | - SendErrorForV8Message(params.frame_id, params.world_id, params.serial, |
3542 | - OxideMsg_SendMessage_Error::INVALID_DESTINATION, |
3543 | - "Invalid frame ID"); |
3544 | - return; |
3545 | - } |
3546 | - |
3547 | - if (!TryDispatchV8MessageToTarget(frame, frame, params.world_id, |
3548 | - params.serial, params.msg_id, |
3549 | - params.args)) { |
3550 | - if (!TryDispatchV8MessageToTarget(this, frame, params.world_id, |
3551 | - params.serial, params.msg_id, |
3552 | - params.args)) { |
3553 | - SendErrorForV8Message(params.frame_id, params.world_id, params.serial, |
3554 | - OxideMsg_SendMessage_Error::NO_HANDLER, |
3555 | - "No handler was found for message"); |
3556 | - } |
3557 | - } |
3558 | - |
3559 | - return; |
3560 | - } |
3561 | - |
3562 | - if (!frame) { |
3563 | - return; |
3564 | - } |
3565 | - |
3566 | - for (size_t i = 0; i < frame->GetOutgoingMessageRequestCount(); ++i) { |
3567 | - OutgoingMessageRequest* request = frame->GetOutgoingMessageRequestAt(i); |
3568 | - |
3569 | - if (request->serial() == params.serial) { |
3570 | - request->OnReceiveResponse(params.args, params.error); |
3571 | - return; |
3572 | - } |
3573 | - } |
3574 | -} |
3575 | - |
3576 | -void WebView::OnFrameCreated(int64 parent_frame_id, |
3577 | - int64 frame_id) { |
3578 | - WebFrame* parent = FindFrameWithID(parent_frame_id); |
3579 | - if (!parent) { |
3580 | - LOG(ERROR) << "Got FrameCreated with non-existant parent"; |
3581 | - return; |
3582 | - } |
3583 | - |
3584 | - WebFrame* frame = CreateWebFrame(); |
3585 | - frame->set_identifier(frame_id); |
3586 | - frame->set_view(this); |
3587 | - frame->SetParent(parent); |
3588 | -} |
3589 | - |
3590 | void WebView::OnURLChanged() {} |
3591 | void WebView::OnTitleChanged() {} |
3592 | void WebView::OnCommandsUpdated() {} |
3593 | |
3594 | void WebView::OnLoadProgressChanged(double progress) {} |
3595 | |
3596 | -void WebView::OnRootFrameChanged() {} |
3597 | - |
3598 | void WebView::OnLoadStarted(const GURL& validated_url, |
3599 | bool is_error_frame) {} |
3600 | void WebView::OnLoadStopped(const GURL& validated_url) {} |
3601 | @@ -217,9 +108,14 @@ |
3602 | void WebView::OnNavigationEntryChanged(int index) {} |
3603 | |
3604 | WebView::WebView() : |
3605 | - root_frame_(NULL) {} |
3606 | + root_frame_(NULL), |
3607 | + web_preferences_(NULL) {} |
3608 | |
3609 | WebView::~WebView() { |
3610 | + if (web_preferences_) { |
3611 | + web_preferences_->RemoveWebView(this); |
3612 | + } |
3613 | + |
3614 | if (web_contents_) { |
3615 | GetBrowserContext()->RemoveWebView(this); |
3616 | web_contents_->SetDelegate(NULL); |
3617 | @@ -244,7 +140,8 @@ |
3618 | |
3619 | content::WebContents::CreateParams params(context); |
3620 | params.initial_size = initial_size; |
3621 | - web_contents_.reset(content::WebContents::Create(params)); |
3622 | + web_contents_.reset(static_cast<content::WebContentsImpl *>( |
3623 | + content::WebContents::Create(params))); |
3624 | if (!web_contents_) { |
3625 | LOG(ERROR) << "Failed to create WebContents"; |
3626 | return false; |
3627 | @@ -259,6 +156,8 @@ |
3628 | registrar_->Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED, |
3629 | content::NotificationService::AllBrowserContextsAndSources()); |
3630 | |
3631 | + root_frame_ = CreateWebFrame(web_contents_->GetFrameTree()->root()); |
3632 | + |
3633 | return true; |
3634 | } |
3635 | |
3636 | @@ -272,10 +171,8 @@ |
3637 | |
3638 | WebContentsObserver::Observe(NULL); |
3639 | |
3640 | - if (root_frame_) { |
3641 | - root_frame_->DestroyFrame(); |
3642 | - root_frame_ = NULL; |
3643 | - } |
3644 | + root_frame_->Destroy(); |
3645 | + root_frame_ = NULL; |
3646 | |
3647 | GetBrowserContext()->RemoveWebView(this); |
3648 | web_contents_.reset(); |
3649 | @@ -382,6 +279,10 @@ |
3650 | return BrowserContext::FromContent(web_contents_->GetBrowserContext()); |
3651 | } |
3652 | |
3653 | +content::WebContents* WebView::GetWebContents() const { |
3654 | + return web_contents_.get(); |
3655 | +} |
3656 | + |
3657 | int WebView::GetNavigationEntryCount() const { |
3658 | if (!web_contents_) { |
3659 | return 0; |
3660 | @@ -442,11 +343,7 @@ |
3661 | return root_frame_; |
3662 | } |
3663 | |
3664 | -WebFrame* WebView::FindFrameWithID(int64 frame_id) const { |
3665 | - if (!root_frame_) { |
3666 | - return NULL; |
3667 | - } |
3668 | - |
3669 | +WebFrame* WebView::FindFrameWithID(int64 frame_tree_node_id) const { |
3670 | std::queue<WebFrame *> q; |
3671 | q.push(const_cast<WebFrame *>(root_frame_)); |
3672 | |
3673 | @@ -454,20 +351,51 @@ |
3674 | WebFrame* f = q.front(); |
3675 | q.pop(); |
3676 | |
3677 | - if (f->identifier() == frame_id) { |
3678 | + if (f->FrameTreeNodeID() == frame_tree_node_id) { |
3679 | return f; |
3680 | } |
3681 | |
3682 | - f->AddChildrenToQueue(&q); |
3683 | + for (size_t i = 0; i < f->ChildCount(); ++i) { |
3684 | + q.push(f->ChildAt(i)); |
3685 | + } |
3686 | } |
3687 | |
3688 | return NULL; |
3689 | } |
3690 | |
3691 | +WebPreferences* WebView::GetWebPreferences() { |
3692 | + if (!web_preferences_) { |
3693 | + SetWebPreferences( |
3694 | + ContentClient::instance()->browser()->GetDefaultWebPreferences(), |
3695 | + false); |
3696 | + } |
3697 | + |
3698 | + return web_preferences_; |
3699 | +} |
3700 | + |
3701 | +void WebView::SetWebPreferences(WebPreferences* prefs, bool send_update) { |
3702 | + if (web_preferences_) { |
3703 | + web_preferences_->RemoveWebView(this); |
3704 | + } |
3705 | + |
3706 | + web_preferences_ = prefs; |
3707 | + if (prefs) { |
3708 | + prefs->AddWebView(this); |
3709 | + } |
3710 | + |
3711 | + if (!send_update || !web_contents_) { |
3712 | + return; |
3713 | + } |
3714 | + |
3715 | + web_contents()->GetRenderViewHost()->UpdateWebkitPreferences( |
3716 | + web_contents()->GetRenderViewHost()->GetWebkitPreferences()); |
3717 | +} |
3718 | + |
3719 | void WebView::Observe(int type, |
3720 | const content::NotificationSource& source, |
3721 | const content::NotificationDetails& details) { |
3722 | - if (content::Source<content::NavigationController>(source).ptr() != &web_contents()->GetController()) { |
3723 | + if (content::Source<content::NavigationController>(source).ptr() != |
3724 | + &GetWebContents()->GetController()) { |
3725 | return; |
3726 | } |
3727 | if (type == content::NOTIFICATION_NAV_LIST_PRUNED) { |
3728 | @@ -482,21 +410,12 @@ |
3729 | void WebView::RenderViewHostChanged(content::RenderViewHost* old_host, |
3730 | content::RenderViewHost* new_host) { |
3731 | // Make sure the new RWHV gets the correct size |
3732 | - web_contents()->GetView()->SizeContents( |
3733 | - web_contents()->GetView()->GetContainerSize()); |
3734 | - |
3735 | - if (root_frame_) { |
3736 | - root_frame_->DestroyFrame(); |
3737 | - } |
3738 | - |
3739 | - if (new_host) { |
3740 | - root_frame_ = CreateWebFrame(); |
3741 | - root_frame_->set_view(this); |
3742 | - } else { |
3743 | - root_frame_ = NULL; |
3744 | - } |
3745 | - |
3746 | - OnRootFrameChanged(); |
3747 | + GetWebContents()->GetView()->SizeContents( |
3748 | + GetWebContents()->GetView()->GetContainerSize()); |
3749 | + |
3750 | + while (root_frame_->ChildCount() > 0) { |
3751 | + root_frame_->ChildAt(0)->Destroy(); |
3752 | + } |
3753 | } |
3754 | |
3755 | void WebView::DidStartProvisionalLoadForFrame( |
3756 | @@ -521,11 +440,11 @@ |
3757 | const GURL& url, |
3758 | content::PageTransition transition_type, |
3759 | content::RenderViewHost* render_view_host) { |
3760 | - if (is_main_frame) { |
3761 | - root_frame_->set_identifier(frame_id); |
3762 | - } |
3763 | + content::FrameTreeNode* node = |
3764 | + web_contents_->GetFrameTree()->FindByFrameID(frame_id); |
3765 | + DCHECK(node); |
3766 | |
3767 | - WebFrame* frame = FindFrameWithID(frame_id); |
3768 | + WebFrame* frame = FindFrameWithID(node->frame_tree_node_id()); |
3769 | if (frame) { |
3770 | frame->SetURL(url); |
3771 | } |
3772 | @@ -577,12 +496,43 @@ |
3773 | |
3774 | void WebView::FrameDetached(content::RenderViewHost* rvh, |
3775 | int64 frame_id) { |
3776 | - WebFrame* frame = FindFrameWithID(frame_id); |
3777 | - if (!frame) { |
3778 | - return; |
3779 | - } |
3780 | - |
3781 | - frame->DestroyFrame(); |
3782 | + if (!root_frame_) { |
3783 | + return; |
3784 | + } |
3785 | + |
3786 | + // XXX: This is temporary until there's a better API for these events |
3787 | + // The ID we have is only renderer-process unique |
3788 | + content::FrameTreeNode* node = |
3789 | + web_contents_->GetFrameTree()->FindByFrameID(frame_id); |
3790 | + DCHECK(node); |
3791 | + |
3792 | + WebFrame* frame = FindFrameWithID(node->frame_tree_node_id()); |
3793 | + DCHECK(frame); |
3794 | + |
3795 | + frame->Destroy(); |
3796 | +} |
3797 | + |
3798 | +void WebView::FrameAttached(content::RenderViewHost* rvh, |
3799 | + int64 parent_frame_id, |
3800 | + int64 frame_id) { |
3801 | + if (!root_frame_) { |
3802 | + return; |
3803 | + } |
3804 | + |
3805 | + // XXX: This is temporary until there's a better API for these events |
3806 | + // The ID's we have are only renderer-process unique |
3807 | + content::FrameTree* tree = web_contents_->GetFrameTree(); |
3808 | + content::FrameTreeNode* parent_node = tree->FindByFrameID(parent_frame_id); |
3809 | + content::FrameTreeNode* node = tree->FindByFrameID(frame_id); |
3810 | + |
3811 | + DCHECK(parent_node && node); |
3812 | + |
3813 | + WebFrame* parent = FindFrameWithID(parent_node->frame_tree_node_id()); |
3814 | + DCHECK(parent); |
3815 | + |
3816 | + WebFrame* frame = CreateWebFrame(node); |
3817 | + DCHECK(frame); |
3818 | + frame->SetParent(parent); |
3819 | } |
3820 | |
3821 | void WebView::TitleWasSet(content::NavigationEntry* entry, bool explicit_set) { |
3822 | @@ -599,17 +549,6 @@ |
3823 | } |
3824 | } |
3825 | |
3826 | -bool WebView::OnMessageReceived(const IPC::Message& message) { |
3827 | - bool handled = true; |
3828 | - IPC_BEGIN_MESSAGE_MAP(WebView, message) |
3829 | - IPC_MESSAGE_HANDLER(OxideHostMsg_SendMessage, DispatchV8Message) |
3830 | - IPC_MESSAGE_HANDLER(OxideHostMsg_FrameCreated, OnFrameCreated) |
3831 | - IPC_MESSAGE_UNHANDLED(handled = false) |
3832 | - IPC_END_MESSAGE_MAP() |
3833 | - |
3834 | - return handled; |
3835 | -} |
3836 | - |
3837 | size_t WebView::GetMessageHandlerCount() const { |
3838 | return 0; |
3839 | } |
3840 | @@ -622,4 +561,7 @@ |
3841 | return NULL; |
3842 | } |
3843 | |
3844 | +void WebView::FrameAdded(WebFrame* frame) {} |
3845 | +void WebView::FrameRemoved(WebFrame* frame) {} |
3846 | + |
3847 | } // namespace oxide |
3848 | |
3849 | === modified file 'shared/browser/oxide_web_view.h' |
3850 | --- shared/browser/oxide_web_view.h 2014-01-20 12:35:23 +0000 |
3851 | +++ shared/browser/oxide_web_view.h 2014-02-07 16:51:32 +0000 |
3852 | @@ -32,8 +32,6 @@ |
3853 | #include "shared/browser/oxide_message_target.h" |
3854 | #include "shared/common/oxide_message_enums.h" |
3855 | |
3856 | -struct OxideMsg_SendMessage_Params; |
3857 | - |
3858 | class GURL; |
3859 | |
3860 | namespace gfx { |
3861 | @@ -42,11 +40,13 @@ |
3862 | |
3863 | namespace content { |
3864 | |
3865 | +class FrameTreeNode; |
3866 | class NotificationRegistrar; |
3867 | struct OpenURLParams; |
3868 | class RenderWidgetHost; |
3869 | class RenderWidgetHostView; |
3870 | class WebContents; |
3871 | +class WebContentsImpl; |
3872 | |
3873 | } // namespace content |
3874 | |
3875 | @@ -55,6 +55,7 @@ |
3876 | class BrowserContext; |
3877 | class WebFrame; |
3878 | class WebPopupMenu; |
3879 | +class WebPreferences; |
3880 | |
3881 | // This is the main webview class. Implementations should subclass |
3882 | // this. Note that this class will hold the main browser process |
3883 | @@ -96,6 +97,7 @@ |
3884 | void Hidden(); |
3885 | |
3886 | BrowserContext* GetBrowserContext() const; |
3887 | + content::WebContents* GetWebContents() const; |
3888 | |
3889 | int GetNavigationEntryCount() const; |
3890 | int GetNavigationCurrentEntryIndex() const; |
3891 | @@ -106,7 +108,10 @@ |
3892 | base::Time GetNavigationEntryTimestamp(int index) const; |
3893 | |
3894 | WebFrame* GetRootFrame() const; |
3895 | - WebFrame* FindFrameWithID(int64 frame_id) const; |
3896 | + WebFrame* FindFrameWithID(int64 frame_tree_node_id) const; |
3897 | + |
3898 | + WebPreferences* GetWebPreferences(); |
3899 | + void SetWebPreferences(WebPreferences* prefs, bool send_update = true); |
3900 | |
3901 | void Observe(int type, |
3902 | const content::NotificationSource& source, |
3903 | @@ -157,18 +162,14 @@ |
3904 | |
3905 | void FrameDetached(content::RenderViewHost* rvh, |
3906 | int64 frame_id) FINAL; |
3907 | + void FrameAttached(content::RenderViewHost* rvh, |
3908 | + int64 parent_frame_id, int64 frame_id) FINAL; |
3909 | |
3910 | void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) FINAL; |
3911 | |
3912 | - bool OnMessageReceived(const IPC::Message& message) FINAL; |
3913 | - |
3914 | virtual size_t GetMessageHandlerCount() const OVERRIDE; |
3915 | virtual MessageHandler* GetMessageHandlerAt(size_t index) const OVERRIDE; |
3916 | |
3917 | - content::WebContents* web_contents() const { |
3918 | - return web_contents_.get(); |
3919 | - } |
3920 | - |
3921 | virtual content::RenderWidgetHostView* CreateViewForWidget( |
3922 | content::RenderWidgetHost* render_widget_host) = 0; |
3923 | |
3924 | @@ -176,6 +177,9 @@ |
3925 | |
3926 | virtual WebPopupMenu* CreatePopupMenu(content::RenderViewHost* rvh); |
3927 | |
3928 | + virtual void FrameAdded(WebFrame* frame); |
3929 | + virtual void FrameRemoved(WebFrame* frame); |
3930 | + |
3931 | protected: |
3932 | WebView(); |
3933 | |
3934 | @@ -189,29 +193,12 @@ |
3935 | int error_code, |
3936 | const base::string16& error_description); |
3937 | |
3938 | - void SendErrorForV8Message(long long frame_id, |
3939 | - const std::string& world_id, |
3940 | - int serial, |
3941 | - OxideMsg_SendMessage_Error::Value error_code, |
3942 | - const std::string& error_desc); |
3943 | - bool TryDispatchV8MessageToTarget(MessageTarget* target, |
3944 | - WebFrame* source_frame, |
3945 | - const std::string& world_id, |
3946 | - int serial, |
3947 | - const std::string& msg_id, |
3948 | - const std::string& args); |
3949 | - void DispatchV8Message(const OxideMsg_SendMessage_Params& params); |
3950 | - |
3951 | - void OnFrameCreated(int64 parent_frame_id, int64 frame_id); |
3952 | - |
3953 | virtual void OnURLChanged(); |
3954 | virtual void OnTitleChanged(); |
3955 | virtual void OnCommandsUpdated(); |
3956 | |
3957 | virtual void OnLoadProgressChanged(double progress); |
3958 | |
3959 | - virtual void OnRootFrameChanged(); |
3960 | - |
3961 | virtual void OnLoadStarted(const GURL& validated_url, |
3962 | bool is_error_frame); |
3963 | virtual void OnLoadStopped(const GURL& validated_url); |
3964 | @@ -224,12 +211,14 @@ |
3965 | virtual void OnNavigationListPruned(bool from_front, int count); |
3966 | virtual void OnNavigationEntryChanged(int index); |
3967 | |
3968 | - virtual WebFrame* CreateWebFrame() = 0; |
3969 | - |
3970 | - scoped_ptr<content::WebContents> web_contents_; |
3971 | + virtual WebFrame* CreateWebFrame(content::FrameTreeNode* node) = 0; |
3972 | + |
3973 | + scoped_ptr<content::WebContentsImpl> web_contents_; |
3974 | + scoped_ptr<content::NotificationRegistrar> registrar_; |
3975 | + |
3976 | WebFrame* root_frame_; |
3977 | |
3978 | - scoped_ptr<content::NotificationRegistrar> registrar_; |
3979 | + WebPreferences* web_preferences_; |
3980 | |
3981 | DISALLOW_COPY_AND_ASSIGN(WebView); |
3982 | }; |
3983 | |
3984 | === modified file 'shared/common/oxide_message_enums.h' |
3985 | --- shared/common/oxide_message_enums.h 2013-11-20 19:04:45 +0000 |
3986 | +++ shared/common/oxide_message_enums.h 2014-02-07 16:51:32 +0000 |
3987 | @@ -44,13 +44,8 @@ |
3988 | // No handler was registered for this message |
3989 | NO_HANDLER, |
3990 | |
3991 | - // The handler reported an error |
3992 | - HANDLER_REPORTED_ERROR, |
3993 | - |
3994 | - // The frame disappeared before sending a response was sent |
3995 | - // (only valid for embedder to content script messages, and |
3996 | - // never actually sent across the wire) |
3997 | - FRAME_DISAPPEARED, |
3998 | + // The handler reported an error via the error() function |
3999 | + HANDLER_REPORTED_ERROR |
4000 | }; |
4001 | }; |
4002 | |
4003 | |
4004 | === modified file 'shared/common/oxide_messages.h' |
4005 | --- shared/common/oxide_messages.h 2013-11-20 19:02:08 +0000 |
4006 | +++ shared/common/oxide_messages.h 2014-02-07 16:51:32 +0000 |
4007 | @@ -27,13 +27,12 @@ |
4008 | IPC_ENUM_TRAITS(OxideMsg_SendMessage_Error::Value) |
4009 | |
4010 | IPC_STRUCT_BEGIN(OxideMsg_SendMessage_Params) |
4011 | - IPC_STRUCT_MEMBER(long long, frame_id) |
4012 | IPC_STRUCT_MEMBER(std::string, world_id) |
4013 | IPC_STRUCT_MEMBER(int, serial) |
4014 | IPC_STRUCT_MEMBER(OxideMsg_SendMessage_Type::Value, type) |
4015 | IPC_STRUCT_MEMBER(OxideMsg_SendMessage_Error::Value, error) |
4016 | IPC_STRUCT_MEMBER(std::string, msg_id) |
4017 | - IPC_STRUCT_MEMBER(std::string, args) |
4018 | + IPC_STRUCT_MEMBER(std::string, payload) |
4019 | IPC_STRUCT_END() |
4020 | |
4021 | #define IPC_MESSAGE_START OxideMsgStart |
4022 | |
4023 | === modified file 'shared/renderer/oxide_content_renderer_client.cc' |
4024 | --- shared/renderer/oxide_content_renderer_client.cc 2013-11-20 19:02:08 +0000 |
4025 | +++ shared/renderer/oxide_content_renderer_client.cc 2014-02-07 16:51:32 +0000 |
4026 | @@ -21,7 +21,6 @@ |
4027 | #include "oxide_process_observer.h" |
4028 | #include "oxide_user_script_scheduler.h" |
4029 | #include "oxide_user_script_slave.h" |
4030 | -#include "oxide_web_frame_observer.h" |
4031 | |
4032 | namespace oxide { |
4033 | |
4034 | @@ -32,14 +31,19 @@ |
4035 | void ContentRendererClient::RenderThreadStarted() { |
4036 | process_observer_.reset(new ProcessObserver()); |
4037 | user_script_slave_.reset(new UserScriptSlave()); |
4038 | - message_dispatcher_.reset(new MessageDispatcherRenderer()); |
4039 | +} |
4040 | + |
4041 | +void ContentRendererClient::RenderFrameCreated( |
4042 | + content::RenderFrame* render_frame) { |
4043 | + new MessageDispatcherRenderer(render_frame); |
4044 | } |
4045 | |
4046 | void ContentRendererClient::RenderViewCreated( |
4047 | content::RenderView* render_view) { |
4048 | + // XXX: This is currently here because RenderFrame proxies the |
4049 | + // notifications we're interested in to RenderView. Make this |
4050 | + // a RenderFrameObserver when it grows the features we need |
4051 | new UserScriptScheduler(render_view); |
4052 | - new MessageDispatcherRenderer::EndPoint(render_view); |
4053 | - new WebFrameObserver(render_view); |
4054 | } |
4055 | |
4056 | void ContentRendererClient::DidCreateScriptContext( |
4057 | @@ -47,14 +51,16 @@ |
4058 | v8::Handle<v8::Context> context, |
4059 | int extension_group, |
4060 | int world_id) { |
4061 | - message_dispatcher_->DidCreateScriptContext(frame, context, world_id); |
4062 | + MessageDispatcherRenderer::FromWebFrame( |
4063 | + frame)->DidCreateScriptContext(context, world_id); |
4064 | } |
4065 | |
4066 | void ContentRendererClient::WillReleaseScriptContext( |
4067 | blink::WebFrame* frame, |
4068 | v8::Handle<v8::Context> context, |
4069 | int world_id) { |
4070 | - message_dispatcher_->WillReleaseScriptContext(frame, context, world_id); |
4071 | + MessageDispatcherRenderer::FromWebFrame( |
4072 | + frame)->WillReleaseScriptContext(context, world_id); |
4073 | } |
4074 | |
4075 | } // namespace oxide |
4076 | |
4077 | === modified file 'shared/renderer/oxide_content_renderer_client.h' |
4078 | --- shared/renderer/oxide_content_renderer_client.h 2013-11-20 19:02:08 +0000 |
4079 | +++ shared/renderer/oxide_content_renderer_client.h 2014-02-07 16:51:32 +0000 |
4080 | @@ -26,7 +26,6 @@ |
4081 | |
4082 | namespace oxide { |
4083 | |
4084 | -class MessageDispatcherRenderer; |
4085 | class ProcessObserver; |
4086 | class UserScriptSlave; |
4087 | |
4088 | @@ -38,12 +37,10 @@ |
4089 | UserScriptSlave* user_script_slave() const { |
4090 | return user_script_slave_.get(); |
4091 | } |
4092 | - MessageDispatcherRenderer* message_dispatcher() const { |
4093 | - return message_dispatcher_.get(); |
4094 | - } |
4095 | |
4096 | void RenderThreadStarted() FINAL; |
4097 | |
4098 | + void RenderFrameCreated(content::RenderFrame* render_frame) FINAL; |
4099 | void RenderViewCreated(content::RenderView* render_view) FINAL; |
4100 | |
4101 | void DidCreateScriptContext(blink::WebFrame* frame, |
4102 | @@ -57,7 +54,6 @@ |
4103 | private: |
4104 | scoped_ptr<ProcessObserver> process_observer_; |
4105 | scoped_ptr<UserScriptSlave> user_script_slave_; |
4106 | - scoped_ptr<MessageDispatcherRenderer> message_dispatcher_; |
4107 | |
4108 | DISALLOW_COPY_AND_ASSIGN(ContentRendererClient); |
4109 | }; |
4110 | |
4111 | === modified file 'shared/renderer/oxide_message_dispatcher_renderer.cc' |
4112 | --- shared/renderer/oxide_message_dispatcher_renderer.cc 2014-01-07 01:08:00 +0000 |
4113 | +++ shared/renderer/oxide_message_dispatcher_renderer.cc 2014-02-07 16:51:32 +0000 |
4114 | @@ -17,48 +17,36 @@ |
4115 | |
4116 | #include "oxide_message_dispatcher_renderer.h" |
4117 | |
4118 | +#include <map> |
4119 | +#include <utility> |
4120 | + |
4121 | +#include "base/lazy_instance.h" |
4122 | +#include "content/public/renderer/render_frame.h" |
4123 | #include "content/public/renderer/render_thread.h" |
4124 | -#include "content/public/renderer/render_view.h" |
4125 | +#include "ipc/ipc_message.h" |
4126 | +#include "ipc/ipc_message_macros.h" |
4127 | #include "third_party/WebKit/public/web/WebFrame.h" |
4128 | |
4129 | -#include "shared/common/oxide_content_client.h" |
4130 | #include "shared/common/oxide_messages.h" |
4131 | |
4132 | -#include "oxide_content_renderer_client.h" |
4133 | #include "oxide_isolated_world_map.h" |
4134 | #include "oxide_v8_message_manager.h" |
4135 | |
4136 | namespace oxide { |
4137 | |
4138 | -void MessageDispatcherRenderer::EndPoint::OnReceiveMessage( |
4139 | - const OxideMsg_SendMessage_Params& params) { |
4140 | - ContentClient::instance()->renderer()->message_dispatcher()-> |
4141 | - OnReceiveMessage(render_view(), params); |
4142 | -} |
4143 | - |
4144 | -MessageDispatcherRenderer::EndPoint::EndPoint(content::RenderView* render_view) : |
4145 | - content::RenderViewObserver(render_view) {} |
4146 | - |
4147 | -bool MessageDispatcherRenderer::EndPoint::OnMessageReceived( |
4148 | - const IPC::Message& message) { |
4149 | - bool handled = true; |
4150 | - IPC_BEGIN_MESSAGE_MAP(EndPoint, message) |
4151 | - IPC_MESSAGE_HANDLER(OxideMsg_SendMessage, OnReceiveMessage) |
4152 | - IPC_MESSAGE_UNHANDLED(handled = false) |
4153 | - IPC_END_MESSAGE_MAP() |
4154 | - |
4155 | - return handled; |
4156 | +namespace { |
4157 | +typedef std::map<content::RenderFrame*, MessageDispatcherRenderer*> MessageDispatcherMap; |
4158 | +typedef MessageDispatcherMap::iterator MessageDispatcherMapIterator; |
4159 | +base::LazyInstance<MessageDispatcherMap> g_dispatcher_map = |
4160 | + LAZY_INSTANCE_INITIALIZER; |
4161 | } |
4162 | |
4163 | void MessageDispatcherRenderer::OnReceiveMessage( |
4164 | - content::RenderView* render_view, |
4165 | const OxideMsg_SendMessage_Params& params) { |
4166 | for (MessageManagerVector::iterator it = message_managers_.begin(); |
4167 | it != message_managers_.end(); ++it) { |
4168 | linked_ptr<V8MessageManager> mm = *it; |
4169 | - if (mm->frame_id() == params.frame_id && |
4170 | - mm->world_id() == IsolatedWorldMap::NameToID(params.world_id) && |
4171 | - mm->render_view() == render_view) { |
4172 | + if (mm->world_id() == IsolatedWorldMap::NameToID(params.world_id)) { |
4173 | mm->ReceiveMessage(params); |
4174 | return; |
4175 | } |
4176 | @@ -69,25 +57,56 @@ |
4177 | } |
4178 | |
4179 | OxideMsg_SendMessage_Params error_params; |
4180 | - error_params.frame_id = params.frame_id; |
4181 | error_params.world_id = params.world_id; |
4182 | error_params.serial = params.serial; |
4183 | error_params.type = OxideMsg_SendMessage_Type::Reply; |
4184 | error_params.error = OxideMsg_SendMessage_Error::INVALID_DESTINATION; |
4185 | error_params.msg_id = params.msg_id; |
4186 | - error_params.args = std::string("Invalid frame or world ID"); |
4187 | - |
4188 | - content::RenderThread::Get()->Send( |
4189 | - new OxideHostMsg_SendMessage(render_view->GetRoutingID(), |
4190 | - error_params)); |
4191 | -} |
4192 | - |
4193 | -MessageDispatcherRenderer::MessageDispatcherRenderer() {} |
4194 | - |
4195 | -MessageDispatcherRenderer::~MessageDispatcherRenderer() {} |
4196 | + error_params.payload = std::string( |
4197 | + "Could not deliver message. The specified world ID does not exist"); |
4198 | + |
4199 | + Send(new OxideHostMsg_SendMessage(routing_id(), error_params)); |
4200 | +} |
4201 | + |
4202 | +bool MessageDispatcherRenderer::OnMessageReceived(const IPC::Message& message) { |
4203 | + bool handled = true; |
4204 | + IPC_BEGIN_MESSAGE_MAP(MessageDispatcherRenderer, message) |
4205 | + IPC_MESSAGE_HANDLER(OxideMsg_SendMessage, OnReceiveMessage) |
4206 | + IPC_MESSAGE_UNHANDLED(handled = false) |
4207 | + IPC_END_MESSAGE_MAP() |
4208 | + |
4209 | + return handled; |
4210 | +} |
4211 | + |
4212 | +MessageDispatcherRenderer::MessageDispatcherRenderer( |
4213 | + content::RenderFrame* frame) : |
4214 | + content::RenderFrameObserver(frame) { |
4215 | + std::pair<MessageDispatcherMapIterator, bool> rv = |
4216 | + g_dispatcher_map.Get().insert(std::make_pair(frame, this)); |
4217 | + CHECK(rv.second); |
4218 | +} |
4219 | + |
4220 | +MessageDispatcherRenderer::~MessageDispatcherRenderer() { |
4221 | + // RenderFrameObserver has already cleared it's pointer to our RenderFrame |
4222 | + for (MessageDispatcherMapIterator it = g_dispatcher_map.Get().begin(); |
4223 | + it != g_dispatcher_map.Get().end(); ++it) { |
4224 | + MessageDispatcherMap::value_type& v = *it; |
4225 | + if (v.second == this) { |
4226 | + g_dispatcher_map.Get().erase(it); |
4227 | + break; |
4228 | + } |
4229 | + } |
4230 | +} |
4231 | + |
4232 | +// static |
4233 | +MessageDispatcherRenderer* MessageDispatcherRenderer::FromWebFrame( |
4234 | + blink::WebFrame* frame) { |
4235 | + content::RenderFrame* rf = content::RenderFrame::FromWebFrame(frame); |
4236 | + MessageDispatcherMapIterator it = g_dispatcher_map.Get().find(rf); |
4237 | + return it == g_dispatcher_map.Get().end() ? NULL : it->second; |
4238 | +} |
4239 | |
4240 | void MessageDispatcherRenderer::DidCreateScriptContext( |
4241 | - blink::WebFrame* frame, |
4242 | v8::Handle<v8::Context> context, |
4243 | int world_id) { |
4244 | if (world_id < 1) { |
4245 | @@ -95,13 +114,12 @@ |
4246 | } |
4247 | |
4248 | message_managers_.push_back( |
4249 | - linked_ptr<V8MessageManager>(new V8MessageManager(frame, |
4250 | + linked_ptr<V8MessageManager>(new V8MessageManager(render_frame(), |
4251 | context, |
4252 | world_id))); |
4253 | } |
4254 | |
4255 | void MessageDispatcherRenderer::WillReleaseScriptContext( |
4256 | - blink::WebFrame* frame, |
4257 | v8::Handle<v8::Context> context, |
4258 | int world_id) { |
4259 | if (world_id < 1) { |
4260 | |
4261 | === modified file 'shared/renderer/oxide_message_dispatcher_renderer.h' |
4262 | --- shared/renderer/oxide_message_dispatcher_renderer.h 2013-11-20 19:02:08 +0000 |
4263 | +++ shared/renderer/oxide_message_dispatcher_renderer.h 2014-02-07 16:51:32 +0000 |
4264 | @@ -23,12 +23,12 @@ |
4265 | #include "base/basictypes.h" |
4266 | #include "base/compiler_specific.h" |
4267 | #include "base/memory/linked_ptr.h" |
4268 | -#include "content/public/renderer/render_view_observer.h" |
4269 | +#include "content/public/renderer/render_frame_observer.h" |
4270 | #include "v8/include/v8.h" |
4271 | |
4272 | struct OxideMsg_SendMessage_Params; |
4273 | |
4274 | -namespace WebKit { |
4275 | +namespace blink { |
4276 | class WebFrame; |
4277 | } |
4278 | |
4279 | @@ -36,40 +36,24 @@ |
4280 | |
4281 | class V8MessageManager; |
4282 | |
4283 | -class MessageDispatcherRenderer FINAL { |
4284 | +class MessageDispatcherRenderer FINAL : public content::RenderFrameObserver { |
4285 | public: |
4286 | - |
4287 | - // XXX: Not sure if this is really necessary - should we just use control |
4288 | - // (non-routed) messages for this, and use RenderProcessObserver |
4289 | - // instead? |
4290 | - class EndPoint FINAL : public content::RenderViewObserver { |
4291 | - public: |
4292 | - EndPoint(content::RenderView* render_view); |
4293 | - |
4294 | - bool OnMessageReceived(const IPC::Message& message) FINAL; |
4295 | - |
4296 | - private: |
4297 | - void OnReceiveMessage(const OxideMsg_SendMessage_Params& params); |
4298 | - |
4299 | - DISALLOW_IMPLICIT_CONSTRUCTORS(EndPoint); |
4300 | - }; |
4301 | - |
4302 | - MessageDispatcherRenderer(); |
4303 | + MessageDispatcherRenderer(content::RenderFrame* frame); |
4304 | ~MessageDispatcherRenderer(); |
4305 | |
4306 | - void DidCreateScriptContext(blink::WebFrame* frame, |
4307 | - v8::Handle<v8::Context> context, |
4308 | + static MessageDispatcherRenderer* FromWebFrame(blink::WebFrame* frame); |
4309 | + |
4310 | + void DidCreateScriptContext(v8::Handle<v8::Context> context, |
4311 | int world_id); |
4312 | |
4313 | - void WillReleaseScriptContext(blink::WebFrame* frame, |
4314 | - v8::Handle<v8::Context> context, |
4315 | + void WillReleaseScriptContext(v8::Handle<v8::Context> context, |
4316 | int world_id); |
4317 | |
4318 | private: |
4319 | typedef std::vector<linked_ptr<V8MessageManager> > MessageManagerVector; |
4320 | |
4321 | - void OnReceiveMessage(content::RenderView* render_view, |
4322 | - const OxideMsg_SendMessage_Params& params); |
4323 | + bool OnMessageReceived(const IPC::Message& message) FINAL; |
4324 | + void OnReceiveMessage(const OxideMsg_SendMessage_Params& params); |
4325 | |
4326 | MessageManagerVector message_managers_; |
4327 | |
4328 | |
4329 | === modified file 'shared/renderer/oxide_v8_message_manager.cc' |
4330 | --- shared/renderer/oxide_v8_message_manager.cc 2014-01-20 12:35:23 +0000 |
4331 | +++ shared/renderer/oxide_v8_message_manager.cc 2014-02-07 16:51:32 +0000 |
4332 | @@ -23,8 +23,7 @@ |
4333 | #include "base/strings/string16.h" |
4334 | #include "base/strings/string_piece.h" |
4335 | #include "base/strings/utf_string_conversions.h" |
4336 | -#include "content/public/renderer/render_thread.h" |
4337 | -#include "content/public/renderer/render_view.h" |
4338 | +#include "content/public/renderer/render_frame.h" |
4339 | #include "third_party/WebKit/public/web/WebFrame.h" |
4340 | #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" |
4341 | #include "ui/base/resource/resource_bundle.h" |
4342 | @@ -145,35 +144,33 @@ |
4343 | |
4344 | v8::Local<v8::String> msg_id = msg_id_as_val->ToString(); |
4345 | |
4346 | - v8::Local<v8::String> msg_args; |
4347 | + v8::Local<v8::String> msg_payload; |
4348 | if (args.Length() > 4) { |
4349 | - v8::Local<v8::Value> msg_args_as_val = args[4]; |
4350 | - if (!msg_args_as_val->IsString()) { |
4351 | + v8::Local<v8::Value> msg_payload_as_val = args[4]; |
4352 | + if (!msg_payload_as_val->IsString()) { |
4353 | isolate->ThrowException(v8::Exception::Error( |
4354 | v8::String::NewFromUtf8( |
4355 | isolate, "Invalid argument type"))); |
4356 | return; |
4357 | } |
4358 | |
4359 | - msg_args = msg_args_as_val->ToString(); |
4360 | + msg_payload = msg_payload_as_val->ToString(); |
4361 | } else if (error != OxideMsg_SendMessage_Error::OK) { |
4362 | - msg_args = v8::String::Empty(isolate); |
4363 | + msg_payload = v8::String::Empty(isolate); |
4364 | } else { |
4365 | - msg_args = v8::String::NewFromUtf8(isolate, "{}"); |
4366 | + msg_payload = v8::String::NewFromUtf8(isolate, "{}"); |
4367 | } |
4368 | |
4369 | OxideMsg_SendMessage_Params params; |
4370 | - params.frame_id = frame_->identifier(); |
4371 | params.world_id = IsolatedWorldMap::IDToName(world_id_); |
4372 | params.serial = serial->Value(); |
4373 | params.type = type; |
4374 | params.error = error; |
4375 | params.msg_id = V8StringToStdString(msg_id); |
4376 | - params.args = V8StringToStdString(msg_args); |
4377 | + params.payload = V8StringToStdString(msg_payload); |
4378 | |
4379 | - content::RenderThread::Get()->Send( |
4380 | - new OxideHostMsg_SendMessage(render_view()->GetRoutingID(), |
4381 | - params)); |
4382 | + frame_->Send(new OxideHostMsg_SendMessage( |
4383 | + frame_->GetRoutingID(), params)); |
4384 | } |
4385 | |
4386 | void V8MessageManager::RegisterReceiveHandlerInner( |
4387 | @@ -264,7 +261,7 @@ |
4388 | |
4389 | { |
4390 | blink::WebScopedMicrotaskSuppression mts; |
4391 | - frame_->callFunctionEvenIfScriptDisabled( |
4392 | + frame_->GetWebFrame()->callFunctionEvenIfScriptDisabled( |
4393 | function, |
4394 | context_.NewHandle(isolate)->Global(), |
4395 | arraysize(args), |
4396 | @@ -280,7 +277,7 @@ |
4397 | info.GetReturnValue().Set(exports); |
4398 | } |
4399 | |
4400 | -V8MessageManager::V8MessageManager(blink::WebFrame* frame, |
4401 | +V8MessageManager::V8MessageManager(content::RenderFrame* frame, |
4402 | v8::Handle<v8::Context> context, |
4403 | int world_id) : |
4404 | frame_(frame), |
4405 | @@ -315,11 +312,11 @@ |
4406 | v8::Integer::New(isolate, params.type), |
4407 | v8::Integer::New(isolate, params.error), |
4408 | v8::String::NewFromUtf8(isolate, params.msg_id.data()), |
4409 | - v8::String::NewFromUtf8(isolate, params.args.data()) |
4410 | + v8::String::NewFromUtf8(isolate, params.payload.data()) |
4411 | }; |
4412 | |
4413 | v8::TryCatch try_catch; |
4414 | - frame_->callFunctionEvenIfScriptDisabled( |
4415 | + frame_->GetWebFrame()->callFunctionEvenIfScriptDisabled( |
4416 | receive_handler_.NewHandle(isolate), |
4417 | context_.NewHandle(isolate)->Global(), |
4418 | arraysize(args), |
4419 | @@ -327,7 +324,6 @@ |
4420 | if (try_catch.HasCaught() && |
4421 | params.type == OxideMsg_SendMessage_Type::Message) { |
4422 | OxideMsg_SendMessage_Params error_params; |
4423 | - error_params.frame_id = params.frame_id; |
4424 | error_params.world_id = params.world_id; |
4425 | error_params.serial = params.serial; |
4426 | error_params.type = OxideMsg_SendMessage_Type::Reply; |
4427 | @@ -337,14 +333,11 @@ |
4428 | v8::Local<v8::Message> msg(try_catch.Message()); |
4429 | if (!msg.IsEmpty()) { |
4430 | v8::Local<v8::String> s(msg->Get()); |
4431 | - error_params.args = V8StringToStdString(s); |
4432 | - } else { |
4433 | - error_params.args = std::string("Handler threw an exception"); |
4434 | + error_params.payload = V8StringToStdString(s); |
4435 | } |
4436 | |
4437 | - content::RenderThread::Get()->Send( |
4438 | - new OxideHostMsg_SendMessage(render_view()->GetRoutingID(), |
4439 | - error_params)); |
4440 | + frame_->Send(new OxideHostMsg_SendMessage( |
4441 | + frame_->GetRoutingID(), error_params)); |
4442 | } |
4443 | } |
4444 | |
4445 | @@ -352,12 +345,4 @@ |
4446 | return context_.NewHandle(v8::Isolate::GetCurrent()); |
4447 | } |
4448 | |
4449 | -long long V8MessageManager::frame_id() const { |
4450 | - return frame_->identifier(); |
4451 | -} |
4452 | - |
4453 | -content::RenderView* V8MessageManager::render_view() const { |
4454 | - return content::RenderView::FromWebView(frame_->view()); |
4455 | -} |
4456 | - |
4457 | } // namespace oxide |
4458 | |
4459 | === modified file 'shared/renderer/oxide_v8_message_manager.h' |
4460 | --- shared/renderer/oxide_v8_message_manager.h 2013-11-20 19:02:08 +0000 |
4461 | +++ shared/renderer/oxide_v8_message_manager.h 2014-02-07 16:51:32 +0000 |
4462 | @@ -28,11 +28,8 @@ |
4463 | |
4464 | struct OxideMsg_SendMessage_Params; |
4465 | |
4466 | -namespace blink { |
4467 | -class WebFrame; |
4468 | -} |
4469 | - |
4470 | namespace content { |
4471 | +class RenderFrame; |
4472 | class RenderView; |
4473 | } |
4474 | |
4475 | @@ -40,7 +37,7 @@ |
4476 | |
4477 | class V8MessageManager FINAL { |
4478 | public: |
4479 | - V8MessageManager(blink::WebFrame* frame, |
4480 | + V8MessageManager(content::RenderFrame* frame, |
4481 | v8::Handle<v8::Context> context, |
4482 | int world_id); |
4483 | ~V8MessageManager(); |
4484 | @@ -48,9 +45,7 @@ |
4485 | void ReceiveMessage(const OxideMsg_SendMessage_Params& params); |
4486 | |
4487 | v8::Handle<v8::Context> v8_context() const; |
4488 | - long long frame_id() const; |
4489 | int world_id() const { return world_id_; } |
4490 | - content::RenderView* render_view() const; |
4491 | |
4492 | private: |
4493 | static std::string V8StringToStdString(v8::Local<v8::String> string); |
4494 | @@ -72,7 +67,7 @@ |
4495 | void OxideLazyGetterInner(v8::Local<v8::String> property, |
4496 | const v8::PropertyCallbackInfo<v8::Value>& info); |
4497 | |
4498 | - blink::WebFrame* frame_; |
4499 | + content::RenderFrame* frame_; |
4500 | ScopedPersistent<v8::Context> context_; |
4501 | int world_id_; |
4502 | ScopedPersistent<v8::External> closure_data_; |
4503 | |
4504 | === removed file 'shared/renderer/oxide_web_frame_observer.cc' |
4505 | --- shared/renderer/oxide_web_frame_observer.cc 2013-11-20 19:02:08 +0000 |
4506 | +++ shared/renderer/oxide_web_frame_observer.cc 1970-01-01 00:00:00 +0000 |
4507 | @@ -1,40 +0,0 @@ |
4508 | -// vim:expandtab:shiftwidth=2:tabstop=2: |
4509 | -// Copyright (C) 2013 Canonical Ltd. |
4510 | - |
4511 | -// This library is free software; you can redistribute it and/or |
4512 | -// modify it under the terms of the GNU Lesser General Public |
4513 | -// License as published by the Free Software Foundation; either |
4514 | -// version 2.1 of the License, or (at your option) any later version. |
4515 | - |
4516 | -// This library is distributed in the hope that it will be useful, |
4517 | -// but WITHOUT ANY WARRANTY; without even the implied warranty of |
4518 | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4519 | -// Lesser General Public License for more details. |
4520 | - |
4521 | -// You should have received a copy of the GNU Lesser General Public |
4522 | -// License along with this library; if not, write to the Free Software |
4523 | -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
4524 | - |
4525 | -#include "oxide_web_frame_observer.h" |
4526 | - |
4527 | -#include "content/public/renderer/render_view.h" |
4528 | -#include "third_party/WebKit/public/web/WebFrame.h" |
4529 | - |
4530 | -#include "shared/common/oxide_messages.h" |
4531 | - |
4532 | -namespace oxide { |
4533 | - |
4534 | -WebFrameObserver::WebFrameObserver(content::RenderView* render_view) : |
4535 | - content::RenderViewObserver(render_view) {} |
4536 | - |
4537 | -WebFrameObserver::~WebFrameObserver() {} |
4538 | - |
4539 | -void WebFrameObserver::FrameCreated(blink::WebFrame* parent, |
4540 | - blink::WebFrame* frame) { |
4541 | - render_view()->Send( |
4542 | - new OxideHostMsg_FrameCreated(routing_id(), |
4543 | - parent->identifier(), |
4544 | - frame->identifier())); |
4545 | -} |
4546 | - |
4547 | -} // namespace oxide |
4548 | |
4549 | === removed file 'shared/renderer/oxide_web_frame_observer.h' |
4550 | --- shared/renderer/oxide_web_frame_observer.h 2013-11-20 19:02:08 +0000 |
4551 | +++ shared/renderer/oxide_web_frame_observer.h 1970-01-01 00:00:00 +0000 |
4552 | @@ -1,41 +0,0 @@ |
4553 | -// vim:expandtab:shiftwidth=2:tabstop=2: |
4554 | -// Copyright (C) 2013 Canonical Ltd. |
4555 | - |
4556 | -// This library is free software; you can redistribute it and/or |
4557 | -// modify it under the terms of the GNU Lesser General Public |
4558 | -// License as published by the Free Software Foundation; either |
4559 | -// version 2.1 of the License, or (at your option) any later version. |
4560 | - |
4561 | -// This library is distributed in the hope that it will be useful, |
4562 | -// but WITHOUT ANY WARRANTY; without even the implied warranty of |
4563 | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4564 | -// Lesser General Public License for more details. |
4565 | - |
4566 | -// You should have received a copy of the GNU Lesser General Public |
4567 | -// License along with this library; if not, write to the Free Software |
4568 | -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
4569 | - |
4570 | -#ifndef _OXIDE_SHARED_RENDERER_WEB_FRAME_OBSERVER_H_ |
4571 | -#define _OXIDE_SHARED_RENDERER_WEB_FRAME_OBSERVER_H_ |
4572 | - |
4573 | -#include "base/basictypes.h" |
4574 | -#include "base/compiler_specific.h" |
4575 | -#include "content/public/renderer/render_view_observer.h" |
4576 | - |
4577 | -namespace oxide { |
4578 | - |
4579 | -class WebFrameObserver FINAL : public content::RenderViewObserver { |
4580 | - public: |
4581 | - WebFrameObserver(content::RenderView* render_view); |
4582 | - virtual ~WebFrameObserver(); |
4583 | - |
4584 | - void FrameCreated(blink::WebFrame* parent, |
4585 | - blink::WebFrame* frame) FINAL; |
4586 | - |
4587 | - private: |
4588 | - DISALLOW_IMPLICIT_CONSTRUCTORS(WebFrameObserver); |
4589 | -}; |
4590 | - |
4591 | -}; |
4592 | - |
4593 | -#endif // _OXIDE_SHARED_RENDERER_WEB_FRAME_OBSERVER_H_ |
4594 | |
4595 | === modified file 'shared/shared.gyp' |
4596 | --- shared/shared.gyp 2014-01-30 10:57:52 +0000 |
4597 | +++ shared/shared.gyp 2014-02-07 16:51:32 +0000 |
4598 | @@ -148,6 +148,8 @@ |
4599 | 'browser/oxide_incoming_message.h', |
4600 | 'browser/oxide_io_thread_delegate.cc', |
4601 | 'browser/oxide_io_thread_delegate.h', |
4602 | + 'browser/oxide_message_dispatcher_browser.cc', |
4603 | + 'browser/oxide_message_dispatcher_browser.h', |
4604 | 'browser/oxide_message_handler.cc', |
4605 | 'browser/oxide_message_handler.h', |
4606 | 'browser/oxide_message_pump.cc', |
4607 | @@ -173,6 +175,8 @@ |
4608 | 'browser/oxide_web_frame.h', |
4609 | 'browser/oxide_web_popup_menu.cc', |
4610 | 'browser/oxide_web_popup_menu.h', |
4611 | + 'browser/oxide_web_preferences.cc', |
4612 | + 'browser/oxide_web_preferences.h', |
4613 | 'browser/oxide_web_view.cc', |
4614 | 'browser/oxide_web_view.h', |
4615 | 'common/oxide_constants.cc', |
4616 | @@ -213,8 +217,6 @@ |
4617 | 'renderer/oxide_v8_message_manager.cc', |
4618 | 'renderer/oxide_v8_message_manager.h', |
4619 | 'renderer/oxide_v8_scoped_persistent.h', |
4620 | - 'renderer/oxide_web_frame_observer.cc', |
4621 | - 'renderer/oxide_web_frame_observer.h', |
4622 | '<(DEPTH)/extensions/common/constants.cc', |
4623 | '<(DEPTH)/extensions/common/constants.h', |
4624 | '<(DEPTH)/extensions/common/error_utils.cc', |