OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser_plugin/browser_plugin_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 case NEW_WINDOW: | 146 case NEW_WINDOW: |
147 return "new_window"; | 147 return "new_window"; |
148 case NEW_POPUP: | 148 case NEW_POPUP: |
149 return "new_popup"; | 149 return "new_popup"; |
150 default: | 150 default: |
151 NOTREACHED() << "Unknown Window Open Disposition"; | 151 NOTREACHED() << "Unknown Window Open Disposition"; |
152 return "ignore"; | 152 return "ignore"; |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 // Called on IO thread. | |
157 static GURL RetrieveDownloadURLFromRequestId( | |
158 int render_process_id, | |
159 int url_request_id) { | |
160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
161 | |
162 GlobalRequestID global_id(render_process_id, url_request_id); | |
163 net::URLRequest* url_request = | |
164 ResourceDispatcherHostImpl::Get()->GetURLRequest(global_id); | |
165 if (url_request) | |
166 return url_request->url(); | |
lazyboy
2014/05/13 01:33:51
Note that this can be different then the original
Fady Samuel
2014/05/13 14:33:12
That's fine. I don't believe there's any change in
| |
167 return GURL(); | |
168 } | |
169 | |
170 } // namespace | 156 } // namespace |
171 | 157 |
172 class BrowserPluginGuest::EmbedderWebContentsObserver | 158 class BrowserPluginGuest::EmbedderWebContentsObserver |
173 : public WebContentsObserver { | 159 : public WebContentsObserver { |
174 public: | 160 public: |
175 explicit EmbedderWebContentsObserver(BrowserPluginGuest* guest) | 161 explicit EmbedderWebContentsObserver(BrowserPluginGuest* guest) |
176 : WebContentsObserver(guest->embedder_web_contents()), | 162 : WebContentsObserver(guest->embedder_web_contents()), |
177 browser_plugin_guest_(guest) { | 163 browser_plugin_guest_(guest) { |
178 } | 164 } |
179 | 165 |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
606 bool user_gesture, | 592 bool user_gesture, |
607 bool* was_blocked) { | 593 bool* was_blocked) { |
608 if (was_blocked) | 594 if (was_blocked) |
609 *was_blocked = false; | 595 *was_blocked = false; |
610 RequestNewWindowPermission(disposition, initial_pos, user_gesture, | 596 RequestNewWindowPermission(disposition, initial_pos, user_gesture, |
611 static_cast<WebContentsImpl*>(new_contents)); | 597 static_cast<WebContentsImpl*>(new_contents)); |
612 } | 598 } |
613 | 599 |
614 void BrowserPluginGuest::CanDownload( | 600 void BrowserPluginGuest::CanDownload( |
615 RenderViewHost* render_view_host, | 601 RenderViewHost* render_view_host, |
616 int request_id, | 602 const GURL& url, |
617 const std::string& request_method, | 603 const std::string& request_method, |
618 const base::Callback<void(bool)>& callback) { | 604 const base::Callback<void(bool)>& callback) { |
619 if (!delegate_) { | 605 if (!delegate_ || !url.is_valid()) { |
620 callback.Run(false); | 606 callback.Run(false); |
621 return; | 607 return; |
622 } | 608 } |
623 | 609 |
624 BrowserThread::PostTaskAndReplyWithResult( | 610 delegate_->CanDownload(request_method, url, callback); |
625 BrowserThread::IO, FROM_HERE, | |
626 base::Bind(&RetrieveDownloadURLFromRequestId, | |
627 render_view_host->GetProcess()->GetID(), request_id), | |
628 base::Bind(&BrowserPluginGuest::DidRetrieveDownloadURLFromRequestId, | |
629 weak_ptr_factory_.GetWeakPtr(), | |
630 request_method, | |
631 callback)); | |
632 } | 611 } |
633 | 612 |
634 void BrowserPluginGuest::LoadProgressChanged(WebContents* contents, | 613 void BrowserPluginGuest::LoadProgressChanged(WebContents* contents, |
635 double progress) { | 614 double progress) { |
636 if (delegate_) | 615 if (delegate_) |
637 delegate_->LoadProgressed(progress); | 616 delegate_->LoadProgressed(progress); |
638 } | 617 } |
639 | 618 |
640 void BrowserPluginGuest::CloseContents(WebContents* source) { | 619 void BrowserPluginGuest::CloseContents(WebContents* source) { |
641 if (!delegate_) | 620 if (!delegate_) |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1549 #if defined(OS_MACOSX) || defined(USE_AURA) | 1528 #if defined(OS_MACOSX) || defined(USE_AURA) |
1550 void BrowserPluginGuest::OnImeCompositionRangeChanged( | 1529 void BrowserPluginGuest::OnImeCompositionRangeChanged( |
1551 const gfx::Range& range, | 1530 const gfx::Range& range, |
1552 const std::vector<gfx::Rect>& character_bounds) { | 1531 const std::vector<gfx::Rect>& character_bounds) { |
1553 static_cast<RenderWidgetHostViewBase*>( | 1532 static_cast<RenderWidgetHostViewBase*>( |
1554 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( | 1533 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( |
1555 range, character_bounds); | 1534 range, character_bounds); |
1556 } | 1535 } |
1557 #endif | 1536 #endif |
1558 | 1537 |
1559 void BrowserPluginGuest::DidRetrieveDownloadURLFromRequestId( | |
1560 const std::string& request_method, | |
1561 const base::Callback<void(bool)>& callback, | |
1562 const GURL& url) { | |
1563 if (!url.is_valid()) { | |
1564 callback.Run(false); | |
1565 return; | |
1566 } | |
1567 | |
1568 delegate_->CanDownload(request_method, url, callback); | |
1569 } | |
1570 | |
1571 } // namespace content | 1538 } // namespace content |
OLD | NEW |