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