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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1202 contents_mime_type_ == "text/plain" || | 1202 contents_mime_type_ == "text/plain" || |
1203 contents_mime_type_ == "text/css" || | 1203 contents_mime_type_ == "text/css" || |
1204 net::IsSupportedJavascriptMimeType(contents_mime_type_.c_str()); | 1204 net::IsSupportedJavascriptMimeType(contents_mime_type_.c_str()); |
1205 } | 1205 } |
1206 | 1206 |
1207 void WebContentsImpl::OnSavePage() { | 1207 void WebContentsImpl::OnSavePage() { |
1208 // If we can not save the page, try to download it. | 1208 // If we can not save the page, try to download it. |
1209 if (!IsSavable()) { | 1209 if (!IsSavable()) { |
1210 download_stats::RecordDownloadSource( | 1210 download_stats::RecordDownloadSource( |
1211 download_stats::INITIATED_BY_SAVE_PACKAGE_ON_NON_HTML); | 1211 download_stats::INITIATED_BY_SAVE_PACKAGE_ON_NON_HTML); |
1212 SaveURL(GetURL(), GURL(), true); | 1212 SaveURL(GetURL(), content::Referrer(), true); |
1213 return; | 1213 return; |
1214 } | 1214 } |
1215 | 1215 |
1216 Stop(); | 1216 Stop(); |
1217 | 1217 |
1218 // Create the save package and possibly prompt the user for the name to save | 1218 // Create the save package and possibly prompt the user for the name to save |
1219 // the page as. The user prompt is an asynchronous operation that runs on | 1219 // the page as. The user prompt is an asynchronous operation that runs on |
1220 // another thread. | 1220 // another thread. |
1221 save_package_ = new SavePackage(this); | 1221 save_package_ = new SavePackage(this); |
1222 save_package_->GetSaveInfo(); | 1222 save_package_->GetSaveInfo(); |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1732 } | 1732 } |
1733 | 1733 |
1734 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, | 1734 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, |
1735 int maximum_percent, | 1735 int maximum_percent, |
1736 bool remember) { | 1736 bool remember) { |
1737 minimum_zoom_percent_ = minimum_percent; | 1737 minimum_zoom_percent_ = minimum_percent; |
1738 maximum_zoom_percent_ = maximum_percent; | 1738 maximum_zoom_percent_ = maximum_percent; |
1739 temporary_zoom_settings_ = !remember; | 1739 temporary_zoom_settings_ = !remember; |
1740 } | 1740 } |
1741 | 1741 |
1742 void WebContentsImpl::OnSaveURL(const GURL& url) { | 1742 void WebContentsImpl::OnSaveURL(const GURL& url, |
1743 const content::Referrer& referrer) { | |
1743 download_stats::RecordDownloadSource( | 1744 download_stats::RecordDownloadSource( |
1744 download_stats::INITIATED_BY_PEPPER_SAVE); | 1745 download_stats::INITIATED_BY_PEPPER_SAVE); |
1745 // Check if the URL to save matches the URL of the main frame. Since this | 1746 // Check if the URL to save matches the URL of the main frame. Since this |
1746 // message originates from Pepper plugins, it may not be the case if the | 1747 // message originates from Pepper plugins, it may not be the case if the |
1747 // plugin is an embedded element. | 1748 // plugin is an embedded element. |
1748 GURL main_frame_url = GetURL(); | 1749 GURL main_frame_url = GetURL(); |
1749 if (!main_frame_url.is_valid()) | 1750 if (!main_frame_url.is_valid()) |
1750 return; | 1751 return; |
1751 bool is_main_frame = (url == main_frame_url); | 1752 bool is_main_frame = (url == main_frame_url); |
1752 SaveURL(url, main_frame_url, is_main_frame); | 1753 SaveURL(url, referrer, is_main_frame); |
1753 } | 1754 } |
1754 | 1755 |
1755 void WebContentsImpl::OnEnumerateDirectory(int request_id, | 1756 void WebContentsImpl::OnEnumerateDirectory(int request_id, |
1756 const FilePath& path) { | 1757 const FilePath& path) { |
1757 ChildProcessSecurityPolicyImpl* policy = | 1758 ChildProcessSecurityPolicyImpl* policy = |
1758 ChildProcessSecurityPolicyImpl::GetInstance(); | 1759 ChildProcessSecurityPolicyImpl::GetInstance(); |
1759 if (policy->CanReadDirectory(GetRenderProcessHost()->GetID(), path)) | 1760 if (policy->CanReadDirectory(GetRenderProcessHost()->GetID(), path)) |
1760 delegate_->EnumerateDirectory(this, request_id, path); | 1761 delegate_->EnumerateDirectory(this, request_id, path); |
1761 } | 1762 } |
1762 | 1763 |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2696 static_cast<RenderViewHostImpl*>( | 2697 static_cast<RenderViewHostImpl*>( |
2697 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); | 2698 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); |
2698 } | 2699 } |
2699 | 2700 |
2700 void WebContentsImpl::SetEncoding(const std::string& encoding) { | 2701 void WebContentsImpl::SetEncoding(const std::string& encoding) { |
2701 encoding_ = content::GetContentClient()->browser()-> | 2702 encoding_ = content::GetContentClient()->browser()-> |
2702 GetCanonicalEncodingNameByAliasName(encoding); | 2703 GetCanonicalEncodingNameByAliasName(encoding); |
2703 } | 2704 } |
2704 | 2705 |
2705 void WebContentsImpl::SaveURL(const GURL& url, | 2706 void WebContentsImpl::SaveURL(const GURL& url, |
2706 const GURL& referrer, | 2707 const content::Referrer& referrer, |
2707 bool is_main_frame) { | 2708 bool is_main_frame) { |
2708 DownloadManager* dlm = GetBrowserContext()->GetDownloadManager(); | 2709 DownloadManager* dlm = GetBrowserContext()->GetDownloadManager(); |
2709 if (!dlm) | 2710 if (!dlm) |
2710 return; | 2711 return; |
2711 int64 post_id = -1; | 2712 int64 post_id = -1; |
2712 if (is_main_frame) { | 2713 if (is_main_frame) { |
2713 const NavigationEntry* entry = controller_.GetActiveEntry(); | 2714 const NavigationEntry* entry = controller_.GetActiveEntry(); |
2714 if (entry) | 2715 if (entry) |
2715 post_id = entry->GetPostID(); | 2716 post_id = entry->GetPostID(); |
2716 } | 2717 } |
2717 content::DownloadSaveInfo save_info; | 2718 content::DownloadSaveInfo save_info; |
2718 save_info.prompt_for_save_location = true; | 2719 save_info.prompt_for_save_location = true; |
2719 scoped_ptr<DownloadUrlParameters> params( | 2720 scoped_ptr<DownloadUrlParameters> params( |
2720 DownloadUrlParameters::FromWebContents(this, url, save_info)); | 2721 DownloadUrlParameters::FromWebContents(this, url, save_info)); |
2721 params->set_referrer(referrer); | 2722 // TODO(jochen): Pass in the referrer policy as well. |
benjhayden
2012/05/14 13:56:20
Any reason not to do this in this cl?
jochen (gone - plz use gerrit)
2012/05/14 14:11:22
Yes, because then I need to change all places that
| |
2723 params->set_referrer(referrer.url); | |
2722 params->set_post_id(post_id); | 2724 params->set_post_id(post_id); |
2723 params->set_prefer_cache(true); | 2725 params->set_prefer_cache(true); |
2724 if (post_id >= 0) | 2726 if (post_id >= 0) |
2725 params->set_method("POST"); | 2727 params->set_method("POST"); |
2726 dlm->DownloadUrl(params.Pass()); | 2728 dlm->DownloadUrl(params.Pass()); |
2727 } | 2729 } |
2728 | 2730 |
2729 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2731 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2730 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2732 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
2731 // Can be NULL during tests. | 2733 // Can be NULL during tests. |
2732 if (rwh_view) | 2734 if (rwh_view) |
2733 rwh_view->SetSize(GetView()->GetContainerSize()); | 2735 rwh_view->SetSize(GetView()->GetContainerSize()); |
2734 } | 2736 } |
2735 | 2737 |
2736 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { | 2738 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
2737 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 2739 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
2738 } | 2740 } |
OLD | NEW |