summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-12 01:56:32 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-12 01:56:32 +0000
commitf6b4853153c6be7a7ce092d4c5f3172c022da561 (patch)
tree99f03bfa0866d1441f37f979d88c82f3fb51180f
parent5e5136c2a2fc497ada68dadfacfd9068ee22f36f (diff)
downloadchromium_src-f6b4853153c6be7a7ce092d4c5f3172c022da561.zip
chromium_src-f6b4853153c6be7a7ce092d4c5f3172c022da561.tar.gz
chromium_src-f6b4853153c6be7a7ce092d4c5f3172c022da561.tar.bz2
Change url wstrings to GURLS
Review URL: http://codereview.chromium.org/20273 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9635 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/download/download_file.cc5
-rw-r--r--chrome/browser/download/download_file.h2
-rw-r--r--chrome/browser/download/download_manager.cc2
-rw-r--r--chrome/browser/download/download_manager.h8
-rw-r--r--chrome/browser/download/download_manager_unittest.cc112
-rw-r--r--chrome/browser/download/download_util.cc2
-rw-r--r--chrome/browser/download/save_file_manager.cc40
-rw-r--r--chrome/browser/download/save_file_manager.h18
-rw-r--r--chrome/browser/download/save_item.cc4
-rw-r--r--chrome/browser/download/save_item.h13
-rw-r--r--chrome/browser/download/save_package.cc37
-rw-r--r--chrome/browser/download/save_package.h6
-rw-r--r--chrome/browser/download/save_types.h7
-rw-r--r--chrome/browser/history/download_database.cc6
-rw-r--r--chrome/browser/history/download_types.h5
-rw-r--r--chrome/browser/history/history_unittest.cc2
-rw-r--r--chrome/browser/renderer_host/buffered_resource_handler.cc2
-rw-r--r--chrome/browser/renderer_host/download_resource_handler.cc6
-rw-r--r--chrome/browser/renderer_host/download_resource_handler.h4
-rw-r--r--chrome/browser/renderer_host/download_throttling_resource_handler.cc4
-rw-r--r--chrome/browser/renderer_host/download_throttling_resource_handler.h5
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc2
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc4
-rw-r--r--chrome/browser/renderer_host/save_file_resource_handler.cc6
-rw-r--r--chrome/browser/renderer_host/save_file_resource_handler.h6
-rw-r--r--chrome/common/render_messages_internal.h2
-rw-r--r--chrome/common/temp_scaffolding_stubs.h2
-rw-r--r--chrome/renderer/render_view.cc2
-rw-r--r--chrome/renderer/render_view.h2
-rw-r--r--webkit/glue/dom_serializer.cc32
-rw-r--r--webkit/glue/dom_serializer.h9
-rw-r--r--webkit/glue/dom_serializer_unittest.cc148
33 files changed, 248 insertions, 259 deletions
diff --git a/chrome/browser/download/download_file.cc b/chrome/browser/download/download_file.cc
index d3c7c63..7d03acb 100644
--- a/chrome/browser/download/download_file.cc
+++ b/chrome/browser/download/download_file.cc
@@ -531,12 +531,13 @@ void DownloadFileManager::OnShowDownloadInShell(const FilePath& full_path) {
// a valid parent window, the 'safer' version will be used which can
// display a modal dialog asking for user consent on dangerous files.
void DownloadFileManager::OnOpenDownloadInShell(const FilePath& full_path,
- const std::wstring& url,
+ const GURL& url,
gfx::NativeView parent_window) {
#if defined(OS_WIN)
DCHECK(MessageLoop::current() == file_loop_);
if (NULL != parent_window) {
- win_util::SaferOpenItemViaShell(parent_window, L"", full_path, url, true);
+ win_util::SaferOpenItemViaShell(parent_window, L"", full_path,
+ UTF8ToWide(url.spec()), true);
} else {
win_util::OpenItemViaShell(full_path, true);
}
diff --git a/chrome/browser/download/download_file.h b/chrome/browser/download/download_file.h
index ebc1dde..9991c03 100644
--- a/chrome/browser/download/download_file.h
+++ b/chrome/browser/download/download_file.h
@@ -200,7 +200,7 @@ class DownloadFileManager
void OnShowDownloadInShell(const FilePath& full_path);
// Handler to open or execute a downloaded file.
void OnOpenDownloadInShell(const FilePath& full_path,
- const std::wstring& url,
+ const GURL& url,
gfx::NativeView parent_window);
// The download manager has provided a final name for a download. Sent from
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc
index d448f0a..5747c3b 100644
--- a/chrome/browser/download/download_manager.cc
+++ b/chrome/browser/download/download_manager.cc
@@ -126,7 +126,7 @@ DownloadItem::DownloadItem(const DownloadCreateInfo& info)
DownloadItem::DownloadItem(int32 download_id,
const FilePath& path,
int path_uniquifier,
- const std::wstring& url,
+ const GURL& url,
const FilePath& original_name,
const base::Time start_time,
int64 download_size,
diff --git a/chrome/browser/download/download_manager.h b/chrome/browser/download/download_manager.h
index f718094..942361b 100644
--- a/chrome/browser/download/download_manager.h
+++ b/chrome/browser/download/download_manager.h
@@ -103,7 +103,7 @@ class DownloadItem {
DownloadItem(int32 download_id,
const FilePath& path,
int path_uniquifier,
- const std::wstring& url,
+ const GURL& url,
const FilePath& original_name,
const base::Time start_time,
int64 download_size,
@@ -176,7 +176,7 @@ class DownloadItem {
void set_full_path(const FilePath& path) { full_path_ = path; }
int path_uniquifier() const { return path_uniquifier_; }
void set_path_uniquifier(int uniquifier) { path_uniquifier_ = uniquifier; }
- std::wstring url() const { return url_; }
+ GURL url() const { return url_; }
int64 total_bytes() const { return total_bytes_; }
void set_total_bytes(int64 total_bytes) { total_bytes_ = total_bytes; }
int64 received_bytes() const { return received_bytes_; }
@@ -221,8 +221,8 @@ class DownloadItem {
// Short display version of the file
FilePath file_name_;
- // The URL from whence we came, for display
- std::wstring url_;
+ // The URL from whence we came.
+ GURL url_;
// Total bytes expected
int64 total_bytes_;
diff --git a/chrome/browser/download/download_manager_unittest.cc b/chrome/browser/download/download_manager_unittest.cc
index 51feb5b..3771030 100644
--- a/chrome/browser/download/download_manager_unittest.cc
+++ b/chrome/browser/download/download_manager_unittest.cc
@@ -17,12 +17,12 @@ class DownloadManagerTest : public testing::Test {
}
void GetGeneratedFilename(const std::string& content_disposition,
- const std::wstring& url,
+ const std::string& url,
const std::string& mime_type,
std::wstring* generated_name_string) {
DownloadCreateInfo info;
info.content_disposition = content_disposition;
- info.url = url;
+ info.url = GURL(url);
info.mime_type = mime_type;
FilePath generated_name;
download_manager_->GenerateFilename(&info, &generated_name);
@@ -40,277 +40,277 @@ namespace {
const struct {
const char* disposition;
- const wchar_t* url;
+ const char* url;
const char* mime_type;
const wchar_t* expected_name;
} kGeneratedFiles[] = {
// No 'filename' keyword in the disposition, use the URL
{"a_file_name.txt",
- L"http://www.evil.com/my_download.txt",
+ "http://www.evil.com/my_download.txt",
"text/plain",
L"my_download.txt"},
// Disposition has relative paths, remove them
{"filename=../../../../././../a_file_name.txt",
- L"http://www.evil.com/my_download.txt",
+ "http://www.evil.com/my_download.txt",
"text/plain",
L"a_file_name.txt"},
// Disposition has parent directories, remove them
{"filename=dir1/dir2/a_file_name.txt",
- L"http://www.evil.com/my_download.txt",
+ "http://www.evil.com/my_download.txt",
"text/plain",
L"a_file_name.txt"},
// No useful information in disposition or URL, use default
- {"", L"http://www.truncated.com/path/", "text/plain", L"download.txt"},
+ {"", "http://www.truncated.com/path/", "text/plain", L"download.txt"},
// A normal avi should get .avi and not .avi.avi
- {"", L"https://blah.google.com/misc/2.avi", "video/x-msvideo", L"2.avi"},
+ {"", "https://blah.google.com/misc/2.avi", "video/x-msvideo", L"2.avi"},
// Spaces in the disposition file name
{"filename=My Downloaded File.exe",
- L"http://www.frontpagehacker.com/a_download.exe",
+ "http://www.frontpagehacker.com/a_download.exe",
"application/octet-stream",
L"My Downloaded File.exe"},
{"filename=my-cat",
- L"http://www.example.com/my-cat",
+ "http://www.example.com/my-cat",
"image/jpeg",
L"my-cat.jpg"},
{"filename=my-cat",
- L"http://www.example.com/my-cat",
+ "http://www.example.com/my-cat",
"text/plain",
L"my-cat.txt"},
{"filename=my-cat",
- L"http://www.example.com/my-cat",
+ "http://www.example.com/my-cat",
"text/html",
L"my-cat.htm"},
{"filename=my-cat",
- L"http://www.example.com/my-cat",
+ "http://www.example.com/my-cat",
"dance/party",
L"my-cat"},
{"filename=my-cat.jpg",
- L"http://www.example.com/my-cat.jpg",
+ "http://www.example.com/my-cat.jpg",
"text/plain",
L"my-cat.jpg"},
{"filename=evil.exe",
- L"http://www.goodguy.com/evil.exe",
+ "http://www.goodguy.com/evil.exe",
"image/jpeg",
L"evil.jpg"},
{"filename=ok.exe",
- L"http://www.goodguy.com/ok.exe",
+ "http://www.goodguy.com/ok.exe",
"binary/octet-stream",
L"ok.exe"},
{"filename=evil.exe.exe",
- L"http://www.goodguy.com/evil.exe.exe",
+ "http://www.goodguy.com/evil.exe.exe",
"dance/party",
L"evil.exe.download"},
{"filename=evil.exe",
- L"http://www.goodguy.com/evil.exe",
+ "http://www.goodguy.com/evil.exe",
"application/xml",
L"evil.xml"},
{"filename=evil.exe",
- L"http://www.goodguy.com/evil.exe",
+ "http://www.goodguy.com/evil.exe",
"application/html+xml",
L"evil.download"},
{"filename=evil.exe",
- L"http://www.goodguy.com/evil.exe",
+ "http://www.goodguy.com/evil.exe",
"application/rss+xml",
L"evil.download"},
{"filename=utils.js",
- L"http://www.goodguy.com/utils.js",
+ "http://www.goodguy.com/utils.js",
"application/x-javascript",
L"utils.js"},
{"filename=contacts.js",
- L"http://www.goodguy.com/contacts.js",
+ "http://www.goodguy.com/contacts.js",
"application/json",
L"contacts.js"},
{"filename=utils.js",
- L"http://www.goodguy.com/utils.js",
+ "http://www.goodguy.com/utils.js",
"text/javascript",
L"utils.js"},
{"filename=utils.js",
- L"http://www.goodguy.com/utils.js",
+ "http://www.goodguy.com/utils.js",
"text/javascript;version=2",
L"utils.js"},
{"filename=utils.js",
- L"http://www.goodguy.com/utils.js",
+ "http://www.goodguy.com/utils.js",
"application/ecmascript",
L"utils.js"},
{"filename=utils.js",
- L"http://www.goodguy.com/utils.js",
+ "http://www.goodguy.com/utils.js",
"application/ecmascript;version=4",
L"utils.js"},
{"filename=program.exe",
- L"http://www.goodguy.com/program.exe",
+ "http://www.goodguy.com/program.exe",
"application/foo-bar",
L"program.exe"},
{"filename=../foo.txt",
- L"http://www.evil.com/../foo.txt",
+ "http://www.evil.com/../foo.txt",
"text/plain",
L"foo.txt"},
{"filename=..\\foo.txt",
- L"http://www.evil.com/..\\foo.txt",
+ "http://www.evil.com/..\\foo.txt",
"text/plain",
L"foo.txt"},
{"filename=.hidden",
- L"http://www.evil.com/.hidden",
+ "http://www.evil.com/.hidden",
"text/plain",
L"hidden.txt"},
{"filename=trailing.",
- L"http://www.evil.com/trailing.",
+ "http://www.evil.com/trailing.",
"dance/party",
L"trailing"},
{"filename=trailing.",
- L"http://www.evil.com/trailing.",
+ "http://www.evil.com/trailing.",
"text/plain",
L"trailing.txt"},
{"filename=.",
- L"http://www.evil.com/.",
+ "http://www.evil.com/.",
"dance/party",
L"download"},
{"filename=..",
- L"http://www.evil.com/..",
+ "http://www.evil.com/..",
"dance/party",
L"download"},
{"filename=...",
- L"http://www.evil.com/...",
+ "http://www.evil.com/...",
"dance/party",
L"download"},
{"a_file_name.txt",
- L"http://www.evil.com/",
+ "http://www.evil.com/",
"image/jpeg",
L"download.jpg"},
{"filename=",
- L"http://www.evil.com/",
+ "http://www.evil.com/",
"image/jpeg",
L"download.jpg"},
{"filename=simple",
- L"http://www.example.com/simple",
+ "http://www.example.com/simple",
"application/octet-stream",
L"simple"},
{"filename=COM1",
- L"http://www.goodguy.com/COM1",
+ "http://www.goodguy.com/COM1",
"application/foo-bar",
L"_COM1"},
{"filename=COM4.txt",
- L"http://www.goodguy.com/COM4.txt",
+ "http://www.goodguy.com/COM4.txt",
"text/plain",
L"_COM4.txt"},
{"filename=lpt1.TXT",
- L"http://www.goodguy.com/lpt1.TXT",
+ "http://www.goodguy.com/lpt1.TXT",
"text/plain",
L"_lpt1.TXT"},
{"filename=clock$.txt",
- L"http://www.goodguy.com/clock$.txt",
+ "http://www.goodguy.com/clock$.txt",
"text/plain",
L"_clock$.txt"},
{"filename=mycom1.foo",
- L"http://www.goodguy.com/mycom1.foo",
+ "http://www.goodguy.com/mycom1.foo",
"text/plain",
L"mycom1.foo"},
{"filename=Setup.exe.local",
- L"http://www.badguy.com/Setup.exe.local",
+ "http://www.badguy.com/Setup.exe.local",
"application/foo-bar",
L"Setup.exe.download"},
{"filename=Setup.exe.local.local",
- L"http://www.badguy.com/Setup.exe.local",
+ "http://www.badguy.com/Setup.exe.local",
"application/foo-bar",
L"Setup.exe.local.download"},
{"filename=Setup.exe.lnk",
- L"http://www.badguy.com/Setup.exe.lnk",
+ "http://www.badguy.com/Setup.exe.lnk",
"application/foo-bar",
L"Setup.exe.download"},
{"filename=Desktop.ini",
- L"http://www.badguy.com/Desktop.ini",
+ "http://www.badguy.com/Desktop.ini",
"application/foo-bar",
L"_Desktop.ini"},
{"filename=Thumbs.db",
- L"http://www.badguy.com/Thumbs.db",
+ "http://www.badguy.com/Thumbs.db",
"application/foo-bar",
L"_Thumbs.db"},
{"filename=source.srf",
- L"http://www.hotmail.com",
+ "http://www.hotmail.com",
"image/jpeg",
L"source.srf.jpg"},
{"filename=source.jpg",
- L"http://www.hotmail.com",
+ "http://www.hotmail.com",
"application/x-javascript",
L"source.jpg"},
// NetUtilTest.{GetSuggestedFilename, GetFileNameFromCD} test these
// more thoroughly. Tested below are a small set of samples.
{"attachment; filename=\"%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg\"",
- L"http://www.examples.com/",
+ "http://www.examples.com/",
"image/jpeg",
L"\uc608\uc220 \uc608\uc220.jpg"},
{"attachment; name=abc de.pdf",
- L"http://www.examples.com/q.cgi?id=abc",
+ "http://www.examples.com/q.cgi?id=abc",
"application/octet-stream",
L"abc de.pdf"},
{"filename=\"=?EUC-JP?Q?=B7=DD=BD=D13=2Epng?=\"",
- L"http://www.example.com/path",
+ "http://www.example.com/path",
"image/png",
L"\x82b8\x8853" L"3.png"},
// The following two have invalid CD headers and filenames come
// from the URL.
{"attachment; filename==?iiso88591?Q?caf=EG?=",
- L"http://www.example.com/test%20123",
+ "http://www.example.com/test%20123",
"image/jpeg",
L"test 123.jpg"},
{"malformed_disposition",
- L"http://www.google.com/%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg",
+ "http://www.google.com/%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg",
"image/jpeg",
L"\uc608\uc220 \uc608\uc220.jpg"},
// Invalid C-D. No filename from URL. Falls back to 'download'.
{"attachment; filename==?iso88591?Q?caf=E3?",
- L"http://www.google.com/path1/path2/",
+ "http://www.google.com/path1/path2/",
"image/jpeg",
L"download.jpg"},
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index e264987..09ae4c0 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -112,7 +112,7 @@ void BaseContextMenu::ExecuteCommand(int id) {
download_->manager()->ShowDownloadInShell(download_);
break;
case COPY_LINK:
- scw.WriteText(download_->url());
+ scw.WriteText(UTF8ToWide(download_->url().spec()));
break;
case COPY_PATH:
scw.WriteText(download_->full_path().ToWStringHack());
diff --git a/chrome/browser/download/save_file_manager.cc b/chrome/browser/download/save_file_manager.cc
index 64984de..510b94c 100644
--- a/chrome/browser/download/save_file_manager.cc
+++ b/chrome/browser/download/save_file_manager.cc
@@ -87,7 +87,7 @@ int SaveFileManager::GetNextId() {
return next_id_++;
}
-void SaveFileManager::RegisterStartingRequest(const std::wstring& save_url,
+void SaveFileManager::RegisterStartingRequest(const GURL& save_url,
SavePackage* save_package) {
// Make sure it runs in the UI thread.
DCHECK(MessageLoop::current() == ui_loop_);
@@ -96,19 +96,19 @@ void SaveFileManager::RegisterStartingRequest(const std::wstring& save_url,
// Register this starting request.
StartingRequestsMap& starting_requests = tab_starting_requests_[tab_id];
bool never_present = starting_requests.insert(
- StartingRequestsMap::value_type(save_url, save_package)).second;
+ StartingRequestsMap::value_type(save_url.spec(), save_package)).second;
DCHECK(never_present);
}
SavePackage* SaveFileManager::UnregisterStartingRequest(
- const std::wstring& save_url, int tab_id) {
+ const GURL& save_url, int tab_id) {
// Make sure it runs in UI thread.
DCHECK(MessageLoop::current() == ui_loop_);
TabToStartingRequestsMap::iterator it = tab_starting_requests_.find(tab_id);
if (it != tab_starting_requests_.end()) {
StartingRequestsMap& requests = it->second;
- StartingRequestsMap::iterator sit = requests.find(save_url);
+ StartingRequestsMap::iterator sit = requests.find(save_url.spec());
if (sit == requests.end())
return NULL;
@@ -149,8 +149,8 @@ SavePackage* SaveFileManager::LookupPackage(int save_id) {
}
// Call from SavePackage for starting a saving job
-void SaveFileManager::SaveURL(const std::wstring& url,
- const std::wstring& referrer,
+void SaveFileManager::SaveURL(const GURL& url,
+ const GURL& referrer,
int render_process_host_id,
int render_view_id,
SaveFileCreateInfo::SaveFileSource save_source,
@@ -166,14 +166,13 @@ void SaveFileManager::SaveURL(const std::wstring& url,
// Register a saving job.
RegisterStartingRequest(url, save_package);
if (save_source == SaveFileCreateInfo::SAVE_FILE_FROM_NET) {
- GURL save_url(url);
- DCHECK(save_url.is_valid());
+ DCHECK(url.is_valid());
io_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this,
&SaveFileManager::OnSaveURL,
- save_url,
- GURL(referrer),
+ url,
+ referrer,
render_process_host_id,
render_view_id,
request_context));
@@ -195,7 +194,7 @@ void SaveFileManager::SaveURL(const std::wstring& url,
// If the save id is -1, it means we just send a request to save, but the
// saving action has still not happened, need to call UnregisterStartingRequest
// to remove it from the tracking map.
-void SaveFileManager::RemoveSaveFile(int save_id, const std::wstring& save_url,
+void SaveFileManager::RemoveSaveFile(int save_id, const GURL& save_url,
SavePackage* package) {
DCHECK(MessageLoop::current() == ui_loop_ && package);
// A save page job(SavePackage) can only have one manager,
@@ -295,7 +294,7 @@ void SaveFileManager::UpdateSaveProgress(int save_id,
// thread, which will use the save URL to find corresponding request record and
// delete it.
void SaveFileManager::SaveFinished(int save_id,
- std::wstring save_url,
+ GURL save_url,
int render_process_id,
bool is_success) {
DCHECK(MessageLoop::current() == GetSaveLoop());
@@ -312,7 +311,7 @@ void SaveFileManager::SaveFinished(int save_id,
save_file->Finish();
} else if (save_id == -1) {
// Before saving started, we got error. We still call finish process.
- DCHECK(!save_url.empty());
+ DCHECK(!save_url.is_empty());
ui_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this,
&SaveFileManager::OnErrorFinished,
@@ -375,7 +374,7 @@ void SaveFileManager::OnSaveFinished(int save_id,
package->SaveFinished(save_id, bytes_so_far, is_success);
}
-void SaveFileManager::OnErrorFinished(std::wstring save_url, int tab_id) {
+void SaveFileManager::OnErrorFinished(GURL save_url, int tab_id) {
DCHECK(MessageLoop::current() == ui_loop_);
SavePackage* save_package = UnregisterStartingRequest(save_url, tab_id);
if (save_package)
@@ -473,7 +472,7 @@ void SaveFileManager::CancelSave(int save_id) {
// It is possible that SaveItem which has specified save_id has been canceled
// before this function runs. So if we can not find corresponding SaveFile by
// using specified save_id, just return.
-void SaveFileManager::SaveLocalFile(const std::wstring& original_file_url,
+void SaveFileManager::SaveLocalFile(const GURL& original_file_url,
int save_id,
int render_process_id) {
DCHECK(MessageLoop::current() == GetSaveLoop());
@@ -488,10 +487,9 @@ void SaveFileManager::SaveLocalFile(const std::wstring& original_file_url,
// Close the save file before the copy operation.
save_file->Finish();
- GURL file_url(original_file_url);
- DCHECK(file_url.SchemeIsFile());
- std::wstring file_path;
- net::FileURLToFilePath(file_url, &file_path);
+ DCHECK(original_file_url.SchemeIsFile());
+ FilePath file_path;
+ net::FileURLToFilePath(original_file_url, &file_path);
// If we can not get valid file path from original URL, treat it as
// disk error.
if (file_path.empty())
@@ -499,8 +497,8 @@ void SaveFileManager::SaveLocalFile(const std::wstring& original_file_url,
// Copy the local file to the temporary file. It will be renamed to its
// final name later.
- bool success = CopyFile(file_path.c_str(),
- save_file->full_path().c_str(), FALSE) != 0;
+ bool success = file_util::CopyFile(file_path,
+ FilePath::FromWStringHack(save_file->full_path()));
if (!success)
file_util::Delete(save_file->full_path(), false);
SaveFinished(save_id, original_file_url, render_process_id, success);
diff --git a/chrome/browser/download/save_file_manager.h b/chrome/browser/download/save_file_manager.h
index cf29e1c..4df5abf 100644
--- a/chrome/browser/download/save_file_manager.h
+++ b/chrome/browser/download/save_file_manager.h
@@ -93,8 +93,8 @@ class SaveFileManager
// Save the specified URL. Called on the UI thread and forwarded to the
// ResourceDispatcherHost on the IO thread.
- void SaveURL(const std::wstring& url,
- const std::wstring& referrer,
+ void SaveURL(const GURL& url,
+ const GURL& referrer,
int render_process_host_id,
int render_view_id,
SaveFileCreateInfo::SaveFileSource save_source,
@@ -105,7 +105,7 @@ class SaveFileManager
// Notifications sent from the IO thread and run on the file thread:
void StartSave(SaveFileCreateInfo* info);
void UpdateSaveProgress(int save_id, net::IOBuffer* data, int size);
- void SaveFinished(int save_id, std::wstring save_url,
+ void SaveFinished(int save_id, GURL save_url,
int render_process_id, bool is_success);
// Notifications sent from the UI thread and run on the file thread.
@@ -114,7 +114,7 @@ class SaveFileManager
// Called on the UI thread to remove a save package from SaveFileManager's
// tracking map.
- void RemoveSaveFile(int save_id, const std::wstring& save_url,
+ void RemoveSaveFile(int save_id, const GURL& save_url,
SavePackage* package);
// Handler for shell operations sent from the UI to the file thread.
@@ -128,7 +128,7 @@ class SaveFileManager
// Runs on file thread to save a file by copying from file system when
// original url is using file scheme.
- void SaveLocalFile(const std::wstring& original_file_url,
+ void SaveLocalFile(const GURL& original_file_url,
int save_id,
int render_process_id);
@@ -161,11 +161,11 @@ class SaveFileManager
// Register a starting request. Associate the save URL with a
// SavePackage for further matching.
- void RegisterStartingRequest(const std::wstring& save_url,
+ void RegisterStartingRequest(const GURL& save_url,
SavePackage* save_package);
// Unregister a start request according save URL, disassociate
// the save URL and SavePackage.
- SavePackage* UnregisterStartingRequest(const std::wstring& save_url,
+ SavePackage* UnregisterStartingRequest(const GURL& save_url,
int tab_id);
// Look up the SavePackage according to save id.
@@ -193,7 +193,7 @@ class SaveFileManager
void OnSaveFinished(int save_id, int64 bytes_so_far, bool is_success);
// For those requests that do not have valid save id, use
// map:(url, SavePackage) to find the request and remove it.
- void OnErrorFinished(std::wstring save_url, int tab_id);
+ void OnErrorFinished(GURL save_url, int tab_id);
// Handler for a notification sent to the UI thread.
// The user has requested a cancel in the UI thread, so send a cancel request
// to stop the network requests in net IO thread.
@@ -255,7 +255,7 @@ class SaveFileManager
// use a hashmap to map the tab id (we actually use render_process_id) to the
// hashmap since it is possible to save same URL in different tab at
// same time.
- typedef base::hash_map<std::wstring, SavePackage*> StartingRequestsMap;
+ typedef base::hash_map<std::string, SavePackage*> StartingRequestsMap;
typedef base::hash_map<int, StartingRequestsMap> TabToStartingRequestsMap;
TabToStartingRequestsMap tab_starting_requests_;
diff --git a/chrome/browser/download/save_item.cc b/chrome/browser/download/save_item.cc
index b7b7ee40..bd96010 100644
--- a/chrome/browser/download/save_item.cc
+++ b/chrome/browser/download/save_item.cc
@@ -13,8 +13,8 @@
#include "chrome/browser/download/save_package.h"
// Constructor for SaveItem when creating each saving job.
-SaveItem::SaveItem(const std::wstring& url,
- const std::wstring& referrer,
+SaveItem::SaveItem(const GURL& url,
+ const GURL& referrer,
SavePackage* package,
SaveFileCreateInfo::SaveFileSource save_source)
: save_id_(-1),
diff --git a/chrome/browser/download/save_item.h b/chrome/browser/download/save_item.h
index 3c3ed4a..b54840a 100644
--- a/chrome/browser/download/save_item.h
+++ b/chrome/browser/download/save_item.h
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "chrome/browser/download/save_types.h"
+#include "googleurl/src/gurl.h"
class SavePackage;
@@ -23,8 +24,8 @@ class SaveItem {
CANCELED
};
- SaveItem(const std::wstring& url,
- const std::wstring& referrer,
+ SaveItem(const GURL& url,
+ const GURL& referrer,
SavePackage* package,
SaveFileCreateInfo::SaveFileSource save_source);
@@ -56,8 +57,8 @@ class SaveItem {
SaveState state() const { return state_; }
const std::wstring full_path() const { return full_path_; }
const std::wstring file_name() const { return file_name_; }
- const std::wstring& url() const { return url_; }
- const std::wstring& referrer() const { return referrer_; }
+ const GURL& url() const { return url_; }
+ const GURL& referrer() const { return referrer_; }
int64 total_bytes() const { return total_bytes_; }
int64 received_bytes() const { return received_bytes_; }
int32 save_id() const { return save_id_; }
@@ -82,8 +83,8 @@ class SaveItem {
std::wstring file_name_;
// The URL for this save item.
- std::wstring url_;
- std::wstring referrer_;
+ GURL url_;
+ GURL referrer_;
// Total bytes expected.
int64 total_bytes_;
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc
index 6ddc554..4c6d938 100644
--- a/chrome/browser/download/save_package.cc
+++ b/chrome/browser/download/save_package.cc
@@ -109,7 +109,7 @@ SavePackage::SavePackage(WebContents* web_content,
DCHECK(web_content);
const GURL& current_page_url = web_contents_->GetURL();
DCHECK(current_page_url.is_valid());
- page_url_ = UTF8ToWide(current_page_url.spec());
+ page_url_ = current_page_url;
DCHECK(save_type_ == SAVE_AS_ONLY_HTML ||
save_type_ == SAVE_AS_COMPLETE_HTML);
DCHECK(!saved_main_file_path_.empty() &&
@@ -230,7 +230,7 @@ bool SavePackage::Init() {
SaveFileCreateInfo::SAVE_FILE_FROM_FILE :
SaveFileCreateInfo::SAVE_FILE_FROM_NET;
SaveItem* save_item = new SaveItem(page_url_,
- L"",
+ GURL(),
this,
save_source);
// Add this item to waiting list.
@@ -329,9 +329,9 @@ bool SavePackage::GenerateFilename(const std::string& disposition,
// We have received a message from SaveFileManager about a new saving job. We
// create a SaveItem and store it in our in_progress list.
void SavePackage::StartSave(const SaveFileCreateInfo* info) {
- DCHECK(info && !info->url.empty());
+ DCHECK(info && !info->url.is_empty());
- SaveUrlItemMap::iterator it = in_progress_items_.find(info->url);
+ SaveUrlItemMap::iterator it = in_progress_items_.find(info->url.spec());
if (it == in_progress_items_.end()) {
// If not found, we must have cancel action.
DCHECK(canceled());
@@ -409,8 +409,8 @@ void SavePackage::StartSave(const SaveFileCreateInfo* info) {
// Look up SaveItem by save id from in progress map.
SaveItem* SavePackage::LookupItemInProcessBySaveId(int32 save_id) {
if (in_process_count()) {
- SaveUrlItemMap::iterator it = in_progress_items_.begin();
- for (; it != in_progress_items_.end(); ++it) {
+ for (SaveUrlItemMap::iterator it = in_progress_items_.begin();
+ it != in_progress_items_.end(); ++it) {
SaveItem* save_item = it->second;
DCHECK(save_item->state() == SaveItem::IN_PROGRESS);
if (save_item->save_id() == save_id)
@@ -423,7 +423,7 @@ SaveItem* SavePackage::LookupItemInProcessBySaveId(int32 save_id) {
// Remove SaveItem from in progress map and put it to saved map.
void SavePackage::PutInProgressItemToSavedMap(SaveItem* save_item) {
SaveUrlItemMap::iterator it = in_progress_items_.find(
- save_item->url());
+ save_item->url().spec());
DCHECK(it != in_progress_items_.end());
DCHECK(save_item == it->second);
in_progress_items_.erase(it);
@@ -435,9 +435,9 @@ void SavePackage::PutInProgressItemToSavedMap(SaveItem* save_item) {
saved_success_items_[save_item->save_id()] = save_item;
} else {
// Add it to saved_failed_items_.
- DCHECK(saved_failed_items_.find(save_item->url()) ==
+ DCHECK(saved_failed_items_.find(save_item->url().spec()) ==
saved_failed_items_.end());
- saved_failed_items_[save_item->url()] = save_item;
+ saved_failed_items_[save_item->url().spec()] = save_item;
}
}
@@ -599,8 +599,8 @@ void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) {
// this error.
// Saving an item failed. If it's a sub-resource, ignore it. If the error comes
// from serializing HTML data, then cancel saving page.
-void SavePackage::SaveFailed(const std::wstring& save_url) {
- SaveUrlItemMap::iterator it = in_progress_items_.find(save_url);
+void SavePackage::SaveFailed(const GURL& save_url) {
+ SaveUrlItemMap::iterator it = in_progress_items_.find(save_url.spec());
if (it == in_progress_items_.end()) {
NOTREACHED(); // Should not exist!
return;
@@ -660,9 +660,9 @@ void SavePackage::SaveNextFile(bool process_all_remaining_items) {
// Add the item to in_progress_items_.
SaveUrlItemMap::iterator it = in_progress_items_.find(
- save_item->url());
+ save_item->url().spec());
DCHECK(it == in_progress_items_.end());
- in_progress_items_[save_item->url()] = save_item;
+ in_progress_items_[save_item->url().spec()] = save_item;
save_item->Start();
file_manager_->SaveURL(save_item->url(),
save_item->referrer(),
@@ -744,7 +744,7 @@ void SavePackage::DoSavingProcess() {
void SavePackage::GetSerializedHtmlDataForCurrentPageWithLocalLinks() {
if (wait_state_ != HTML_DATA)
return;
- std::vector<std::wstring> saved_links;
+ std::vector<GURL> saved_links;
std::vector<std::wstring> saved_file_paths;
int successful_started_items_count = 0;
@@ -815,8 +815,7 @@ void SavePackage::OnReceivedSerializedHtmlData(const GURL& frame_url,
return;
}
- std::wstring current_frame_url = UTF8ToWide(frame_url.spec());
- SaveUrlItemMap::iterator it = in_progress_items_.find(current_frame_url);
+ SaveUrlItemMap::iterator it = in_progress_items_.find(frame_url.spec());
if (it == in_progress_items_.end())
return;
SaveItem* save_item = it->second;
@@ -886,15 +885,15 @@ void SavePackage::OnReceivedSavableResourceLinksForCurrentPage(
SaveFileCreateInfo::SaveFileSource save_source = u.SchemeIsFile() ?
SaveFileCreateInfo::SAVE_FILE_FROM_FILE :
SaveFileCreateInfo::SAVE_FILE_FROM_NET;
- SaveItem* save_item = new SaveItem(UTF8ToWide(u.spec()),
- UTF8ToWide(referrers_list[i].spec()), this, save_source);
+ SaveItem* save_item = new SaveItem(u, referrers_list[i],
+ this, save_source);
waiting_item_queue_.push(save_item);
}
// Put all HTML resources to wait list.
for (int i = 0; i < static_cast<int>(frames_list.size()); ++i) {
const GURL& u = frames_list[i];
DCHECK(u.is_valid());
- SaveItem* save_item = new SaveItem(UTF8ToWide(u.spec()), L"",
+ SaveItem* save_item = new SaveItem(u, GURL(),
this, SaveFileCreateInfo::SAVE_FILE_FROM_DOM);
waiting_item_queue_.push(save_item);
}
diff --git a/chrome/browser/download/save_package.h b/chrome/browser/download/save_package.h
index 6bbe7b2..5dbc9e6 100644
--- a/chrome/browser/download/save_package.h
+++ b/chrome/browser/download/save_package.h
@@ -98,7 +98,7 @@ class SavePackage : public base::RefCountedThreadSafe<SavePackage>,
void StartSave(const SaveFileCreateInfo* info);
bool UpdateSaveProgress(int32 save_id, int64 size, bool write_success);
void SaveFinished(int32 save_id, int64 size, bool is_success);
- void SaveFailed(const std::wstring& save_url);
+ void SaveFailed(const GURL& save_url);
void SaveCanceled(SaveItem* save_item);
// Rough percent complete, -1 means we don't know (since we didn't receive a
@@ -228,7 +228,7 @@ class SavePackage : public base::RefCountedThreadSafe<SavePackage>,
SaveItem* LookupItemInProcessBySaveId(int32 save_id);
void PutInProgressItemToSavedMap(SaveItem* save_item);
- typedef base::hash_map<std::wstring, SaveItem*> SaveUrlItemMap;
+ typedef base::hash_map<std::string, SaveItem*> SaveUrlItemMap;
// in_progress_items_ is map of all saving job in in-progress state.
SaveUrlItemMap in_progress_items_;
// saved_failed_items_ is map of all saving job which are failed.
@@ -268,7 +268,7 @@ class SavePackage : public base::RefCountedThreadSafe<SavePackage>,
DownloadItem* download_;
// The URL of the page the user wants to save.
- std::wstring page_url_;
+ GURL page_url_;
FilePath saved_main_file_path_;
FilePath saved_main_directory_path_;
diff --git a/chrome/browser/download/save_types.h b/chrome/browser/download/save_types.h
index 624aaa6..7e19d18 100644
--- a/chrome/browser/download/save_types.h
+++ b/chrome/browser/download/save_types.h
@@ -9,6 +9,7 @@
#include <utility>
#include "base/basictypes.h"
+#include "googleurl/src/gurl.h"
typedef std::vector<std::pair<int, std::wstring> > FinalNameList;
typedef std::vector<int> SaveIDList;
@@ -29,7 +30,7 @@ struct SaveFileCreateInfo {
};
SaveFileCreateInfo(const std::wstring& path,
- const std::wstring& url,
+ const GURL& url,
SaveFileSource save_source,
int32 save_id)
: path(path),
@@ -48,9 +49,9 @@ struct SaveFileCreateInfo {
// The local file path of saved file.
std::wstring path;
// Original URL of the saved resource.
- std::wstring url;
+ GURL url;
// Final URL of the saved resource since some URL might be redirected.
- std::wstring final_url;
+ GURL final_url;
// The unique identifier for saving job, assigned at creation by
// the SaveFileManager for its internal record keeping.
int save_id;
diff --git a/chrome/browser/history/download_database.cc b/chrome/browser/history/download_database.cc
index 7f66dba..5c34ef4 100644
--- a/chrome/browser/history/download_database.cc
+++ b/chrome/browser/history/download_database.cc
@@ -72,7 +72,9 @@ void DownloadDatabase::QueryDownloads(std::vector<DownloadCreateInfo>* results)
std::wstring path_str;
statement->column_wstring(1, &path_str);
info.path = FilePath::FromWStringHack(path_str);
- statement->column_wstring(2, &info.url);
+ std::wstring url_str;
+ statement->column_wstring(2, &url_str);
+ info.url = GURL(WideToUTF8(url_str));
info.start_time = Time::FromTimeT(statement->column_int64(3));
info.received_bytes = statement->column_int64(4);
info.total_bytes = statement->column_int64(5);
@@ -120,7 +122,7 @@ int64 DownloadDatabase::CreateDownload(const DownloadCreateInfo& info) {
return 0;
statement->bind_wstring(0, info.path.ToWStringHack());
- statement->bind_wstring(1, info.url);
+ statement->bind_wstring(1, UTF8ToWide(info.url.spec()));
statement->bind_int64(2, info.start_time.ToTimeT());
statement->bind_int64(3, info.received_bytes);
statement->bind_int64(4, info.total_bytes);
diff --git a/chrome/browser/history/download_types.h b/chrome/browser/history/download_types.h
index e520ff6..de87d2e 100644
--- a/chrome/browser/history/download_types.h
+++ b/chrome/browser/history/download_types.h
@@ -13,6 +13,7 @@
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/time.h"
+#include "googleurl/src/gurl.h"
// Used for informing the download database of a new download, where we don't
// want to pass DownloadItems between threads. The history service also uses a
@@ -20,7 +21,7 @@
// initialization time (see DownloadQueryInfo below).
struct DownloadCreateInfo {
DownloadCreateInfo(const FilePath& path,
- const std::wstring& url,
+ const GURL& url,
base::Time start_time,
int64 received_bytes,
int64 total_bytes,
@@ -46,7 +47,7 @@ struct DownloadCreateInfo {
// DownloadItem fields
FilePath path;
- std::wstring url;
+ GURL url;
FilePath suggested_path;
// A number that should be added to the suggested path to make it unique.
// 0 means no number should be appended. Not actually stored in the db.
diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc
index 6677145..b8f953e 100644
--- a/chrome/browser/history/history_unittest.cc
+++ b/chrome/browser/history/history_unittest.cc
@@ -194,7 +194,7 @@ class HistoryTest : public testing::Test {
int64 AddDownload(int32 state, const Time& time) {
DownloadCreateInfo download(FilePath(FILE_PATH_LITERAL("foo-path")),
- L"foo-url", time, 0, 512, state, 0);
+ GURL("foo-url"), time, 0, 512, state, 0);
return db_->CreateDownload(download);
}
diff --git a/chrome/browser/renderer_host/buffered_resource_handler.cc b/chrome/browser/renderer_host/buffered_resource_handler.cc
index d8f66a8..66ef1f3 100644
--- a/chrome/browser/renderer_host/buffered_resource_handler.cc
+++ b/chrome/browser/renderer_host/buffered_resource_handler.cc
@@ -248,7 +248,7 @@ bool BufferedResourceHandler::CompleteResponseStarted(int request_id,
scoped_refptr<DownloadThrottlingResourceHandler> download_handler =
new DownloadThrottlingResourceHandler(host_,
request_,
- request_->url().spec(),
+ request_->url(),
info->render_process_host_id,
info->render_view_id,
request_id,
diff --git a/chrome/browser/renderer_host/download_resource_handler.cc b/chrome/browser/renderer_host/download_resource_handler.cc
index de34a60..9351f56 100644
--- a/chrome/browser/renderer_host/download_resource_handler.cc
+++ b/chrome/browser/renderer_host/download_resource_handler.cc
@@ -19,7 +19,7 @@ DownloadResourceHandler::DownloadResourceHandler(ResourceDispatcherHost* rdh,
int render_process_host_id,
int render_view_id,
int request_id,
- const std::string& url,
+ const GURL& url,
DownloadFileManager* manager,
URLRequest* request,
bool save_as)
@@ -27,7 +27,7 @@ DownloadResourceHandler::DownloadResourceHandler(ResourceDispatcherHost* rdh,
global_id_(ResourceDispatcherHost::GlobalRequestID(render_process_host_id,
request_id)),
render_view_id_(render_view_id),
- url_(UTF8ToWide(url)),
+ url_(url),
content_length_(0),
download_manager_(manager),
request_(request),
@@ -40,7 +40,7 @@ DownloadResourceHandler::DownloadResourceHandler(ResourceDispatcherHost* rdh,
// Not needed, as this event handler ought to be the final resource.
bool DownloadResourceHandler::OnRequestRedirected(int request_id,
const GURL& url) {
- url_ = UTF8ToWide(url.spec());
+ url_ = url;
return true;
}
diff --git a/chrome/browser/renderer_host/download_resource_handler.h b/chrome/browser/renderer_host/download_resource_handler.h
index 0dbeef0..dfc047e 100644
--- a/chrome/browser/renderer_host/download_resource_handler.h
+++ b/chrome/browser/renderer_host/download_resource_handler.h
@@ -19,7 +19,7 @@ class DownloadResourceHandler : public ResourceHandler {
int render_process_host_id,
int render_view_id,
int request_id,
- const std::string& url,
+ const GURL& url,
DownloadFileManager* manager,
URLRequest* request,
bool save_as);
@@ -56,7 +56,7 @@ class DownloadResourceHandler : public ResourceHandler {
int render_view_id_;
scoped_refptr<net::IOBuffer> read_buffer_;
std::string content_disposition_;
- std::wstring url_;
+ GURL url_;
int64 content_length_;
DownloadFileManager* download_manager_;
URLRequest* request_;
diff --git a/chrome/browser/renderer_host/download_throttling_resource_handler.cc b/chrome/browser/renderer_host/download_throttling_resource_handler.cc
index ea4fdbb..f049788 100644
--- a/chrome/browser/renderer_host/download_throttling_resource_handler.cc
+++ b/chrome/browser/renderer_host/download_throttling_resource_handler.cc
@@ -10,7 +10,7 @@
DownloadThrottlingResourceHandler::DownloadThrottlingResourceHandler(
ResourceDispatcherHost* host,
URLRequest* request,
- const std::string& url,
+ const GURL& url,
int render_process_host_id,
int render_view_id,
int request_id,
@@ -44,7 +44,7 @@ bool DownloadThrottlingResourceHandler::OnRequestRedirected(int request_id,
const GURL& url) {
if (download_handler_.get())
return download_handler_->OnRequestRedirected(request_id, url);
- url_ = url.spec();
+ url_ = url;
return true;
}
diff --git a/chrome/browser/renderer_host/download_throttling_resource_handler.h b/chrome/browser/renderer_host/download_throttling_resource_handler.h
index 6f7c3d9..80c5a00 100644
--- a/chrome/browser/renderer_host/download_throttling_resource_handler.h
+++ b/chrome/browser/renderer_host/download_throttling_resource_handler.h
@@ -8,6 +8,7 @@
#include <string>
#include "chrome/browser/renderer_host/resource_handler.h"
+#include "googleurl/src/gurl.h"
#if defined(OS_WIN)
// TODO(port): Remove ifdef when downloads are ported.
@@ -33,7 +34,7 @@ class DownloadThrottlingResourceHandler
public:
DownloadThrottlingResourceHandler(ResourceDispatcherHost* host,
URLRequest* request,
- const std::string& url,
+ const GURL& url,
int render_process_host_id,
int render_view_id,
int request_id,
@@ -61,7 +62,7 @@ class DownloadThrottlingResourceHandler
ResourceDispatcherHost* host_;
URLRequest* request_;
- std::string url_;
+ GURL url_;
int render_process_host_id_;
int render_view_id_;
int request_id_;
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index b78c4c9..d8d34f7 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1223,7 +1223,7 @@ void RenderViewHost::OnDidGetApplicationInfo(
}
void RenderViewHost::GetSerializedHtmlDataForCurrentPageWithLocalLinks(
- const std::vector<std::wstring>& links,
+ const std::vector<GURL>& links,
const std::vector<std::wstring>& local_paths,
const std::wstring& local_directory_name) {
Send(new ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks(
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 2cd9d29..01f1097 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -351,7 +351,7 @@ class RenderViewHost : public RenderWidgetHost {
// The parameter local_directory_name is relative path of directory which
// contain all saved auxiliary files included all sub frames and resouces.
void GetSerializedHtmlDataForCurrentPageWithLocalLinks(
- const std::vector<std::wstring>& links,
+ const std::vector<GURL>& links,
const std::vector<std::wstring>& local_paths,
const std::wstring& local_directory_name);
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index 65b5c3d..5c1bd26 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -349,7 +349,7 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url,
render_process_host_id,
render_view_id,
request_id_,
- url.spec(),
+ url,
download_file_manager_.get(),
request,
true);
@@ -405,7 +405,7 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url,
scoped_refptr<ResourceHandler> handler =
new SaveFileResourceHandler(render_process_host_id,
render_view_id,
- url.spec(),
+ url,
save_file_manager_.get());
request_id_--;
diff --git a/chrome/browser/renderer_host/save_file_resource_handler.cc b/chrome/browser/renderer_host/save_file_resource_handler.cc
index 3a1b753..139f5a00 100644
--- a/chrome/browser/renderer_host/save_file_resource_handler.cc
+++ b/chrome/browser/renderer_host/save_file_resource_handler.cc
@@ -14,19 +14,19 @@
SaveFileResourceHandler::SaveFileResourceHandler(int render_process_host_id,
int render_view_id,
- const std::string& url,
+ const GURL& url,
SaveFileManager* manager)
: save_id_(-1),
render_process_id_(render_process_host_id),
render_view_id_(render_view_id),
- url_(UTF8ToWide(url)),
+ url_(url),
content_length_(0),
save_manager_(manager) {
}
bool SaveFileResourceHandler::OnRequestRedirected(int request_id,
const GURL& url) {
- final_url_ = UTF8ToWide(url.spec());
+ final_url_ = url;
return true;
}
diff --git a/chrome/browser/renderer_host/save_file_resource_handler.h b/chrome/browser/renderer_host/save_file_resource_handler.h
index 30fc074..63d78ad 100644
--- a/chrome/browser/renderer_host/save_file_resource_handler.h
+++ b/chrome/browser/renderer_host/save_file_resource_handler.h
@@ -16,7 +16,7 @@ class SaveFileResourceHandler : public ResourceHandler {
public:
SaveFileResourceHandler(int render_process_host_id,
int render_view_id,
- const std::string& url,
+ const GURL& url,
SaveFileManager* manager);
// Saves the redirected URL to final_url_, we need to use the original
@@ -53,8 +53,8 @@ class SaveFileResourceHandler : public ResourceHandler {
int render_view_id_;
scoped_refptr<net::IOBuffer> read_buffer_;
std::string content_disposition_;
- std::wstring url_;
- std::wstring final_url_;
+ GURL url_;
+ GURL final_url_;
int64 content_length_;
SaveFileManager* save_manager_;
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index e6b401e..76e53c4 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -401,7 +401,7 @@ IPC_BEGIN_MESSAGES(View)
// Get html data by serializing all frames of current page with lists
// which contain all resource links that have local copy.
IPC_MESSAGE_ROUTED3(ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
- std::vector<std::wstring> /* urls that have local copy */,
+ std::vector<GURL> /* urls that have local copy */,
std::vector<std::wstring> /* paths of local copy */,
std::wstring /* local directory path */)
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index 9e51a80..9bbaa7f 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -456,7 +456,7 @@ class SaveFileManager : public base::RefCountedThreadSafe<SaveFileManager> {
void UpdateSaveProgress(int save_id, net::IOBuffer* data, int size) {
NOTIMPLEMENTED();
}
- void SaveFinished(int save_id, const std::wstring& save_url,
+ void SaveFinished(int save_id, const GURL& save_url,
int render_process_id, int is_success) {
NOTIMPLEMENTED();
}
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 062cde4..bd300e1 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2718,7 +2718,7 @@ void RenderView::OnGetAllSavableResourceLinksForCurrentPage(
}
void RenderView::OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
- const std::vector<std::wstring>& links,
+ const std::vector<GURL>& links,
const std::vector<std::wstring>& local_paths,
const std::wstring& local_directory_name) {
webkit_glue::DomSerializer dom_serializer(webview()->GetMainFrame(),
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 03710f3..b177ed0 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -435,7 +435,7 @@ class RenderView : public RenderWidget,
void OnSetPageEncoding(const std::wstring& encoding_name);
void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
- const std::vector<std::wstring>& links,
+ const std::vector<GURL>& links,
const std::vector<std::wstring>& local_paths,
const std::wstring& local_directory_name);
void OnUploadFileRequest(const ViewMsg_UploadFile_Params& p);
diff --git a/webkit/glue/dom_serializer.cc b/webkit/glue/dom_serializer.cc
index e71d8f4..cb8d92e 100644
--- a/webkit/glue/dom_serializer.cc
+++ b/webkit/glue/dom_serializer.cc
@@ -82,8 +82,8 @@ MSVC_POP_WARNING();
namespace {
// Default "mark of the web" declaration
-static const wchar_t* const kDefaultMarkOfTheWeb =
- L"\n<!-- saved from url=(%04d)%ls -->\n";
+static const char* const kDefaultMarkOfTheWeb =
+ "\n<!-- saved from url=(%04d)%s -->\n";
// Default meat content for writing correct charset declaration.
static const wchar_t* const kDefaultMetaContent =
@@ -146,12 +146,10 @@ namespace webkit_glue {
// SerializeDomParam Constructor.
DomSerializer::SerializeDomParam::SerializeDomParam(
const GURL& current_frame_gurl,
- const std::wstring& current_frame_wurl,
const WebCore::TextEncoding& text_encoding,
WebCore::Document* doc,
const std::wstring& directory_name)
: current_frame_gurl(current_frame_gurl),
- current_frame_wurl(current_frame_wurl),
text_encoding(text_encoding),
doc(doc),
directory_name(directory_name),
@@ -165,9 +163,10 @@ DomSerializer::SerializeDomParam::SerializeDomParam(
}
// Static.
-std::wstring DomSerializer::GenerateMarkOfTheWebDeclaration(
- const std::wstring& url) {
- return StringPrintf(kDefaultMarkOfTheWeb, url.size(), url.c_str());
+std::string DomSerializer::GenerateMarkOfTheWebDeclaration(
+ const GURL& url) {
+ return StringPrintf(kDefaultMarkOfTheWeb,
+ url.spec().size(), url.spec().c_str());
}
// Static.
@@ -212,7 +211,8 @@ WebCore::String DomSerializer::PreActionBeforeSerializeOpenTag(
// Add MOTW declaration before html tag.
// See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx.
- result += StdWStringToString(GenerateMarkOfTheWebDeclaration(param->current_frame_wurl));
+ result += StdStringToString(GenerateMarkOfTheWebDeclaration(
+ param->current_frame_gurl));
} else if (element->hasTagName(WebCore::HTMLNames::baseTag)) {
// Comment the BASE tag when serializing dom.
result += StdWStringToString(kStartCommentNotation);
@@ -375,7 +375,7 @@ void DomSerializer::OpenTagToString(const WebCore::Element* element,
result += attr_value;
} else {
WebCore::String str_value = param->doc->completeURL(attr_value);
- std::wstring value(StringToStdWString(str_value));
+ std::string value(StringToStdString(str_value));
// Check whether we local files for those link.
LinkLocalPathMap::const_iterator it = local_links_.find(value);
if (it != local_links_.end()) {
@@ -481,7 +481,7 @@ void DomSerializer::BuildContentForNode(const WebCore::Node* node,
DomSerializer::DomSerializer(WebFrame* webframe,
bool recursive_serialization,
DomSerializerDelegate* delegate,
- const std::vector<std::wstring>& links,
+ const std::vector<GURL>& links,
const std::vector<std::wstring>& local_paths,
const std::wstring& local_directory_name)
: delegate_(delegate),
@@ -495,11 +495,11 @@ DomSerializer::DomSerializer(WebFrame* webframe,
DCHECK(delegate);
// Build local resources map.
DCHECK(links.size() == local_paths.size());
- for (std::vector<std::wstring>::const_iterator link_it = links.begin(),
- path_it = local_paths.begin(); link_it != links.end();
- ++link_it, ++path_it) {
+ std::vector<GURL>::const_iterator link_it = links.begin();
+ std::vector<std::wstring>::const_iterator path_it = local_paths.begin();
+ for (; link_it != links.end(); ++link_it, ++path_it) {
bool never_present = local_links_.insert(
- LinkLocalPathMap::value_type(*link_it, *path_it)).
+ LinkLocalPathMap::value_type(link_it->spec(), *path_it)).
second;
DCHECK(never_present);
}
@@ -561,10 +561,9 @@ bool DomSerializer::SerializeDom() {
const WebCore::KURL& current_frame_kurl =
current_frame->frame()->loader()->url();
GURL current_frame_gurl(KURLToGURL(current_frame_kurl));
- std::wstring current_frame_wurl = ASCIIToWide(current_frame_gurl.spec());
// Check whether we have done this document.
- if (local_links_.find(current_frame_wurl) != local_links_.end()) {
+ if (local_links_.find(current_frame_gurl.spec()) != local_links_.end()) {
// A new document, we will serialize it.
did_serialization = true;
// Get target encoding for current document.
@@ -574,7 +573,6 @@ bool DomSerializer::SerializeDom() {
// Construct serialize parameter for late processing document.
SerializeDomParam param(
current_frame_gurl,
- current_frame_wurl,
encoding.length() ? text_encoding : WebCore::UTF8Encoding(),
current_doc,
current_frame_gurl == main_page_gurl ?
diff --git a/webkit/glue/dom_serializer.h b/webkit/glue/dom_serializer.h
index bfe8c43..b8073c1 100644
--- a/webkit/glue/dom_serializer.h
+++ b/webkit/glue/dom_serializer.h
@@ -52,12 +52,12 @@ class DomSerializer {
DomSerializer(WebFrame* webframe,
bool recursive_serialization,
DomSerializerDelegate* delegate,
- const std::vector<std::wstring>& links,
+ const std::vector<GURL>& links,
const std::vector<std::wstring>& local_paths,
const std::wstring& local_directory_name);
// Generate the MOTW declaration.
- static std::wstring GenerateMarkOfTheWebDeclaration(const std::wstring& url);
+ static std::string GenerateMarkOfTheWebDeclaration(const GURL& url);
// Generate the default base tag declaration.
static std::wstring GenerateBaseTagDeclaration(
const std::wstring& base_target);
@@ -67,7 +67,7 @@ class DomSerializer {
WebFrameImpl* specified_webframeimpl_;
// This hash_map is used to map resource URL of original link to its local
// file path.
- typedef base::hash_map<std::wstring, std::wstring> LinkLocalPathMap;
+ typedef base::hash_map<std::string, std::wstring> LinkLocalPathMap;
// local_links_ include all pair of local resource path and corresponding
// original link.
LinkLocalPathMap local_links_;
@@ -90,8 +90,6 @@ class DomSerializer {
struct SerializeDomParam {
// Frame URL of current processing document presented by GURL
const GURL& current_frame_gurl;
- // Frame URL of current processing document presented by std::wstring.
- const std::wstring& current_frame_wurl;
// Current using text encoding object.
const WebCore::TextEncoding& text_encoding;
@@ -118,7 +116,6 @@ class DomSerializer {
// Constructor.
SerializeDomParam(
const GURL& current_frame_gurl,
- const std::wstring& current_frame_wurl,
const WebCore::TextEncoding& text_encoding,
WebCore::Document* doc,
const std::wstring& directory_name);
diff --git a/webkit/glue/dom_serializer_unittest.cc b/webkit/glue/dom_serializer_unittest.cc
index 7881c3f..93cf20d 100644
--- a/webkit/glue/dom_serializer_unittest.cc
+++ b/webkit/glue/dom_serializer_unittest.cc
@@ -58,42 +58,41 @@ class DomSerializerTests : public TestShellTest,
return;
}
- std::wstring current_frame_url = UTF8ToWide(frame_url.spec());
// Check finish status of current frame.
SerializationFinishStatusMap::iterator it =
- serialization_finish_status_.find(current_frame_url);
+ serialization_finish_status_.find(frame_url.spec());
// New frame, set initial status as false.
if (it == serialization_finish_status_.end())
- serialization_finish_status_[current_frame_url] = false;
+ serialization_finish_status_[frame_url.spec()] = false;
- it = serialization_finish_status_.find(current_frame_url);
+ it = serialization_finish_status_.find(frame_url.spec());
ASSERT_TRUE(it != serialization_finish_status_.end());
// In process frame, finish status should be false.
ASSERT_FALSE(it->second);
// Add data to corresponding frame's content.
- serialized_frame_map_[current_frame_url] += data;
+ serialized_frame_map_[frame_url.spec()] += data;
// Current frame is completed saving, change the finish status.
if (status == CURRENT_FRAME_IS_FINISHED)
it->second = true;
}
- bool HasSerializedFrame(const std::wstring& frame_url) {
- return serialized_frame_map_.find(frame_url) !=
+ bool HasSerializedFrame(const GURL& frame_url) {
+ return serialized_frame_map_.find(frame_url.spec()) !=
serialized_frame_map_.end();
}
const std::string& GetSerializedContentForFrame(
- const std::wstring& frame_url) {
- return serialized_frame_map_[frame_url];
+ const GURL& frame_url) {
+ return serialized_frame_map_[frame_url.spec()];
}
// Load web page according to specific URL.
- void LoadPageFromURL(const std::wstring& page_url) {
+ void LoadPageFromURL(const GURL& page_url) {
// Load the test file.
test_shell_->ResetTestController();
- test_shell_->LoadURL(page_url.c_str());
+ test_shell_->LoadURL(UTF8ToWide(page_url.spec()).c_str());
test_shell_->WaitTestFinished();
}
@@ -130,12 +129,12 @@ class DomSerializerTests : public TestShellTest,
// Serialize page DOM according to specific page URL. The parameter
// recursive_serialization indicates whether we will serialize all
// sub-frames.
- void SerializeDomForURL(const std::wstring& page_url,
+ void SerializeDomForURL(const GURL& page_url,
bool recursive_serialization) {
// Find corresponding WebFrameImpl according to page_url.
WebFrameImpl* web_frame =
webkit_glue::GetWebFrameImplFromWebViewForSpecificURL(
- test_shell_->webView(), GURL(WideToUTF8(page_url)));
+ test_shell_->webView(), page_url);
ASSERT_TRUE(web_frame != NULL);
// Add input file URl to links_.
links_.push_back(page_url);
@@ -151,15 +150,15 @@ class DomSerializerTests : public TestShellTest,
private:
// Map frame_url to corresponding serialized_content.
- typedef base::hash_map<std::wstring, std::string> SerializedFrameContentMap;
+ typedef base::hash_map<std::string, std::string> SerializedFrameContentMap;
SerializedFrameContentMap serialized_frame_map_;
// Map frame_url to corresponding status of serialization finish.
- typedef base::hash_map<std::wstring, bool> SerializationFinishStatusMap;
+ typedef base::hash_map<std::string, bool> SerializationFinishStatusMap;
SerializationFinishStatusMap serialization_finish_status_;
// Flag indicates whether the process of serializing DOM is finished or not.
bool serialized_;
// The links_ contain dummy original URLs of all saved links.
- std::vector<std::wstring> links_;
+ std::vector<GURL> links_;
// The local_paths_ contain dummy corresponding local file paths of all saved
// links, which matched links_ one by one.
std::vector<std::wstring> local_paths_;
@@ -241,9 +240,8 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithDocType) {
file_util::AppendToPath(&page_file_path, L"dom_serializer/youtube_1.htm");
GURL file_url = net::FilePathToFileURL(page_file_path);
ASSERT_TRUE(file_url.SchemeIsFile());
- std::wstring page_url = ASCIIToWide(file_url.spec());
// Load the test file.
- LoadPageFromURL(page_url);
+ LoadPageFromURL(file_url);
// Make sure original contents have document type.
WebFrameImpl* web_frame =
webkit_glue::GetWebFrameImplFromWebViewForSpecificURL(
@@ -252,12 +250,12 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithDocType) {
WebCore::Document* doc = web_frame->frame()->document();
ASSERT_TRUE(doc->doctype() != NULL);
// Do serialization.
- SerializeDomForURL(page_url, false);
+ SerializeDomForURL(file_url, false);
// Load the serialized contents.
- ASSERT_TRUE(HasSerializedFrame(page_url));
+ ASSERT_TRUE(HasSerializedFrame(file_url));
const std::string& serialized_contents =
- GetSerializedContentForFrame(page_url);
- LoadContents(serialized_contents, GURL(WideToUTF8(page_url)),
+ GetSerializedContentForFrame(file_url);
+ LoadContents(serialized_contents, file_url,
web_frame->frame()->loader()->encoding());
// Make sure serialized contents still have document type.
web_frame =
@@ -273,9 +271,8 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithoutDocType) {
file_util::AppendToPath(&page_file_path, L"dom_serializer/youtube_2.htm");
GURL file_url = net::FilePathToFileURL(page_file_path);
ASSERT_TRUE(file_url.SchemeIsFile());
- std::wstring page_url = ASCIIToWide(file_url.spec());
// Load the test file.
- LoadPageFromURL(page_url);
+ LoadPageFromURL(file_url);
// Make sure original contents do not have document type.
WebFrameImpl* web_frame =
webkit_glue::GetWebFrameImplFromWebViewForSpecificURL(
@@ -284,12 +281,12 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithoutDocType) {
WebCore::Document* doc = web_frame->frame()->document();
ASSERT_TRUE(doc->doctype() == NULL);
// Do serialization.
- SerializeDomForURL(page_url, false);
+ SerializeDomForURL(file_url, false);
// Load the serialized contents.
- ASSERT_TRUE(HasSerializedFrame(page_url));
+ ASSERT_TRUE(HasSerializedFrame(file_url));
const std::string& serialized_contents =
- GetSerializedContentForFrame(page_url);
- LoadContents(serialized_contents, GURL(WideToUTF8(page_url)),
+ GetSerializedContentForFrame(file_url);
+ LoadContents(serialized_contents, file_url,
web_frame->frame()->loader()->encoding());
// Make sure serialized contents do not have document type.
web_frame =
@@ -310,15 +307,14 @@ TEST_F(DomSerializerTests, SerialzeXMLDocWithBuiltInEntities) {
// Get file URL.
GURL file_url = net::FilePathToFileURL(page_file_path);
ASSERT_TRUE(file_url.SchemeIsFile());
- std::wstring page_url = ASCIIToWide(file_url.spec());
// Load the test file.
- LoadPageFromURL(page_url);
+ LoadPageFromURL(file_url);
// Do serialization.
- SerializeDomForURL(page_url, false);
+ SerializeDomForURL(file_url, false);
// Compare the serialized contents with original contents.
- ASSERT_TRUE(HasSerializedFrame(page_url));
+ ASSERT_TRUE(HasSerializedFrame(file_url));
const std::string& serialized_contents =
- GetSerializedContentForFrame(page_url);
+ GetSerializedContentForFrame(file_url);
ASSERT_EQ(orginal_contents, serialized_contents);
}
@@ -332,25 +328,24 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithAddingMOTW) {
// Get file URL.
GURL file_url = net::FilePathToFileURL(page_file_path);
ASSERT_TRUE(file_url.SchemeIsFile());
- std::wstring page_url = ASCIIToWide(file_url.spec());
// Make sure original contents does not have MOTW;
- std::wstring motw_declaration =
- webkit_glue::DomSerializer::GenerateMarkOfTheWebDeclaration(page_url);
+ std::string motw_declaration =
+ webkit_glue::DomSerializer::GenerateMarkOfTheWebDeclaration(file_url);
ASSERT_FALSE(motw_declaration.empty());
// The encoding of original contents is ISO-8859-1, so we convert the MOTW
// declaration to ASCII and search whether original contents has it or not.
- ASSERT_TRUE(std::wstring::npos ==
- orginal_contents.find(WideToASCII(motw_declaration)));
+ ASSERT_TRUE(std::string::npos ==
+ orginal_contents.find(motw_declaration));
// Load the test file.
- LoadPageFromURL(page_url);
+ LoadPageFromURL(file_url);
// Do serialization.
- SerializeDomForURL(page_url, false);
+ SerializeDomForURL(file_url, false);
// Make sure the serialized contents have MOTW ;
- ASSERT_TRUE(HasSerializedFrame(page_url));
+ ASSERT_TRUE(HasSerializedFrame(file_url));
const std::string& serialized_contents =
- GetSerializedContentForFrame(page_url);
- ASSERT_TRUE(std::wstring::npos !=
- serialized_contents.find(WideToUTF8(motw_declaration)));
+ GetSerializedContentForFrame(file_url);
+ ASSERT_FALSE(std::string::npos ==
+ serialized_contents.find(motw_declaration));
}
// When serializing DOM, we will add the META which have correct charset
@@ -363,9 +358,8 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithNoMetaCharsetInOriginalDoc) {
// Get file URL.
GURL file_url = net::FilePathToFileURL(page_file_path);
ASSERT_TRUE(file_url.SchemeIsFile());
- std::wstring page_url = ASCIIToWide(file_url.spec());
// Load the test file.
- LoadPageFromURL(page_url);
+ LoadPageFromURL(file_url);
// Make sure there is no META charset declaration in original document.
WebFrameImpl* web_frame =
@@ -384,13 +378,13 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithNoMetaCharsetInOriginalDoc) {
ASSERT_TRUE(charset_info.isEmpty());
// Do serialization.
- SerializeDomForURL(page_url, false);
+ SerializeDomForURL(file_url, false);
// Load the serialized contents.
- ASSERT_TRUE(HasSerializedFrame(page_url));
+ ASSERT_TRUE(HasSerializedFrame(file_url));
const std::string& serialized_contents =
- GetSerializedContentForFrame(page_url);
- LoadContents(serialized_contents, GURL(WideToUTF8(page_url)),
+ GetSerializedContentForFrame(file_url);
+ LoadContents(serialized_contents, file_url,
web_frame->frame()->loader()->encoding());
// Make sure the first child of HEAD element is META which has charset
// declaration in serialized contents.
@@ -426,9 +420,8 @@ TEST_F(DomSerializerTests,
// Get file URL.
GURL file_url = net::FilePathToFileURL(page_file_path);
ASSERT_TRUE(file_url.SchemeIsFile());
- std::wstring page_url = ASCIIToWide(file_url.spec());
// Load the test file.
- LoadPageFromURL(page_url);
+ LoadPageFromURL(file_url);
// Make sure there are multiple META charset declarations in original
// document.
@@ -452,13 +445,13 @@ TEST_F(DomSerializerTests,
ASSERT(charset_declaration_count > 1);
// Do serialization.
- SerializeDomForURL(page_url, false);
+ SerializeDomForURL(file_url, false);
// Load the serialized contents.
- ASSERT_TRUE(HasSerializedFrame(page_url));
+ ASSERT_TRUE(HasSerializedFrame(file_url));
const std::string& serialized_contents =
- GetSerializedContentForFrame(page_url);
- LoadContents(serialized_contents, GURL(WideToUTF8(page_url)),
+ GetSerializedContentForFrame(file_url);
+ LoadContents(serialized_contents, file_url,
web_frame->frame()->loader()->encoding());
// Make sure only first child of HEAD element is META which has charset
// declaration in serialized contents.
@@ -494,9 +487,8 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithEntitiesInText) {
// Get file URL.
GURL file_url = net::FilePathToFileURL(page_file_path);
ASSERT_TRUE(file_url.SchemeIsFile());
- std::wstring page_url = ASCIIToWide(file_url.spec());
// Load the test file.
- LoadPageFromURL(page_url);
+ LoadPageFromURL(file_url);
// Get BODY's text content in DOM.
WebFrameImpl* web_frame =
webkit_glue::GetWebFrameImplFromWebViewForSpecificURL(
@@ -510,16 +502,16 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithEntitiesInText) {
ASSERT_TRUE(text_node->isTextNode());
ASSERT_TRUE(createMarkup(text_node) == "&amp;&lt;&gt;\"\'");
// Do serialization.
- SerializeDomForURL(page_url, false);
+ SerializeDomForURL(file_url, false);
// Compare the serialized contents with original contents.
- ASSERT_TRUE(HasSerializedFrame(page_url));
+ ASSERT_TRUE(HasSerializedFrame(file_url));
const std::string& serialized_contents =
- GetSerializedContentForFrame(page_url);
+ GetSerializedContentForFrame(file_url);
// Because we add MOTW when serializing DOM, so before comparison, we also
// need to add MOTW to original_contents.
- std::wstring motw_declaration =
- webkit_glue::DomSerializer::GenerateMarkOfTheWebDeclaration(page_url);
- orginal_contents = WideToASCII(motw_declaration) + orginal_contents;
+ std::string motw_declaration =
+ webkit_glue::DomSerializer::GenerateMarkOfTheWebDeclaration(file_url);
+ orginal_contents = motw_declaration + orginal_contents;
ASSERT_EQ(orginal_contents, serialized_contents);
}
@@ -535,9 +527,8 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithEntitiesInAttributeValue) {
// Get file URL.
GURL file_url = net::FilePathToFileURL(page_file_path);
ASSERT_TRUE(file_url.SchemeIsFile());
- std::wstring page_url = ASCIIToWide(file_url.spec());
// Load the test file.
- LoadPageFromURL(page_url);
+ LoadPageFromURL(file_url);
// Get value of BODY's title attribute in DOM.
WebFrameImpl* web_frame =
webkit_glue::GetWebFrameImplFromWebViewForSpecificURL(
@@ -551,16 +542,16 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithEntitiesInAttributeValue) {
WebCore::HTMLNames::titleAttr);
ASSERT_TRUE(value == WebCore::String("&<>\"\'"));
// Do serialization.
- SerializeDomForURL(page_url, false);
+ SerializeDomForURL(file_url, false);
// Compare the serialized contents with original contents.
- ASSERT_TRUE(HasSerializedFrame(page_url));
+ ASSERT_TRUE(HasSerializedFrame(file_url));
const std::string& serialized_contents =
- GetSerializedContentForFrame(page_url);
+ GetSerializedContentForFrame(file_url);
// Because we add MOTW when serializing DOM, so before comparison, we also
// need to add MOTW to original_contents.
- std::wstring motw_declaration =
- webkit_glue::DomSerializer::GenerateMarkOfTheWebDeclaration(page_url);
- orginal_contents = WideToASCII(motw_declaration) + orginal_contents;
+ std::string motw_declaration =
+ webkit_glue::DomSerializer::GenerateMarkOfTheWebDeclaration(file_url);
+ orginal_contents = motw_declaration + orginal_contents;
ASSERT_EQ(serialized_contents, orginal_contents);
}
@@ -584,9 +575,8 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithBaseTag) {
// Get file URL.
GURL file_url = net::FilePathToFileURL(page_file_path.ToWStringHack());
ASSERT_TRUE(file_url.SchemeIsFile());
- std::wstring page_url = ASCIIToWide(file_url.spec());
// Load the test file.
- LoadPageFromURL(page_url);
+ LoadPageFromURL(file_url);
// Since for this test, we assume there is no savable sub-resource links for
// this test file, also all links are relative URLs in this test file, so we
// need to check those relative URLs and make sure document has BASE tag.
@@ -630,13 +620,13 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithBaseTag) {
ASSERT_NE(original_base_url, path_dir_url);
// Do serialization.
- SerializeDomForURL(page_url, false);
+ SerializeDomForURL(file_url, false);
// Load the serialized contents.
- ASSERT_TRUE(HasSerializedFrame(page_url));
+ ASSERT_TRUE(HasSerializedFrame(file_url));
const std::string& serialized_contents =
- GetSerializedContentForFrame(page_url);
- LoadContents(serialized_contents, GURL(WideToUTF8(page_url)),
+ GetSerializedContentForFrame(file_url);
+ LoadContents(serialized_contents, file_url,
web_frame->frame()->loader()->encoding());
// Make sure all links are absolute URLs and doc there are some number of
@@ -677,7 +667,7 @@ TEST_F(DomSerializerTests, SerialzeHTMLDOMWithBaseTag) {
ASSERT_EQ(new_base_tag_count, original_base_tag_count + 1);
// Make sure in new document, the base URL is equal with the |path_dir_url|.
GURL new_base_url(
- WideToUTF8(webkit_glue::StringToStdWString(doc->baseURL())));
+ webkit_glue::StringToStdString(doc->baseURL()));
ASSERT_EQ(new_base_url, path_dir_url);
}