Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7643)

Unified Diff: chrome/browser/sessions/session_types.cc

Issue 11876045: [Search] Store and recall search terms using NavigationEntry to improve search term extraction (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: reupload Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sessions/session_types.h ('k') | chrome/browser/sessions/session_types_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_types.cc
diff --git a/chrome/browser/sessions/session_types.cc b/chrome/browser/sessions/session_types.cc
index f4e7e03a8d95b7da225773196c1bd692ba759adc..916508569f751f463b771ac665489e73869b33f2 100644
--- a/chrome/browser/sessions/session_types.cc
+++ b/chrome/browser/sessions/session_types.cc
@@ -11,6 +11,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/sessions/session_command.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/search/search.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "sync/util/time.h"
@@ -51,6 +52,9 @@ TabNavigation TabNavigation::FromNavigationEntry(
// If you want to navigate a named frame in Chrome, you will first need to
// add support for persisting it. It is currently only used for layout tests.
CHECK(entry.GetFrameToNavigate().empty());
+ navigation.search_terms_ =
+ chrome::search::GetSearchTermsFromNavigationEntry(&entry);
+
return navigation;
}
@@ -135,6 +139,7 @@ TabNavigation TabNavigation::FromSyncData(
static_cast<content::PageTransition>(transition);
navigation.timestamp_ = base::Time();
+ navigation.search_terms_ = UTF8ToUTF16(sync_data.search_terms());
return navigation;
}
@@ -204,6 +209,7 @@ enum TypeMask {
// original_request_url_
// is_overriding_user_agent_
// timestamp_
+// search_terms_
void TabNavigation::WriteToPickle(Pickle* pickle) const {
pickle->WriteInt(index_);
@@ -248,6 +254,8 @@ void TabNavigation::WriteToPickle(Pickle* pickle) const {
original_request_url_.spec() : std::string());
pickle->WriteBool(is_overriding_user_agent_);
pickle->WriteInt64(timestamp_.ToInternalValue());
+
+ WriteString16ToPickle(pickle, &bytes_written, max_state_size, search_terms_);
}
bool TabNavigation::ReadFromPickle(PickleIterator* iterator) {
@@ -301,6 +309,10 @@ bool TabNavigation::ReadFromPickle(PickleIterator* iterator) {
} else {
timestamp_ = base::Time();
}
+
+ // If the search terms field can't be found, leave it empty.
+ if (!iterator->ReadString16(&search_terms_))
+ search_terms_.clear();
}
return true;
@@ -329,6 +341,8 @@ scoped_ptr<NavigationEntry> TabNavigation::ToNavigationEntry(
entry->SetOriginalRequestURL(original_request_url_);
entry->SetIsOverridingUserAgent(is_overriding_user_agent_);
entry->SetTimestamp(timestamp_);
+ entry->SetExtraData(chrome::search::kInstantExtendedSearchTermsKey,
+ search_terms_);
return entry.Pass();
}
@@ -421,6 +435,8 @@ sync_pb::TabNavigation TabNavigation::ToSyncData() const {
// The full-resolution timestamp works as a global ID.
sync_data.set_global_id(timestamp_.ToInternalValue());
+ sync_data.set_search_terms(UTF16ToUTF8(search_terms_));
+
return sync_data;
}
« no previous file with comments | « chrome/browser/sessions/session_types.h ('k') | chrome/browser/sessions/session_types_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698