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/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <utility> | 10 #include <utility> |
(...skipping 2746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2757 | 2757 |
2758 void WebContentsImpl::SaveFrameWithHeaders(const GURL& url, | 2758 void WebContentsImpl::SaveFrameWithHeaders(const GURL& url, |
2759 const Referrer& referrer, | 2759 const Referrer& referrer, |
2760 const std::string& headers) { | 2760 const std::string& headers) { |
2761 if (!GetLastCommittedURL().is_valid()) | 2761 if (!GetLastCommittedURL().is_valid()) |
2762 return; | 2762 return; |
2763 if (delegate_ && delegate_->SaveFrame(url, referrer)) | 2763 if (delegate_ && delegate_->SaveFrame(url, referrer)) |
2764 return; | 2764 return; |
2765 | 2765 |
2766 // TODO(nasko): This check for main frame is incorrect and should be fixed | 2766 // TODO(nasko): This check for main frame is incorrect and should be fixed |
2767 // by explicitly passing in which frame this method should target. | 2767 // by explicitly passing in which frame this method should target. This would |
| 2768 // indicate whether it's the main frame, and also tell us the frame pointer |
| 2769 // to use for routing. |
2768 bool is_main_frame = (url == GetLastCommittedURL()); | 2770 bool is_main_frame = (url == GetLastCommittedURL()); |
| 2771 RenderFrameHost* frame_host = GetMainFrame(); |
2769 | 2772 |
| 2773 StoragePartition* storage_partition = BrowserContext::GetStoragePartition( |
| 2774 GetBrowserContext(), frame_host->GetSiteInstance()); |
2770 DownloadManager* dlm = | 2775 DownloadManager* dlm = |
2771 BrowserContext::GetDownloadManager(GetBrowserContext()); | 2776 BrowserContext::GetDownloadManager(GetBrowserContext()); |
2772 if (!dlm) | 2777 if (!dlm) |
2773 return; | 2778 return; |
2774 int64_t post_id = -1; | 2779 int64_t post_id = -1; |
2775 if (is_main_frame) { | 2780 if (is_main_frame) { |
2776 const NavigationEntry* entry = controller_.GetLastCommittedEntry(); | 2781 const NavigationEntry* entry = controller_.GetLastCommittedEntry(); |
2777 if (entry) | 2782 if (entry) |
2778 post_id = entry->GetPostID(); | 2783 post_id = entry->GetPostID(); |
2779 } | 2784 } |
2780 std::unique_ptr<DownloadUrlParameters> params( | 2785 std::unique_ptr<DownloadUrlParameters> params(new DownloadUrlParameters( |
2781 DownloadUrlParameters::FromWebContents(this, url)); | 2786 url, frame_host->GetProcess()->GetID(), |
| 2787 frame_host->GetRenderViewHost()->GetRoutingID(), |
| 2788 frame_host->GetRoutingID(), storage_partition->GetURLRequestContext())); |
2782 params->set_referrer(referrer); | 2789 params->set_referrer(referrer); |
2783 params->set_post_id(post_id); | 2790 params->set_post_id(post_id); |
2784 if (post_id >= 0) | 2791 if (post_id >= 0) |
2785 params->set_method("POST"); | 2792 params->set_method("POST"); |
2786 params->set_prompt(true); | 2793 params->set_prompt(true); |
2787 | 2794 |
2788 if (headers.empty()) { | 2795 if (headers.empty()) { |
2789 params->set_prefer_cache(true); | 2796 params->set_prefer_cache(true); |
2790 } else { | 2797 } else { |
2791 for (const base::StringPiece& key_value : | 2798 for (const base::StringPiece& key_value : |
(...skipping 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5033 for (RenderViewHost* render_view_host : render_view_host_set) | 5040 for (RenderViewHost* render_view_host : render_view_host_set) |
5034 render_view_host->OnWebkitPreferencesChanged(); | 5041 render_view_host->OnWebkitPreferencesChanged(); |
5035 } | 5042 } |
5036 | 5043 |
5037 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5044 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
5038 JavaScriptDialogManager* dialog_manager) { | 5045 JavaScriptDialogManager* dialog_manager) { |
5039 dialog_manager_ = dialog_manager; | 5046 dialog_manager_ = dialog_manager; |
5040 } | 5047 } |
5041 | 5048 |
5042 } // namespace content | 5049 } // namespace content |
OLD | NEW |