Index: chrome/browser/android/offline_pages/offline_page_mhtml_archiver.cc |
diff --git a/chrome/browser/android/offline_pages/offline_page_mhtml_archiver.cc b/chrome/browser/android/offline_pages/offline_page_mhtml_archiver.cc |
index 0600f24a74e876b5134ace330460983e24cd0e5e..1e54d51c8b830678f74dce926607974191fc1d35 100644 |
--- a/chrome/browser/android/offline_pages/offline_page_mhtml_archiver.cc |
+++ b/chrome/browser/android/offline_pages/offline_page_mhtml_archiver.cc |
@@ -8,6 +8,7 @@ |
#include "base/bind_helpers.h" |
#include "base/files/file_path.h" |
#include "base/files/file_util.h" |
+#include "base/guid.h" |
#include "base/location.h" |
#include "base/logging.h" |
#include "base/strings/string16.h" |
@@ -25,13 +26,6 @@ |
namespace offline_pages { |
namespace { |
const base::FilePath::CharType kMHTMLExtension[] = FILE_PATH_LITERAL("mhtml"); |
-const base::FilePath::CharType kDefaultFileName[] = |
- FILE_PATH_LITERAL("offline_page"); |
-const int kTitleLengthMax = 80; |
-const char kMHTMLFileNameExtension[] = ".mhtml"; |
-const char kFileNameComponentsSeparator[] = "-"; |
-const char kReplaceChars[] = " "; |
-const char kReplaceWith[] = "_"; |
void DeleteFileOnFileThread(const base::FilePath& file_path, |
const base::Closure& callback) { |
@@ -44,34 +38,6 @@ void DeleteFileOnFileThread(const base::FilePath& file_path, |
} // namespace |
// static |
-std::string OfflinePageMHTMLArchiver::GetFileNameExtension() { |
- return kMHTMLFileNameExtension; |
-} |
- |
-// static |
-base::FilePath OfflinePageMHTMLArchiver::GenerateFileName( |
- const GURL& url, |
- const std::string& title, |
- int64_t archive_id) { |
- std::string title_part(title.substr(0, kTitleLengthMax)); |
- std::string suggested_name( |
- url.host() + kFileNameComponentsSeparator + |
- title_part + kFileNameComponentsSeparator + |
- base::Int64ToString(archive_id)); |
- |
- // Substitute spaces out from title. |
- base::ReplaceChars(suggested_name, kReplaceChars, kReplaceWith, |
- &suggested_name); |
- |
- return net::GenerateFileName(url, |
- std::string(), // content disposition |
- std::string(), // charset |
- suggested_name, |
- std::string(), // mime-type |
- kDefaultFileName) |
- .AddExtension(kMHTMLExtension); |
-} |
- |
OfflinePageMHTMLArchiver::OfflinePageMHTMLArchiver( |
content::WebContents* web_contents) |
: web_contents_(web_contents), |
@@ -129,9 +95,7 @@ void OfflinePageMHTMLArchiver::GenerateMHTML( |
GURL url(web_contents_->GetLastCommittedURL()); |
base::string16 title(web_contents_->GetTitle()); |
base::FilePath file_path( |
- archives_dir.Append( |
- GenerateFileName(url, base::UTF16ToUTF8(title), archive_id))); |
- |
+ archives_dir.Append(base::GenerateGUID()).AddExtension(kMHTMLExtension)); |
Pete Williamson
2017/01/03 20:32:30
Drive by: This means that if we generate another p
dewittj
2017/01/03 22:23:38
We do currently exhibit this behavior when we mana
|
content::MHTMLGenerationParams params(file_path); |
params.use_binary_encoding = true; |