diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-08 08:00:02 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-08 08:00:02 +0000 |
commit | 3184770afa9cbcf49680bab5046c57a7ca035388 (patch) | |
tree | 13a9bc2a635bc23bcdab1368acaf3740dfafd406 /chrome/browser/download/save_package.cc | |
parent | cba313cf4f0dd47d76992947e711d41bd6448598 (diff) | |
download | chromium_src-3184770afa9cbcf49680bab5046c57a7ca035388.zip chromium_src-3184770afa9cbcf49680bab5046c57a7ca035388.tar.gz chromium_src-3184770afa9cbcf49680bab5046c57a7ca035388.tar.bz2 |
Browser and unit test cases for patch submitted for Issue 23584 under
http://codereview.chromium.org/660264.
BUG=23584
TEST=covered by unit tests and browser tests
Original patch by Chamal De Silva <chamal.desilva@gmail.com> at
http://codereview.chromium.org/669262/show
Review URL: http://codereview.chromium.org/1562017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43934 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/save_package.cc')
-rw-r--r-- | chrome/browser/download/save_package.cc | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc index 87b11a9..a549e9c 100644 --- a/chrome/browser/download/save_package.cc +++ b/chrome/browser/download/save_package.cc @@ -167,7 +167,7 @@ SavePackage::SavePackage(TabContents* web_content, tab_id_(web_content->GetRenderProcessHost()->id()), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { DCHECK(web_content); - const GURL& current_page_url = tab_contents_->GetURL(); + const GURL& current_page_url = GetUrlToBeSaved(); DCHECK(current_page_url.is_valid()); page_url_ = current_page_url; DCHECK(save_type_ == SAVE_AS_ONLY_HTML || @@ -192,14 +192,7 @@ SavePackage::SavePackage(TabContents* tab_contents) tab_id_(tab_contents->GetRenderProcessHost()->id()), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { - // Instead of using tab_contents_.GetURL here, we use url() - // (which is the "real" url of the page) - // from the NavigationEntry because its reflects their origin - // rather than the displayed one (returned by GetURL) which may be - // different (like having "view-source:" on the front). - NavigationEntry* active_entry = - tab_contents_->controller().GetActiveEntry(); - const GURL& current_page_url = active_entry->url(); + const GURL& current_page_url = GetUrlToBeSaved(); DCHECK(current_page_url.is_valid()); page_url_ = current_page_url; InternalInit(); @@ -208,10 +201,11 @@ SavePackage::SavePackage(TabContents* tab_contents) // This is for testing use. Set |finished_| as true because we don't want // method Cancel to be be called in destructor in test mode. // We also don't call InternalInit(). -SavePackage::SavePackage(const FilePath& file_full_path, +SavePackage::SavePackage(TabContents* tab_contents, + const FilePath& file_full_path, const FilePath& directory_full_path) : file_manager_(NULL), - tab_contents_(NULL), + tab_contents_(tab_contents), download_(NULL), saved_main_file_path_(file_full_path), saved_main_directory_path_(directory_full_path), @@ -267,6 +261,18 @@ SavePackage::~SavePackage() { select_file_dialog_->ListenerDestroyed(); } +// Retrieves the URL to be saved from tab_contents_ variable. +GURL SavePackage::GetUrlToBeSaved() { + // Instead of using tab_contents_.GetURL here, we use url() + // (which is the "real" url of the page) + // from the NavigationEntry because it reflects its' origin + // rather than the displayed one (returned by GetURL) which may be + // different (like having "view-source:" on the front). + NavigationEntry* active_entry = + tab_contents_->controller().GetActiveEntry(); + return active_entry->url(); +} + // Cancel all in progress request, might be called by user or internal error. void SavePackage::Cancel(bool user_action) { if (!canceled()) { |