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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #include "content/public/browser/notification_details.h" | 65 #include "content/public/browser/notification_details.h" |
66 #include "content/public/browser/notification_service.h" | 66 #include "content/public/browser/notification_service.h" |
67 #include "content/public/browser/resource_request_details.h" | 67 #include "content/public/browser/resource_request_details.h" |
68 #include "content/public/browser/storage_partition.h" | 68 #include "content/public/browser/storage_partition.h" |
69 #include "content/public/browser/user_metrics.h" | 69 #include "content/public/browser/user_metrics.h" |
70 #include "content/public/browser/web_contents_delegate.h" | 70 #include "content/public/browser/web_contents_delegate.h" |
71 #include "content/public/browser/web_contents_observer.h" | 71 #include "content/public/browser/web_contents_observer.h" |
72 #include "content/public/browser/web_contents_view.h" | 72 #include "content/public/browser/web_contents_view.h" |
73 #include "content/public/common/bindings_policy.h" | 73 #include "content/public/common/bindings_policy.h" |
74 #include "content/public/common/content_constants.h" | 74 #include "content/public/common/content_constants.h" |
75 #include "content/public/common/content_restriction.h" | |
76 #include "content/public/common/content_switches.h" | 75 #include "content/public/common/content_switches.h" |
77 #include "content/public/common/url_constants.h" | 76 #include "content/public/common/url_constants.h" |
78 #include "net/base/mime_util.h" | 77 #include "net/base/mime_util.h" |
79 #include "net/base/net_util.h" | 78 #include "net/base/net_util.h" |
80 #include "net/base/network_change_notifier.h" | 79 #include "net/base/network_change_notifier.h" |
81 #include "net/url_request/url_request_context_getter.h" | 80 #include "net/url_request/url_request_context_getter.h" |
82 #include "third_party/WebKit/public/web/WebView.h" | 81 #include "third_party/WebKit/public/web/WebView.h" |
83 #include "ui/base/layout.h" | 82 #include "ui/base/layout.h" |
84 #include "ui/base/touch/touch_device.h" | 83 #include "ui/base/touch/touch_device.h" |
85 #include "ui/base/ui_base_switches.h" | 84 #include "ui/base/ui_base_switches.h" |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 capturer_count_(0), | 348 capturer_count_(0), |
350 should_normally_be_visible_(true), | 349 should_normally_be_visible_(true), |
351 is_being_destroyed_(false), | 350 is_being_destroyed_(false), |
352 notify_disconnection_(false), | 351 notify_disconnection_(false), |
353 dialog_manager_(NULL), | 352 dialog_manager_(NULL), |
354 is_showing_before_unload_dialog_(false), | 353 is_showing_before_unload_dialog_(false), |
355 closed_by_user_gesture_(false), | 354 closed_by_user_gesture_(false), |
356 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), | 355 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), |
357 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), | 356 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
358 temporary_zoom_settings_(false), | 357 temporary_zoom_settings_(false), |
359 content_restrictions_(0), | |
360 color_chooser_identifier_(0), | 358 color_chooser_identifier_(0), |
361 message_source_(NULL), | 359 message_source_(NULL), |
362 fullscreen_widget_routing_id_(MSG_ROUTING_NONE) { | 360 fullscreen_widget_routing_id_(MSG_ROUTING_NONE) { |
363 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) | 361 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
364 g_created_callbacks.Get().at(i).Run(this); | 362 g_created_callbacks.Get().at(i).Run(this); |
365 } | 363 } |
366 | 364 |
367 WebContentsImpl::~WebContentsImpl() { | 365 WebContentsImpl::~WebContentsImpl() { |
368 is_being_destroyed_ = true; | 366 is_being_destroyed_ = true; |
369 | 367 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 OnDidLoadResourceFromMemoryCache) | 683 OnDidLoadResourceFromMemoryCache) |
686 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent, | 684 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent, |
687 OnDidDisplayInsecureContent) | 685 OnDidDisplayInsecureContent) |
688 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, | 686 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, |
689 OnDidRunInsecureContent) | 687 OnDidRunInsecureContent) |
690 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, | 688 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, |
691 OnDocumentLoadedInFrame) | 689 OnDocumentLoadedInFrame) |
692 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) | 690 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) |
693 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailLoadWithError, | 691 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailLoadWithError, |
694 OnDidFailLoadWithError) | 692 OnDidFailLoadWithError) |
695 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, | |
696 OnUpdateContentRestrictions) | |
697 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) | 693 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) |
698 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) | 694 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) |
699 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL) | |
700 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) | 695 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) |
701 IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory) | 696 IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory) |
702 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, | 697 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, |
703 OnRegisterProtocolHandler) | 698 OnRegisterProtocolHandler) |
704 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) | 699 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) |
705 IPC_MESSAGE_HANDLER(ViewHostMsg_DidProgrammaticallyScroll, | 700 IPC_MESSAGE_HANDLER(ViewHostMsg_DidProgrammaticallyScroll, |
706 OnDidProgrammaticallyScroll) | 701 OnDidProgrammaticallyScroll) |
707 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) | 702 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) |
708 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 703 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
709 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) | 704 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 contents_mime_type_ == "application/xhtml+xml" || | 1871 contents_mime_type_ == "application/xhtml+xml" || |
1877 contents_mime_type_ == "text/plain" || | 1872 contents_mime_type_ == "text/plain" || |
1878 contents_mime_type_ == "text/css" || | 1873 contents_mime_type_ == "text/css" || |
1879 net::IsSupportedJavascriptMimeType(contents_mime_type_.c_str()); | 1874 net::IsSupportedJavascriptMimeType(contents_mime_type_.c_str()); |
1880 } | 1875 } |
1881 | 1876 |
1882 void WebContentsImpl::OnSavePage() { | 1877 void WebContentsImpl::OnSavePage() { |
1883 // If we can not save the page, try to download it. | 1878 // If we can not save the page, try to download it. |
1884 if (!IsSavable()) { | 1879 if (!IsSavable()) { |
1885 RecordDownloadSource(INITIATED_BY_SAVE_PACKAGE_ON_NON_HTML); | 1880 RecordDownloadSource(INITIATED_BY_SAVE_PACKAGE_ON_NON_HTML); |
1886 SaveURL(GetURL(), Referrer(), true); | 1881 SaveFrame(GetURL(), Referrer()); |
1887 return; | 1882 return; |
1888 } | 1883 } |
1889 | 1884 |
1890 Stop(); | 1885 Stop(); |
1891 | 1886 |
1892 // Create the save package and possibly prompt the user for the name to save | 1887 // Create the save package and possibly prompt the user for the name to save |
1893 // the page as. The user prompt is an asynchronous operation that runs on | 1888 // the page as. The user prompt is an asynchronous operation that runs on |
1894 // another thread. | 1889 // another thread. |
1895 save_package_ = new SavePackage(this); | 1890 save_package_ = new SavePackage(this); |
1896 save_package_->GetSaveInfo(); | 1891 save_package_->GetSaveInfo(); |
1897 } | 1892 } |
1898 | 1893 |
1899 // Used in automated testing to bypass prompting the user for file names. | 1894 // Used in automated testing to bypass prompting the user for file names. |
1900 // Instead, the names and paths are hard coded rather than running them through | 1895 // Instead, the names and paths are hard coded rather than running them through |
1901 // file name sanitation and extension / mime checking. | 1896 // file name sanitation and extension / mime checking. |
1902 bool WebContentsImpl::SavePage(const base::FilePath& main_file, | 1897 bool WebContentsImpl::SavePage(const base::FilePath& main_file, |
1903 const base::FilePath& dir_path, | 1898 const base::FilePath& dir_path, |
1904 SavePageType save_type) { | 1899 SavePageType save_type) { |
1905 // Stop the page from navigating. | 1900 // Stop the page from navigating. |
1906 Stop(); | 1901 Stop(); |
1907 | 1902 |
1908 save_package_ = new SavePackage(this, save_type, main_file, dir_path); | 1903 save_package_ = new SavePackage(this, save_type, main_file, dir_path); |
1909 return save_package_->Init(SavePackageDownloadCreatedCallback()); | 1904 return save_package_->Init(SavePackageDownloadCreatedCallback()); |
1910 } | 1905 } |
1911 | 1906 |
| 1907 void WebContentsImpl::SaveFrame(const GURL& url, |
| 1908 const Referrer& referrer) { |
| 1909 if (!GetURL().is_valid()) |
| 1910 return; |
| 1911 bool is_main_frame = (url == GetURL()); |
| 1912 |
| 1913 DownloadManager* dlm = |
| 1914 BrowserContext::GetDownloadManager(GetBrowserContext()); |
| 1915 if (!dlm) |
| 1916 return; |
| 1917 int64 post_id = -1; |
| 1918 if (is_main_frame) { |
| 1919 const NavigationEntry* entry = controller_.GetActiveEntry(); |
| 1920 if (entry) |
| 1921 post_id = entry->GetPostID(); |
| 1922 } |
| 1923 scoped_ptr<DownloadUrlParameters> params( |
| 1924 DownloadUrlParameters::FromWebContents(this, url)); |
| 1925 params->set_referrer(referrer); |
| 1926 params->set_post_id(post_id); |
| 1927 params->set_prefer_cache(true); |
| 1928 if (post_id >= 0) |
| 1929 params->set_method("POST"); |
| 1930 params->set_prompt(true); |
| 1931 dlm->DownloadUrl(params.Pass()); |
| 1932 } |
| 1933 |
1912 void WebContentsImpl::GenerateMHTML( | 1934 void WebContentsImpl::GenerateMHTML( |
1913 const base::FilePath& file, | 1935 const base::FilePath& file, |
1914 const base::Callback<void(const base::FilePath&, int64)>& callback) { | 1936 const base::Callback<void(const base::FilePath&, int64)>& callback) { |
1915 MHTMLGenerationManager::GetInstance()->GenerateMHTML(this, file, callback); | 1937 MHTMLGenerationManager::GetInstance()->GenerateMHTML(this, file, callback); |
1916 } | 1938 } |
1917 | 1939 |
1918 bool WebContentsImpl::IsActiveEntry(int32 page_id) { | 1940 bool WebContentsImpl::IsActiveEntry(int32 page_id) { |
1919 NavigationEntryImpl* active_entry = | 1941 NavigationEntryImpl* active_entry = |
1920 NavigationEntryImpl::FromNavigationEntry(controller_.GetActiveEntry()); | 1942 NavigationEntryImpl::FromNavigationEntry(controller_.GetActiveEntry()); |
1921 return (active_entry != NULL && | 1943 return (active_entry != NULL && |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 } | 2070 } |
2049 | 2071 |
2050 int WebContentsImpl::GetMaximumZoomPercent() const { | 2072 int WebContentsImpl::GetMaximumZoomPercent() const { |
2051 return maximum_zoom_percent_; | 2073 return maximum_zoom_percent_; |
2052 } | 2074 } |
2053 | 2075 |
2054 gfx::Size WebContentsImpl::GetPreferredSize() const { | 2076 gfx::Size WebContentsImpl::GetPreferredSize() const { |
2055 return preferred_size_; | 2077 return preferred_size_; |
2056 } | 2078 } |
2057 | 2079 |
2058 int WebContentsImpl::GetContentRestrictions() const { | |
2059 return content_restrictions_; | |
2060 } | |
2061 | |
2062 bool WebContentsImpl::GotResponseToLockMouseRequest(bool allowed) { | 2080 bool WebContentsImpl::GotResponseToLockMouseRequest(bool allowed) { |
2063 return GetRenderViewHost() ? | 2081 return GetRenderViewHost() ? |
2064 GetRenderViewHostImpl()->GotResponseToLockMouseRequest(allowed) : false; | 2082 GetRenderViewHostImpl()->GotResponseToLockMouseRequest(allowed) : false; |
2065 } | 2083 } |
2066 | 2084 |
2067 bool WebContentsImpl::HasOpener() const { | 2085 bool WebContentsImpl::HasOpener() const { |
2068 return opener_ != NULL; | 2086 return opener_ != NULL; |
2069 } | 2087 } |
2070 | 2088 |
2071 void WebContentsImpl::DidChooseColorInColorChooser(SkColor color) { | 2089 void WebContentsImpl::DidChooseColorInColorChooser(SkColor color) { |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2308 const string16& error_description) { | 2326 const string16& error_description) { |
2309 GURL validated_url(url); | 2327 GURL validated_url(url); |
2310 RenderProcessHost* render_process_host = message_source_->GetProcess(); | 2328 RenderProcessHost* render_process_host = message_source_->GetProcess(); |
2311 RenderViewHost::FilterURL(render_process_host, false, &validated_url); | 2329 RenderViewHost::FilterURL(render_process_host, false, &validated_url); |
2312 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2330 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2313 DidFailLoad(frame_id, validated_url, is_main_frame, | 2331 DidFailLoad(frame_id, validated_url, is_main_frame, |
2314 error_code, error_description, | 2332 error_code, error_description, |
2315 message_source_)); | 2333 message_source_)); |
2316 } | 2334 } |
2317 | 2335 |
2318 void WebContentsImpl::OnUpdateContentRestrictions(int restrictions) { | |
2319 content_restrictions_ = restrictions; | |
2320 if (delegate_) | |
2321 delegate_->ContentRestrictionsChanged(this); | |
2322 } | |
2323 | |
2324 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { | 2336 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { |
2325 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) { | 2337 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) { |
2326 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | 2338 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( |
2327 controller_.GetEntryAtOffset(offset)); | 2339 controller_.GetEntryAtOffset(offset)); |
2328 if (!entry) | 2340 if (!entry) |
2329 return; | 2341 return; |
2330 // Note that we don't call NavigationController::GotToOffset() as we don't | 2342 // Note that we don't call NavigationController::GotToOffset() as we don't |
2331 // want to create a pending navigation entry (it might end up lingering | 2343 // want to create a pending navigation entry (it might end up lingering |
2332 // http://crbug.com/51680). | 2344 // http://crbug.com/51680). |
2333 entry->SetTransitionType( | 2345 entry->SetTransitionType( |
(...skipping 13 matching lines...) Expand all Loading... |
2347 } | 2359 } |
2348 | 2360 |
2349 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, | 2361 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, |
2350 int maximum_percent, | 2362 int maximum_percent, |
2351 bool remember) { | 2363 bool remember) { |
2352 minimum_zoom_percent_ = minimum_percent; | 2364 minimum_zoom_percent_ = minimum_percent; |
2353 maximum_zoom_percent_ = maximum_percent; | 2365 maximum_zoom_percent_ = maximum_percent; |
2354 temporary_zoom_settings_ = !remember; | 2366 temporary_zoom_settings_ = !remember; |
2355 } | 2367 } |
2356 | 2368 |
2357 void WebContentsImpl::OnSaveURL(const GURL& url, | |
2358 const Referrer& referrer) { | |
2359 RecordDownloadSource(INITIATED_BY_PEPPER_SAVE); | |
2360 // Check if the URL to save matches the URL of the main frame. Since this | |
2361 // message originates from Pepper plugins, it may not be the case if the | |
2362 // plugin is an embedded element. | |
2363 GURL main_frame_url = GetURL(); | |
2364 if (!main_frame_url.is_valid()) | |
2365 return; | |
2366 bool is_main_frame = (url == main_frame_url); | |
2367 SaveURL(url, referrer, is_main_frame); | |
2368 } | |
2369 | |
2370 void WebContentsImpl::OnEnumerateDirectory(int request_id, | 2369 void WebContentsImpl::OnEnumerateDirectory(int request_id, |
2371 const base::FilePath& path) { | 2370 const base::FilePath& path) { |
2372 if (!delegate_) | 2371 if (!delegate_) |
2373 return; | 2372 return; |
2374 | 2373 |
2375 ChildProcessSecurityPolicyImpl* policy = | 2374 ChildProcessSecurityPolicyImpl* policy = |
2376 ChildProcessSecurityPolicyImpl::GetInstance(); | 2375 ChildProcessSecurityPolicyImpl::GetInstance(); |
2377 if (policy->CanReadDirectory(GetRenderProcessHost()->GetID(), path)) | 2376 if (policy->CanReadDirectory(GetRenderProcessHost()->GetID(), path)) |
2378 delegate_->EnumerateDirectory(this, request_id, path); | 2377 delegate_->EnumerateDirectory(this, request_id, path); |
2379 } | 2378 } |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 } | 3126 } |
3128 | 3127 |
3129 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { | 3128 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { |
3130 if (delegate_ && delegate_->IsPopupOrPanel(this)) | 3129 if (delegate_ && delegate_->IsPopupOrPanel(this)) |
3131 delegate_->MoveContents(this, new_bounds); | 3130 delegate_->MoveContents(this, new_bounds); |
3132 } | 3131 } |
3133 | 3132 |
3134 void WebContentsImpl::DidStartLoading(RenderViewHost* render_view_host) { | 3133 void WebContentsImpl::DidStartLoading(RenderViewHost* render_view_host) { |
3135 SetIsLoading(true, NULL); | 3134 SetIsLoading(true, NULL); |
3136 | 3135 |
3137 if (delegate_ && content_restrictions_) | |
3138 OnUpdateContentRestrictions(0); | |
3139 | |
3140 // Notify observers about navigation. | 3136 // Notify observers about navigation. |
3141 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3137 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3142 DidStartLoading(render_view_host)); | 3138 DidStartLoading(render_view_host)); |
3143 } | 3139 } |
3144 | 3140 |
3145 void WebContentsImpl::DidStopLoading(RenderViewHost* render_view_host) { | 3141 void WebContentsImpl::DidStopLoading(RenderViewHost* render_view_host) { |
3146 scoped_ptr<LoadNotificationDetails> details; | 3142 scoped_ptr<LoadNotificationDetails> details; |
3147 | 3143 |
3148 // Use the last committed entry rather than the active one, in case a | 3144 // Use the last committed entry rather than the active one, in case a |
3149 // pending entry has been created. | 3145 // pending entry has been created. |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3673 is_showing_before_unload_dialog_ = false; | 3669 is_showing_before_unload_dialog_ = false; |
3674 static_cast<RenderViewHostImpl*>( | 3670 static_cast<RenderViewHostImpl*>( |
3675 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); | 3671 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); |
3676 } | 3672 } |
3677 | 3673 |
3678 void WebContentsImpl::SetEncoding(const std::string& encoding) { | 3674 void WebContentsImpl::SetEncoding(const std::string& encoding) { |
3679 encoding_ = GetContentClient()->browser()-> | 3675 encoding_ = GetContentClient()->browser()-> |
3680 GetCanonicalEncodingNameByAliasName(encoding); | 3676 GetCanonicalEncodingNameByAliasName(encoding); |
3681 } | 3677 } |
3682 | 3678 |
3683 void WebContentsImpl::SaveURL(const GURL& url, | |
3684 const Referrer& referrer, | |
3685 bool is_main_frame) { | |
3686 DownloadManager* dlm = | |
3687 BrowserContext::GetDownloadManager(GetBrowserContext()); | |
3688 if (!dlm) | |
3689 return; | |
3690 int64 post_id = -1; | |
3691 if (is_main_frame) { | |
3692 const NavigationEntry* entry = controller_.GetActiveEntry(); | |
3693 if (entry) | |
3694 post_id = entry->GetPostID(); | |
3695 } | |
3696 scoped_ptr<DownloadUrlParameters> params( | |
3697 DownloadUrlParameters::FromWebContents(this, url)); | |
3698 params->set_referrer(referrer); | |
3699 params->set_post_id(post_id); | |
3700 params->set_prefer_cache(true); | |
3701 if (post_id >= 0) | |
3702 params->set_method("POST"); | |
3703 params->set_prompt(true); | |
3704 dlm->DownloadUrl(params.Pass()); | |
3705 } | |
3706 | |
3707 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 3679 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
3708 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(rvh); | 3680 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(rvh); |
3709 // Can be NULL during tests. | 3681 // Can be NULL during tests. |
3710 if (rwh_view) | 3682 if (rwh_view) |
3711 rwh_view->SetSize(GetView()->GetContainerSize()); | 3683 rwh_view->SetSize(GetView()->GetContainerSize()); |
3712 } | 3684 } |
3713 | 3685 |
3714 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { | 3686 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
3715 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 3687 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
3716 } | 3688 } |
(...skipping 25 matching lines...) Expand all Loading... |
3742 } | 3714 } |
3743 | 3715 |
3744 void WebContentsImpl::ClearAllPowerSaveBlockers() { | 3716 void WebContentsImpl::ClearAllPowerSaveBlockers() { |
3745 for (PowerSaveBlockerMap::iterator i(power_save_blockers_.begin()); | 3717 for (PowerSaveBlockerMap::iterator i(power_save_blockers_.begin()); |
3746 i != power_save_blockers_.end(); ++i) | 3718 i != power_save_blockers_.end(); ++i) |
3747 STLDeleteValues(&power_save_blockers_[i->first]); | 3719 STLDeleteValues(&power_save_blockers_[i->first]); |
3748 power_save_blockers_.clear(); | 3720 power_save_blockers_.clear(); |
3749 } | 3721 } |
3750 | 3722 |
3751 } // namespace content | 3723 } // namespace content |
OLD | NEW |