diff options
-rw-r--r-- | chrome/browser/sessions/DEPS | 4 | ||||
-rw-r--r-- | chrome/browser/sessions/base_session_service.cc | 45 | ||||
-rw-r--r-- | chrome/browser/sessions/base_session_service.h | 9 | ||||
-rw-r--r-- | chrome/browser/sessions/compress_data_helper.cc | 137 | ||||
-rw-r--r-- | chrome/browser/sessions/compress_data_helper.h | 34 | ||||
-rw-r--r-- | chrome/browser/sessions/compress_data_helper_unittest.cc | 74 | ||||
-rw-r--r-- | chrome/browser/sessions/session_restore.cc | 22 | ||||
-rw-r--r-- | chrome/browser/sessions/session_service_unittest.cc | 69 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 7 | ||||
-rw-r--r-- | content/common/view_message_enums.h | 5 | ||||
-rw-r--r-- | webkit/glue/glue_serialize.cc | 25 | ||||
-rw-r--r-- | webkit/glue/glue_serialize.h | 8 | ||||
-rw-r--r-- | webkit/glue/glue_serialize_unittest.cc | 59 |
15 files changed, 16 insertions, 485 deletions
diff --git a/chrome/browser/sessions/DEPS b/chrome/browser/sessions/DEPS deleted file mode 100644 index 5a55055..0000000 --- a/chrome/browser/sessions/DEPS +++ /dev/null @@ -1,4 +0,0 @@ -include_rules = [ - # For compressing data stored in SessionStorage. - "+third_party/bzip2", -] diff --git a/chrome/browser/sessions/base_session_service.cc b/chrome/browser/sessions/base_session_service.cc index 6991e24..5cd5780 100644 --- a/chrome/browser/sessions/base_session_service.cc +++ b/chrome/browser/sessions/base_session_service.cc @@ -5,17 +5,14 @@ #include "chrome/browser/sessions/base_session_service.h" #include "base/bind.h" -#include "base/command_line.h" #include "base/metrics/histogram.h" #include "base/pickle.h" #include "base/stl_util.h" #include "base/threading/thread.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/sessions/compress_data_helper.h" #include "chrome/browser/sessions/session_backend.h" #include "chrome/browser/sessions/session_types.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_entry.h" @@ -78,14 +75,10 @@ BaseSessionService::BaseSessionService(SessionType type, path_(path), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), pending_reset_(false), - commands_since_reset_(0), - save_post_data_(false) { + commands_since_reset_(0) { if (profile) { // We should never be created when incognito. DCHECK(!profile->IsOffTheRecord()); - const CommandLine* command_line = CommandLine::ForCurrentProcess(); - save_post_data_ = - command_line->HasSwitch(switches::kEnableRestoreSessionState); } backend_ = new SessionBackend(type, profile_ ? profile_->GetPath() : path_); @@ -170,10 +163,13 @@ SessionCommand* BaseSessionService::CreateUpdateTabNavigationCommand( WriteString16ToPickle(pickle, &bytes_written, max_state_size, entry.GetTitle()); - std::string content_state_without_post; if (entry.GetHasPostData()) { - content_state_without_post = + // Remove the form data, it may contain sensitive information. + std::string content_state_without_post = webkit_glue::RemoveFormDataFromHistoryState(entry.GetContentState()); + WriteStringToPickle(pickle, &bytes_written, max_state_size, + content_state_without_post); + int original_size = entry.GetContentState().size() / 1024; int new_size = content_state_without_post.size() / 1024; UMA_HISTOGRAM_CUSTOM_COUNTS( @@ -187,22 +183,10 @@ SessionCommand* BaseSessionService::CreateUpdateTabNavigationCommand( "SessionService.ContentStateSizeWithoutPost", entry.GetContentState().size() / 1024, 62, 100000, 50); + WriteStringToPickle(pickle, &bytes_written, max_state_size, + entry.GetContentState()); } - std::string content_state; - - if (!save_post_data_) { - // TODO(marja): This branch will be removed when saving the post data - // becomes the default. - if (entry.GetHasPostData()) - content_state = content_state_without_post; - else - content_state = entry.GetContentState(); - } - // Else: use an empty content state for keeping the data format compatible. - - WriteStringToPickle(pickle, &bytes_written, max_state_size, content_state); - pickle.WriteInt(entry.GetTransitionType()); int type_mask = entry.GetHasPostData() ? TabNavigation::HAS_POST_DATA : 0; pickle.WriteInt(type_mask); @@ -212,11 +196,6 @@ SessionCommand* BaseSessionService::CreateUpdateTabNavigationCommand( entry.GetReferrer().url.spec() : std::string()); pickle.WriteInt(entry.GetReferrer().policy); - if (save_post_data_) { - CompressDataHelper::CompressAndWriteStringToPickle( - entry.GetContentState(), max_state_size, &pickle, &bytes_written); - } - // Adding more data? Be sure and update TabRestoreService too. return new SessionCommand(command_id, pickle); } @@ -277,14 +256,6 @@ bool BaseSessionService::RestoreUpdateTabNavigationCommand( navigation->referrer_ = content::Referrer( referrer_spec.empty() ? GURL() : GURL(referrer_spec), policy); - - // And even later, compressed content state was added. - std::string content_state; - if (CompressDataHelper::ReadAndDecompressStringFromPickle( - *pickle.get(), &iterator, &content_state) && - !content_state.empty()) { - navigation->state_ = content_state; - } } navigation->virtual_url_ = GURL(url_spec); diff --git a/chrome/browser/sessions/base_session_service.h b/chrome/browser/sessions/base_session_service.h index 9c1dbb3..acd06f4 100644 --- a/chrome/browser/sessions/base_session_service.h +++ b/chrome/browser/sessions/base_session_service.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,6 @@ #include "base/basictypes.h" #include "base/callback.h" #include "base/file_path.h" -#include "base/gtest_prod_util.h" #include "base/location.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" @@ -159,9 +158,6 @@ class BaseSessionService : public CancelableRequestProvider, static const int max_persist_navigation_count; private: - FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, KeepPostData); - FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, RemovePostData); - // The profile. This may be null during testing. Profile* profile_; @@ -184,9 +180,6 @@ class BaseSessionService : public CancelableRequestProvider, // The number of commands sent to the backend before doing a reset. int commands_since_reset_; - // Whether to save the HTTP bodies of the POST requests. - bool save_post_data_; - DISALLOW_COPY_AND_ASSIGN(BaseSessionService); }; diff --git a/chrome/browser/sessions/compress_data_helper.cc b/chrome/browser/sessions/compress_data_helper.cc deleted file mode 100644 index abad8a9..0000000 --- a/chrome/browser/sessions/compress_data_helper.cc +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/sessions/compress_data_helper.h" - -#include "base/memory/scoped_ptr.h" -#include "base/pickle.h" - -#if defined(USE_SYSTEM_LIBBZ2) -#include <bzlib.h> -#else -#include "third_party/bzip2/bzlib.h" -#endif - -#include <string> - -// static -void CompressDataHelper::CompressAndWriteStringToPickle(const std::string& str, - int max_bytes, - Pickle* pickle, - int* bytes_written) { - // If there is no data to write, only write the size (0). - if (str.empty()) { - pickle->WriteInt(0); - return; - } - - bool written = false; - int max_output_size = max_bytes - *bytes_written; - if (max_output_size > 0) { - // We need a non-const char* to pass to the compression algorithm. - int input_size = str.size(); - scoped_array<char> input(new char[input_size]); - memcpy(input.get(), str.data(), input_size); - - scoped_array<char> output(new char[max_output_size]); - memset(output.get(), 0, max_output_size); - - bz_stream stream; - stream.bzalloc = NULL; - stream.bzfree = NULL; - stream.opaque = NULL; - int result = BZ2_bzCompressInit(&stream, - 1, // 100K block size ( > size of our data) - 0, // quiet - 0); // default work factor - if (result == BZ_OK) { - stream.next_in = input.get(); - stream.avail_in = input_size; - stream.next_out = output.get(); - stream.avail_out = max_output_size; - do { - result = BZ2_bzCompress(&stream, BZ_FINISH); - } while (result == BZ_FINISH_OK); - - // If there wasn't enough space for the output, the result won't be - // BZ_STREAM_END. - if (result == BZ_STREAM_END) { - result = BZ2_bzCompressEnd(&stream); - DCHECK(stream.total_out_lo32 <= - static_cast<unsigned>(max_output_size)); - if (result == BZ_OK) { - // Write the size of the original input, so that the decompression - // part knows how much memory to allocate. - pickle->WriteInt(input_size); - pickle->WriteData(output.get(), stream.total_out_lo32); - - *bytes_written += stream.total_out_lo32; - written = true; - } - } - } - } - if (!written) { - // We cannot write any data. Write only the data size (0). The reading part - // will not try to read any data after seeing the size 0. - pickle->WriteInt(0); - } -} - -// static -bool CompressDataHelper::ReadAndDecompressStringFromPickle(const Pickle& pickle, - void** iter, - std::string* str) { - // Read the size of the original data. - int original_size = 0; - if (!pickle.ReadLength(iter, &original_size)) - return false; - - if (original_size == 0) { - // No data to decompress. - return true; - } - - // Read the compressed data. - const char* compressed_data = NULL; - int compressed_size = 0; - if (!pickle.ReadData(iter, &compressed_data, &compressed_size)) - return false; - - scoped_array<char> original_data(new char[original_size]); - memset(original_data.get(), 0, original_size); - - // We need a non-const char* to pass to the decompression algorithm. - scoped_array<char> compressed_data_copy(new char[compressed_size]); - memcpy(compressed_data_copy.get(), compressed_data, compressed_size); - - bz_stream stream; - stream.bzalloc = NULL; - stream.bzfree = NULL; - stream.opaque = NULL; - - int result = BZ2_bzDecompressInit(&stream, 0, 0); - if (result == BZ_OK) { - stream.next_in = compressed_data_copy.get(); - stream.avail_in = compressed_size; - stream.next_out = original_data.get(); - stream.avail_out = original_size; - - do { - // We should know exactly how much space to allocate for the result, thus - // no out-of-space errors should happen. - DCHECK(stream.avail_out > 0); - result = BZ2_bzDecompress(&stream); - } while (result == BZ_OK); - - DCHECK(result == BZ_STREAM_END); - if (result == BZ_STREAM_END) { - result = BZ2_bzDecompressEnd(&stream); - if (result == BZ_OK) { - str->assign(original_data.get(), original_size); - } - } - } - return !str->empty(); -} diff --git a/chrome/browser/sessions/compress_data_helper.h b/chrome/browser/sessions/compress_data_helper.h deleted file mode 100644 index d7cbbaa..0000000 --- a/chrome/browser/sessions/compress_data_helper.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_SESSIONS_COMPRESS_DATA_HELPER_H_ -#define CHROME_BROWSER_SESSIONS_COMPRESS_DATA_HELPER_H_ -#pragma once - -#include "base/basictypes.h" - -#include <string> - -class Pickle; - -class CompressDataHelper { - public: - // Compresses and writes |str| into |pickle|. |str| may contain NULL - // charaters. - static void CompressAndWriteStringToPickle(const std::string& str, - int max_bytes, - Pickle* pickle, - int* bytes_written); - - // Reads and decompresses a string from |pickle| and saves it to |str|. |iter| - // indicates the position of the data. The same iterator is used by - // Pickle::Read* functions. - static bool ReadAndDecompressStringFromPickle(const Pickle& pickle, - void** iter, - std::string* str); - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(CompressDataHelper); -}; - -#endif // CHROME_BROWSER_SESSIONS_COMPRESS_DATA_HELPER_H_ diff --git a/chrome/browser/sessions/compress_data_helper_unittest.cc b/chrome/browser/sessions/compress_data_helper_unittest.cc deleted file mode 100644 index d0d5ec1..0000000 --- a/chrome/browser/sessions/compress_data_helper_unittest.cc +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/sessions/compress_data_helper.h" - -#include "base/pickle.h" -#include "testing/gtest/include/gtest/gtest.h" - -typedef testing::Test CompressDataHelperTest; - -TEST_F(CompressDataHelperTest, CompressAndDecompressData) { - std::string data = "test data for compression and decompression"; - // Add NULL bytes. - data[3] = data[8] = 0; - - Pickle pickle; - int bytes_written = 0; - int max_bytes = 100; - CompressDataHelper::CompressAndWriteStringToPickle( - data, max_bytes, &pickle, &bytes_written); - - EXPECT_GT(bytes_written, 0); - EXPECT_LT(bytes_written, max_bytes + 1); - - void* it = NULL; - std::string data_out; - - ASSERT_TRUE(CompressDataHelper::ReadAndDecompressStringFromPickle( - pickle, &it, &data_out)); - - ASSERT_EQ(data.size(), data_out.size()); - for (size_t i = 0; i < data_out.size(); ++i) - EXPECT_EQ(data_out[i], data[i]); -} - -TEST_F(CompressDataHelperTest, CompressAndDecompressEmptyData) { - std::string empty; - - Pickle pickle; - int bytes_written = 0; - int max_bytes = 100; - CompressDataHelper::CompressAndWriteStringToPickle( - empty, max_bytes, &pickle, &bytes_written); - - EXPECT_EQ(0, bytes_written); - - void* it = NULL; - std::string data_out; - ASSERT_TRUE(CompressDataHelper::ReadAndDecompressStringFromPickle( - pickle, &it, &data_out)); - - EXPECT_EQ(0U, data_out.size()); -} - -TEST_F(CompressDataHelperTest, TooMuchDataData) { - std::string data = "Some data that clearly cannot be compressed to 2 bytes"; - - Pickle pickle; - int bytes_written = 0; - int max_bytes = 2; - CompressDataHelper::CompressAndWriteStringToPickle( - data, max_bytes, &pickle, &bytes_written); - - EXPECT_EQ(0, bytes_written); - - // When the data is read, we get an empty string back. - void* it = NULL; - std::string data_out; - ASSERT_TRUE(CompressDataHelper::ReadAndDecompressStringFromPickle( - pickle, &it, &data_out)); - - EXPECT_EQ(0U, data_out.size()); -} diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index 656a6c4..dac3665 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -15,7 +15,6 @@ #include "base/command_line.h" #include "base/memory/scoped_ptr.h" #include "base/metrics/histogram.h" -#include "base/platform_file.h" #include "base/stl_util.h" #include "base/stringprintf.h" #include "chrome/browser/browser_process.h" @@ -32,15 +31,12 @@ #include "chrome/common/chrome_notification_types.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" -#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_service.h" -#include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" #include "net/base/network_change_notifier.h" -#include "webkit/glue/glue_serialize.h" #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/boot_times_loader.h" @@ -763,24 +759,6 @@ class SessionRestoreImpl : public content::NotificationObserver { tab.pinned, true, NULL); - - // Set up the file access rights for the selected navigation entry. - const int id = web_contents->GetRenderProcessHost()->GetID(); - const int read_file_permissions = - base::PLATFORM_FILE_OPEN | - base::PLATFORM_FILE_READ | - base::PLATFORM_FILE_EXCLUSIVE_READ | - base::PLATFORM_FILE_ASYNC; - const std::string& state = - tab.navigations.at(selected_index).state(); - const std::vector<FilePath>& file_paths = - webkit_glue::FilePathsFromHistoryState(state); - for (std::vector<FilePath>::const_iterator file = file_paths.begin(); - file != file_paths.end(); ++file) { - content::ChildProcessSecurityPolicy::GetInstance()-> - GrantPermissionsForFile(id, *file, read_file_permissions); - } - if (schedule_load) tab_loader_->ScheduleLoad(&web_contents->GetController()); } diff --git a/chrome/browser/sessions/session_service_unittest.cc b/chrome/browser/sessions/session_service_unittest.cc index 38a1303..b2de553 100644 --- a/chrome/browser/sessions/session_service_unittest.cc +++ b/chrome/browser/sessions/session_service_unittest.cc @@ -674,72 +674,3 @@ TEST_F(SessionServiceTest, DontPersistDefault) { ASSERT_EQ(1U, windows->size()); EXPECT_EQ(ui::SHOW_STATE_NORMAL, windows[0]->show_state); } - -TEST_F(SessionServiceTest, RemovePostData) { - helper_.service()->save_post_data_ = false; - - SessionID tab_id; - ASSERT_NE(window_id.id(), tab_id.id()); - - std::string content_state("dummy_content_state"); - // Create a TabNavigation containing content_state and representing a POST - // request. - TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), - ASCIIToUTF16("title"), content_state, - content::PAGE_TRANSITION_QUALIFIER_MASK); - nav1.set_type_mask(TabNavigation::HAS_POST_DATA); - - // Create a TabNavigation containing content_state and representing a normal - // request. - TabNavigation nav2(0, GURL("http://google.com/nopost"), content::Referrer(), - ASCIIToUTF16("title"), content_state, - content::PAGE_TRANSITION_QUALIFIER_MASK); - - helper_.PrepareTabInWindow(window_id, tab_id, 0, true); - UpdateNavigation(window_id, tab_id, nav1, 0, true); - UpdateNavigation(window_id, tab_id, nav2, 1, true); - - ScopedVector<SessionWindow> windows; - ReadWindows(&(windows.get())); - - helper_.AssertSingleWindowWithSingleTab(windows.get(), 2); - - // Expected: the content state of the POST navigation was removed but the - // content state of the normal navigation was not. - EXPECT_EQ("", windows[0]->tabs[0]->navigations[0].state()); - helper_.AssertNavigationEquals(nav2, windows[0]->tabs[0]->navigations[1]); -} - -TEST_F(SessionServiceTest, KeepPostData) { - helper_.service()->save_post_data_ = true; - - SessionID tab_id; - ASSERT_NE(window_id.id(), tab_id.id()); - std::string content_state("dummy_content_state"); - - // Create a TabNavigation containing content_state and representing a POST - // request. - TabNavigation nav1(0, GURL("http://google.com"), content::Referrer(), - ASCIIToUTF16("title"), content_state, - content::PAGE_TRANSITION_QUALIFIER_MASK); - nav1.set_type_mask(TabNavigation::HAS_POST_DATA); - - // Create a TabNavigation containing content_state and representing a normal - // request. - TabNavigation nav2(0, GURL("http://google.com/nopost"), content::Referrer(), - ASCIIToUTF16("title"), content_state, - content::PAGE_TRANSITION_QUALIFIER_MASK); - - helper_.PrepareTabInWindow(window_id, tab_id, 0, true); - UpdateNavigation(window_id, tab_id, nav1, 0, true); - UpdateNavigation(window_id, tab_id, nav2, 1, true); - - ScopedVector<SessionWindow> windows; - ReadWindows(&(windows.get())); - - helper_.AssertSingleWindowWithSingleTab(windows.get(), 2); - - // Expected: the content state of both navigations was saved and restored. - helper_.AssertNavigationEquals(nav1, windows[0]->tabs[0]->navigations[0]); - helper_.AssertNavigationEquals(nav2, windows[0]->tabs[0]->navigations[1]); -} diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index aba2bbe..de78ed7 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2192,8 +2192,6 @@ 'browser/service/service_process_control.h', 'browser/sessions/base_session_service.cc', 'browser/sessions/base_session_service.h', - 'browser/sessions/compress_data_helper.cc', - 'browser/sessions/compress_data_helper.h', 'browser/sessions/restore_tab_helper.cc', 'browser/sessions/restore_tab_helper.h', 'browser/sessions/session_backend.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 83e8e58..8388d99 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1676,7 +1676,6 @@ 'browser/search_engines/template_url_prepopulate_data_unittest.cc', 'browser/search_engines/template_url_scraper_unittest.cc', 'browser/search_engines/template_url_unittest.cc', - 'browser/sessions/compress_data_helper_unittest.cc', 'browser/sessions/session_backend_unittest.cc', 'browser/sessions/session_service_unittest.cc', 'browser/shell_integration_unittest.cc', diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 7f3e02cd..8fc8df5 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -162,14 +162,9 @@ ViewMsg_Navigate_Type::Value GetNavigationType( break; // Fall through to rest of function. } - // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates - // between |RESTORE_WITH_POST| and |RESTORE|. if (entry.restore_type() == NavigationEntryImpl::RESTORE_LAST_SESSION && - browser_context->DidLastSessionExitCleanly()) { - if (entry.GetHasPostData()) - return ViewMsg_Navigate_Type::RESTORE_WITH_POST; + browser_context->DidLastSessionExitCleanly()) return ViewMsg_Navigate_Type::RESTORE; - } return ViewMsg_Navigate_Type::NORMAL; } diff --git a/content/common/view_message_enums.h b/content/common/view_message_enums.h index 75c6868..92660f9 100644 --- a/content/common/view_message_enums.h +++ b/content/common/view_message_enums.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -104,9 +104,6 @@ struct ViewMsg_Navigate_Type { // the page's cache policy is ignored and we load from the cache. RESTORE, - // Like RESTORE, except that the navigation contains POST data. - RESTORE_WITH_POST, - // Navigation type not categorized by the other types. NORMAL }; diff --git a/webkit/glue/glue_serialize.cc b/webkit/glue/glue_serialize.cc index 04a4ac4..9ee14f9 100644 --- a/webkit/glue/glue_serialize.cc +++ b/webkit/glue/glue_serialize.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -498,29 +498,6 @@ WebHistoryItem HistoryItemFromString(const std::string& serialized_item) { return HistoryItemFromString(serialized_item, true, true); } -std::vector<FilePath> FilePathsFromHistoryState( - const std::string& content_state) { - std::vector<FilePath> to_return; - // TODO(darin): We should avoid using the WebKit API here, so that we do not - // need to have WebKit initialized before calling this method. - const WebHistoryItem& item = - HistoryItemFromString(content_state, true, true); - if (item.isNull()) { - // Couldn't parse the string. - return to_return; - } - const WebHTTPBody& http_body = item.httpBody(); - if (!http_body.isNull()) { - WebHTTPBody::Element element; - for (size_t i = 0; i < http_body.elementCount(); ++i) { - http_body.elementAt(i, element); - if (element.type == WebHTTPBody::Element::TypeFile) - to_return.push_back(WebStringToFilePath(element.filePath)); - } - } - return to_return; -} - // For testing purposes only. void HistoryItemToVersionedString(const WebHistoryItem& item, int version, std::string* serialized_item) { diff --git a/webkit/glue/glue_serialize.h b/webkit/glue/glue_serialize.h index 8d8ad2e..6e4c575 100644 --- a/webkit/glue/glue_serialize.h +++ b/webkit/glue/glue_serialize.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -11,8 +11,6 @@ #define WEBKIT_GLUE_GLUE_SERIALIZE_H_ #include <string> - -#include "base/file_path.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" #include "webkit/glue/webkit_glue_export.h" @@ -24,10 +22,6 @@ WEBKIT_GLUE_EXPORT std::string HistoryItemToString( WEBKIT_GLUE_EXPORT WebKit::WebHistoryItem HistoryItemFromString( const std::string& serialized_item); -// Reads file paths from the HTTP body of a serialized WebHistoryItem. -WEBKIT_GLUE_EXPORT std::vector<FilePath> FilePathsFromHistoryState( - const std::string& content_state); - // For testing purposes only. WEBKIT_GLUE_EXPORT void HistoryItemToVersionedString( const WebKit::WebHistoryItem& item, diff --git a/webkit/glue/glue_serialize_unittest.cc b/webkit/glue/glue_serialize_unittest.cc index 1d88c8d..54a3540 100644 --- a/webkit/glue/glue_serialize_unittest.cc +++ b/webkit/glue/glue_serialize_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,7 +11,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" #include "webkit/glue/glue_serialize.h" -#include "webkit/glue/webkit_glue.h" #include "webkit/glue/web_io_operators.h" using WebKit::WebData; @@ -84,13 +83,6 @@ class GlueSerializeTest : public testing::Test { // Checks that a == b. void HistoryItemExpectEqual(const WebHistoryItem& a, const WebHistoryItem& b) { - HistoryItemExpectBaseDataEqual(a, b); - HistoryItemExpectFormDataEqual(a, b); - HistoryItemExpectChildrenEqual(a, b); - } - - void HistoryItemExpectBaseDataEqual(const WebHistoryItem& a, - const WebHistoryItem& b) { EXPECT_EQ(string16(a.urlString()), string16(b.urlString())); EXPECT_EQ(string16(a.originalURLString()), string16(b.originalURLString())); EXPECT_EQ(string16(a.target()), string16(b.target())); @@ -109,10 +101,8 @@ class GlueSerializeTest : public testing::Test { EXPECT_EQ(a_docstate.size(), b_docstate.size()); for (size_t i = 0, c = a_docstate.size(); i < c; ++i) EXPECT_EQ(string16(a_docstate[i]), string16(b_docstate[i])); - } - void HistoryItemExpectFormDataEqual(const WebHistoryItem& a, - const WebHistoryItem& b) { + // Form Data const WebHTTPBody& a_body = a.httpBody(); const WebHTTPBody& b_body = b.httpBody(); EXPECT_EQ(!a_body.isNull(), !b_body.isNull()); @@ -131,10 +121,8 @@ class GlueSerializeTest : public testing::Test { } } EXPECT_EQ(string16(a.httpContentType()), string16(b.httpContentType())); - } - void HistoryItemExpectChildrenEqual(const WebHistoryItem& a, - const WebHistoryItem& b) { + // Children const WebVector<WebHistoryItem>& a_children = a.children(); const WebVector<WebHistoryItem>& b_children = b.children(); EXPECT_EQ(a_children.size(), b_children.size()); @@ -211,45 +199,4 @@ TEST_F(GlueSerializeTest, BadMessagesTest) { } } -TEST_F(GlueSerializeTest, RemoveFormData) { - const WebHistoryItem& item1 = MakeHistoryItem(true, true); - std::string serialized_item = webkit_glue::HistoryItemToString(item1); - serialized_item = - webkit_glue::RemoveFormDataFromHistoryState(serialized_item); - const WebHistoryItem& item2 = - webkit_glue::HistoryItemFromString(serialized_item); - - ASSERT_FALSE(item1.isNull()); - ASSERT_FALSE(item2.isNull()); - - HistoryItemExpectBaseDataEqual(item1, item2); - HistoryItemExpectChildrenEqual(item1, item2); - - // Form data was removed. - const WebHTTPBody& body1 = item1.httpBody(); - const WebHTTPBody& body2 = item2.httpBody(); - EXPECT_FALSE(body1.isNull()); - EXPECT_TRUE(body2.isNull()); -} - -TEST_F(GlueSerializeTest, FilePathsFromHistoryState) { - WebHistoryItem item = MakeHistoryItem(false, true); - - // Append file paths to item. - FilePath file_path1(FILE_PATH_LITERAL("file.txt")); - FilePath file_path2(FILE_PATH_LITERAL("another_file")); - WebHTTPBody http_body; - http_body.initialize(); - http_body.appendFile(webkit_glue::FilePathToWebString(file_path1)); - http_body.appendFile(webkit_glue::FilePathToWebString(file_path2)); - item.setHTTPBody(http_body); - - std::string serialized_item = webkit_glue::HistoryItemToString(item); - const std::vector<FilePath>& file_paths = - webkit_glue::FilePathsFromHistoryState(serialized_item); - ASSERT_EQ(2U, file_paths.size()); - EXPECT_EQ(file_path1, file_paths[0]); - EXPECT_EQ(file_path2, file_paths[1]); -} - } // namespace |