OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 | 8 |
9 #include "DedicatedWorkerContext.h" | 9 #include "DedicatedWorkerContext.h" |
10 #include "DedicatedWorkerThread.h" | 10 #include "DedicatedWorkerThread.h" |
11 #include "GenericWorkerTask.h" | 11 #include "GenericWorkerTask.h" |
12 #include "KURL.h" | 12 #include "KURL.h" |
13 #include "MessagePort.h" | 13 #include "MessagePort.h" |
14 #include "MessagePortChannel.h" | 14 #include "MessagePortChannel.h" |
15 #include "ScriptExecutionContext.h" | 15 #include "ScriptExecutionContext.h" |
16 #include "SecurityOrigin.h" | 16 #include "SecurityOrigin.h" |
17 #include "SubstituteData.h" | 17 #include "SubstituteData.h" |
18 #include <wtf/MainThread.h> | 18 #include <wtf/MainThread.h> |
19 #include <wtf/Threading.h> | 19 #include <wtf/Threading.h> |
20 | 20 |
21 #undef LOG | 21 #undef LOG |
22 | 22 |
23 #include "base/logging.h" | 23 #include "base/logging.h" |
| 24 #include "webkit/api/public/WebFrameClient.h" |
24 #include "webkit/api/public/WebMessagePortChannel.h" | 25 #include "webkit/api/public/WebMessagePortChannel.h" |
25 #include "webkit/api/public/WebScreenInfo.h" | 26 #include "webkit/api/public/WebScreenInfo.h" |
26 #include "webkit/api/public/WebString.h" | 27 #include "webkit/api/public/WebString.h" |
27 #include "webkit/api/public/WebURL.h" | 28 #include "webkit/api/public/WebURL.h" |
28 #include "webkit/api/public/WebWorkerClient.h" | 29 #include "webkit/api/public/WebWorkerClient.h" |
29 #include "webkit/api/src/PlatformMessagePortChannel.h" | 30 #include "webkit/api/src/PlatformMessagePortChannel.h" |
30 #include "webkit/api/src/WebDataSourceImpl.h" | 31 #include "webkit/api/src/WebDataSourceImpl.h" |
| 32 #include "webkit/glue/empty_webframeclient.h" |
31 #include "webkit/glue/glue_util.h" | 33 #include "webkit/glue/glue_util.h" |
32 #include "webkit/glue/webframe_impl.h" | 34 #include "webkit/glue/webframe_impl.h" |
33 #include "webkit/glue/webpreferences.h" | 35 #include "webkit/glue/webpreferences.h" |
34 #include "webkit/glue/webview.h" | 36 #include "webkit/glue/webview.h" |
35 #include "webkit/glue/webview_delegate.h" | 37 #include "webkit/glue/webview_delegate.h" |
36 #include "webkit/glue/webworker_impl.h" | 38 #include "webkit/glue/webworker_impl.h" |
37 | 39 |
38 using WebKit::WebCursorInfo; | 40 using WebKit::WebCursorInfo; |
| 41 using WebKit::WebDataSource; |
| 42 using WebKit::WebDataSourceImpl; |
39 using WebKit::WebFrame; | 43 using WebKit::WebFrame; |
| 44 using WebKit::WebFrameClient; |
40 using WebKit::WebMessagePortChannel; | 45 using WebKit::WebMessagePortChannel; |
41 using WebKit::WebMessagePortChannelArray; | 46 using WebKit::WebMessagePortChannelArray; |
42 using WebKit::WebNavigationPolicy; | 47 using WebKit::WebNavigationPolicy; |
43 using WebKit::WebRect; | 48 using WebKit::WebRect; |
44 using WebKit::WebScreenInfo; | 49 using WebKit::WebScreenInfo; |
45 using WebKit::WebString; | 50 using WebKit::WebString; |
46 using WebKit::WebURL; | 51 using WebKit::WebURL; |
47 using WebKit::WebWorker; | 52 using WebKit::WebWorker; |
48 using WebKit::WebWorkerClient; | 53 using WebKit::WebWorkerClient; |
49 | 54 |
50 #if ENABLE(WORKERS) | 55 #if ENABLE(WORKERS) |
51 | 56 |
52 // Dummy WebViewDelegate - we only need it in Worker process to load a | 57 // Dummy WebViewDelegate - we only need it in Worker process to load a |
53 // 'shadow page' which will initialize WebCore loader. | 58 // 'shadow page' which will initialize WebCore loader. |
54 class WorkerWebViewDelegate : public WebViewDelegate { | 59 class WorkerWebFrameClient : public webkit_glue::EmptyWebFrameClient { |
55 public: | 60 public: |
56 WorkerWebViewDelegate() {} | |
57 | |
58 virtual void didInvalidateRect(const WebRect&) {} | |
59 virtual void didScrollRect(int dx, int dy, const WebRect& clipRect) {} | |
60 virtual void didFocus() {} | |
61 virtual void didBlur() {} | |
62 virtual void didChangeCursor(const WebCursorInfo&) {} | |
63 virtual void closeWidgetSoon() {} | |
64 virtual void show(WebNavigationPolicy) {} | |
65 virtual void runModal() {} | |
66 virtual WebRect windowRect() { return WebRect(); } | |
67 virtual void setWindowRect(const WebRect&) {} | |
68 virtual WebRect windowResizerRect() { return WebRect(); } | |
69 virtual WebRect rootWindowRect() { return WebRect(); } | |
70 virtual WebScreenInfo screenInfo() { return WebScreenInfo(); } | |
71 | |
72 // Tell the loader to load the data into the 'shadow page' synchronously, | 61 // Tell the loader to load the data into the 'shadow page' synchronously, |
73 // so we can grab the resulting Document right after load. | 62 // so we can grab the resulting Document right after load. |
74 virtual void DidCreateDataSource(WebFrame* frame, WebKit::WebDataSource* ds) { | 63 virtual void didCreateDataSource(WebFrame* frame, WebDataSource* ds) { |
75 static_cast<WebKit::WebDataSourceImpl*>(ds)-> | 64 static_cast<WebDataSourceImpl*>(ds)->setDeferMainResourceDataLoad(false); |
76 setDeferMainResourceDataLoad(false); | |
77 } | 65 } |
78 | 66 |
79 // Lazy allocate and leak this instance. | 67 // Lazy allocate and leak this instance. |
80 static WorkerWebViewDelegate* worker_delegate() { | 68 static WorkerWebFrameClient* GetSharedInstance() { |
81 static WorkerWebViewDelegate* worker_delegate = new WorkerWebViewDelegate(); | 69 static WorkerWebFrameClient client; |
82 return worker_delegate; | 70 return &client; |
83 } | 71 } |
84 | 72 |
85 private: | 73 private: |
86 DISALLOW_COPY_AND_ASSIGN(WorkerWebViewDelegate); | 74 WorkerWebFrameClient() {} |
87 }; | 75 }; |
88 | 76 |
89 namespace WebKit { | 77 namespace WebKit { |
90 | 78 |
91 WebWorker* WebWorker::create(WebWorkerClient* client) { | 79 WebWorker* WebWorker::create(WebWorkerClient* client) { |
92 return new WebWorkerImpl(client); | 80 return new WebWorkerImpl(client); |
93 } | 81 } |
94 | 82 |
95 } | 83 } |
96 | 84 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 130 |
143 // WebWorker ------------------------------------------------------------------- | 131 // WebWorker ------------------------------------------------------------------- |
144 | 132 |
145 void WebWorkerImpl::startWorkerContext(const WebURL& script_url, | 133 void WebWorkerImpl::startWorkerContext(const WebURL& script_url, |
146 const WebString& user_agent, | 134 const WebString& user_agent, |
147 const WebString& source_code) { | 135 const WebString& source_code) { |
148 // Create 'shadow page'. This page is never displayed, it is used to proxy the | 136 // Create 'shadow page'. This page is never displayed, it is used to proxy the |
149 // loading requests from the worker context to the rest of WebKit and Chromium | 137 // loading requests from the worker context to the rest of WebKit and Chromium |
150 // infrastructure. | 138 // infrastructure. |
151 DCHECK(!web_view_); | 139 DCHECK(!web_view_); |
152 web_view_ = WebView::Create(WorkerWebViewDelegate::worker_delegate(), NULL); | 140 web_view_ = WebView::Create(NULL, NULL); |
153 WebPreferences().Apply(web_view_); | 141 WebPreferences().Apply(web_view_); |
154 web_view_->InitializeMainFrame(); | 142 web_view_->InitializeMainFrame(WorkerWebFrameClient::GetSharedInstance()); |
155 | 143 |
156 WebFrameImpl* web_frame = | 144 WebFrameImpl* web_frame = |
157 static_cast<WebFrameImpl*>(web_view_->GetMainFrame()); | 145 static_cast<WebFrameImpl*>(web_view_->GetMainFrame()); |
158 | 146 |
159 // Construct substitute data source for the 'shadow page'. We only need it | 147 // Construct substitute data source for the 'shadow page'. We only need it |
160 // to have same origin as the worker so the loading checks work correctly. | 148 // to have same origin as the worker so the loading checks work correctly. |
161 WebCore::CString content(""); | 149 WebCore::CString content(""); |
162 int len = static_cast<int>(content.length()); | 150 int len = static_cast<int>(content.length()); |
163 RefPtr<WebCore::SharedBuffer> buf( | 151 RefPtr<WebCore::SharedBuffer> buf( |
164 WebCore::SharedBuffer::create(content.data(), len)); | 152 WebCore::SharedBuffer::create(content.data(), len)); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 378 |
391 namespace WebKit { | 379 namespace WebKit { |
392 | 380 |
393 WebWorker* WebWorker::create(WebWorkerClient* client) { | 381 WebWorker* WebWorker::create(WebWorkerClient* client) { |
394 return NULL; | 382 return NULL; |
395 } | 383 } |
396 | 384 |
397 } | 385 } |
398 | 386 |
399 #endif | 387 #endif |
OLD | NEW |