OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/service_worker/service_worker_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 render_frame_id)); | 212 render_frame_id)); |
213 Observe(nullptr); | 213 Observe(nullptr); |
214 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 214 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
215 } | 215 } |
216 | 216 |
217 const WindowOpenedCallback callback_; | 217 const WindowOpenedCallback callback_; |
218 | 218 |
219 DISALLOW_COPY_AND_ASSIGN(WindowOpenedObserver); | 219 DISALLOW_COPY_AND_ASSIGN(WindowOpenedObserver); |
220 }; | 220 }; |
221 | 221 |
| 222 void DidOpenURL(const WindowOpenedCallback& callback, |
| 223 WebContents* web_contents) { |
| 224 DCHECK(web_contents); |
| 225 |
| 226 new WindowOpenedObserver(web_contents, callback); |
| 227 } |
| 228 |
222 void OpenWindowOnUI( | 229 void OpenWindowOnUI( |
223 const GURL& url, | 230 const GURL& url, |
224 const GURL& script_url, | 231 const GURL& script_url, |
225 int process_id, | 232 int process_id, |
226 const scoped_refptr<ServiceWorkerContextWrapper>& context_wrapper, | 233 const scoped_refptr<ServiceWorkerContextWrapper>& context_wrapper, |
227 const WindowOpenedCallback& callback) { | 234 const WindowOpenedCallback& callback) { |
228 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 235 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
229 | 236 |
230 BrowserContext* browser_context = context_wrapper->storage_partition() | 237 BrowserContext* browser_context = context_wrapper->storage_partition() |
231 ? context_wrapper->storage_partition()->browser_context() | 238 ? context_wrapper->storage_partition()->browser_context() |
(...skipping 11 matching lines...) Expand all Loading... |
243 MSG_ROUTING_NONE)); | 250 MSG_ROUTING_NONE)); |
244 return; | 251 return; |
245 } | 252 } |
246 | 253 |
247 OpenURLParams params( | 254 OpenURLParams params( |
248 url, Referrer::SanitizeForRequest( | 255 url, Referrer::SanitizeForRequest( |
249 url, Referrer(script_url, blink::WebReferrerPolicyDefault)), | 256 url, Referrer(script_url, blink::WebReferrerPolicyDefault)), |
250 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 257 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
251 true /* is_renderer_initiated */); | 258 true /* is_renderer_initiated */); |
252 | 259 |
253 WebContents* web_contents = | 260 GetContentClient()->browser()->OpenURL( |
254 GetContentClient()->browser()->OpenURL(browser_context, params); | 261 browser_context, params, |
255 DCHECK(web_contents); | 262 base::Bind(&DidOpenURL, callback)); |
256 | |
257 new WindowOpenedObserver(web_contents, callback); | |
258 } | 263 } |
259 | 264 |
260 void KillEmbeddedWorkerProcess(int process_id, ResultCode code) { | 265 void KillEmbeddedWorkerProcess(int process_id, ResultCode code) { |
261 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 266 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
262 | 267 |
263 RenderProcessHost* render_process_host = | 268 RenderProcessHost* render_process_host = |
264 RenderProcessHost::FromID(process_id); | 269 RenderProcessHost::FromID(process_id); |
265 if (render_process_host->GetHandle() != base::kNullProcessHandle) | 270 if (render_process_host->GetHandle() != base::kNullProcessHandle) |
266 render_process_host->ReceivedBadMessage(); | 271 render_process_host->ReceivedBadMessage(); |
267 } | 272 } |
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 int request_id) { | 1422 int request_id) { |
1418 callbacks->Remove(request_id); | 1423 callbacks->Remove(request_id); |
1419 if (is_doomed_) { | 1424 if (is_doomed_) { |
1420 // The stop should be already scheduled, but try to stop immediately, in | 1425 // The stop should be already scheduled, but try to stop immediately, in |
1421 // order to release worker resources soon. | 1426 // order to release worker resources soon. |
1422 StopWorkerIfIdle(); | 1427 StopWorkerIfIdle(); |
1423 } | 1428 } |
1424 } | 1429 } |
1425 | 1430 |
1426 } // namespace content | 1431 } // namespace content |
OLD | NEW |