Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" | |
| 17 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 18 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 19 #include "base/process/process.h" | 20 #include "base/process/process.h" |
| 20 #include "base/profiler/scoped_tracker.h" | 21 #include "base/profiler/scoped_tracker.h" |
| 21 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
| 22 #include "base/strings/string16.h" | 23 #include "base/strings/string16.h" |
| 23 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 26 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 2720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2747 RecordDownloadSource(INITIATED_BY_SAVE_PACKAGE_ON_NON_HTML); | 2748 RecordDownloadSource(INITIATED_BY_SAVE_PACKAGE_ON_NON_HTML); |
| 2748 SaveFrame(GetLastCommittedURL(), Referrer()); | 2749 SaveFrame(GetLastCommittedURL(), Referrer()); |
| 2749 return; | 2750 return; |
| 2750 } | 2751 } |
| 2751 | 2752 |
| 2752 Stop(); | 2753 Stop(); |
| 2753 | 2754 |
| 2754 // Create the save package and possibly prompt the user for the name to save | 2755 // Create the save package and possibly prompt the user for the name to save |
| 2755 // the page as. The user prompt is an asynchronous operation that runs on | 2756 // the page as. The user prompt is an asynchronous operation that runs on |
| 2756 // another thread. | 2757 // another thread. |
| 2757 save_package_ = new SavePackage(this); | 2758 save_package_ = base::WrapUnique(new SavePackage(this)); |
|
asanka
2016/06/06 18:55:09
Here and elsewhere:
Assigning a unique_ptr and re
| |
| 2758 save_package_->GetSaveInfo(); | 2759 save_package_->GetSaveInfo(); |
| 2759 } | 2760 } |
| 2760 | 2761 |
| 2761 // Used in automated testing to bypass prompting the user for file names. | 2762 // Used in automated testing to bypass prompting the user for file names. |
| 2762 // Instead, the names and paths are hard coded rather than running them through | 2763 // Instead, the names and paths are hard coded rather than running them through |
| 2763 // file name sanitation and extension / mime checking. | 2764 // file name sanitation and extension / mime checking. |
| 2764 bool WebContentsImpl::SavePage(const base::FilePath& main_file, | 2765 bool WebContentsImpl::SavePage(const base::FilePath& main_file, |
| 2765 const base::FilePath& dir_path, | 2766 const base::FilePath& dir_path, |
| 2766 SavePageType save_type) { | 2767 SavePageType save_type) { |
| 2767 // Stop the page from navigating. | 2768 // Stop the page from navigating. |
| 2768 Stop(); | 2769 Stop(); |
| 2769 | 2770 |
| 2770 save_package_ = new SavePackage(this, save_type, main_file, dir_path); | 2771 save_package_ = |
| 2772 base::WrapUnique(new SavePackage(this, save_type, main_file, dir_path)); | |
| 2771 return save_package_->Init(SavePackageDownloadCreatedCallback()); | 2773 return save_package_->Init(SavePackageDownloadCreatedCallback()); |
| 2772 } | 2774 } |
| 2773 | 2775 |
| 2774 void WebContentsImpl::SaveFrame(const GURL& url, | 2776 void WebContentsImpl::SaveFrame(const GURL& url, |
| 2775 const Referrer& referrer) { | 2777 const Referrer& referrer) { |
| 2776 SaveFrameWithHeaders(url, referrer, std::string()); | 2778 SaveFrameWithHeaders(url, referrer, std::string()); |
| 2777 } | 2779 } |
| 2778 | 2780 |
| 2779 void WebContentsImpl::SaveFrameWithHeaders(const GURL& url, | 2781 void WebContentsImpl::SaveFrameWithHeaders(const GURL& url, |
| 2780 const Referrer& referrer, | 2782 const Referrer& referrer, |
| (...skipping 2289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5070 for (RenderViewHost* render_view_host : render_view_host_set) | 5072 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5071 render_view_host->OnWebkitPreferencesChanged(); | 5073 render_view_host->OnWebkitPreferencesChanged(); |
| 5072 } | 5074 } |
| 5073 | 5075 |
| 5074 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5076 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
| 5075 JavaScriptDialogManager* dialog_manager) { | 5077 JavaScriptDialogManager* dialog_manager) { |
| 5076 dialog_manager_ = dialog_manager; | 5078 dialog_manager_ = dialog_manager; |
| 5077 } | 5079 } |
| 5078 | 5080 |
| 5079 } // namespace content | 5081 } // namespace content |
| OLD | NEW |