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

Side by Side Diff: components/sessions/serialized_navigation_entry.cc

Issue 101573003: Add the navigation redirect-chain to Sync sessions proto for offline analysis. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Brett's comment on patch set 46, and rebase. Created 6 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sessions/serialized_navigation_entry.h" 5 #include "components/sessions/serialized_navigation_entry.h"
6 6
7 #include "base/pickle.h" 7 #include "base/pickle.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/browser/favicon_status.h" 9 #include "content/public/browser/favicon_status.h"
10 #include "content/public/browser/navigation_controller.h" 10 #include "content/public/browser/navigation_controller.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 navigation.is_overriding_user_agent_ = entry.GetIsOverridingUserAgent(); 50 navigation.is_overriding_user_agent_ = entry.GetIsOverridingUserAgent();
51 navigation.timestamp_ = entry.GetTimestamp(); 51 navigation.timestamp_ = entry.GetTimestamp();
52 navigation.is_restored_ = entry.IsRestored(); 52 navigation.is_restored_ = entry.IsRestored();
53 // If you want to navigate a named frame in Chrome, you will first need to 53 // If you want to navigate a named frame in Chrome, you will first need to
54 // add support for persisting it. It is currently only used for layout tests. 54 // add support for persisting it. It is currently only used for layout tests.
55 CHECK(entry.GetFrameToNavigate().empty()); 55 CHECK(entry.GetFrameToNavigate().empty());
56 entry.GetExtraData(kSearchTermsKey, &navigation.search_terms_); 56 entry.GetExtraData(kSearchTermsKey, &navigation.search_terms_);
57 if (entry.GetFavicon().valid) 57 if (entry.GetFavicon().valid)
58 navigation.favicon_url_ = entry.GetFavicon().url; 58 navigation.favicon_url_ = entry.GetFavicon().url;
59 navigation.http_status_code_ = entry.GetHttpStatusCode(); 59 navigation.http_status_code_ = entry.GetHttpStatusCode();
60 navigation.redirect_chain_ = entry.GetRedirectChain();
60 61
61 return navigation; 62 return navigation;
62 } 63 }
63 64
64 SerializedNavigationEntry SerializedNavigationEntry::FromSyncData( 65 SerializedNavigationEntry SerializedNavigationEntry::FromSyncData(
65 int index, 66 int index,
66 const sync_pb::TabNavigation& sync_data) { 67 const sync_pb::TabNavigation& sync_data) {
67 SerializedNavigationEntry navigation; 68 SerializedNavigationEntry navigation;
68 navigation.index_ = index; 69 navigation.index_ = index;
69 navigation.unique_id_ = sync_data.unique_id(); 70 navigation.unique_id_ = sync_data.unique_id();
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 entry->SetTitle(title_); 357 entry->SetTitle(title_);
357 entry->SetPageState(page_state_); 358 entry->SetPageState(page_state_);
358 entry->SetPageID(page_id); 359 entry->SetPageID(page_id);
359 entry->SetHasPostData(has_post_data_); 360 entry->SetHasPostData(has_post_data_);
360 entry->SetPostID(post_id_); 361 entry->SetPostID(post_id_);
361 entry->SetOriginalRequestURL(original_request_url_); 362 entry->SetOriginalRequestURL(original_request_url_);
362 entry->SetIsOverridingUserAgent(is_overriding_user_agent_); 363 entry->SetIsOverridingUserAgent(is_overriding_user_agent_);
363 entry->SetTimestamp(timestamp_); 364 entry->SetTimestamp(timestamp_);
364 entry->SetExtraData(kSearchTermsKey, search_terms_); 365 entry->SetExtraData(kSearchTermsKey, search_terms_);
365 entry->SetHttpStatusCode(http_status_code_); 366 entry->SetHttpStatusCode(http_status_code_);
367 entry->SetRedirectChain(redirect_chain_);
366 368
367 // These fields should have default values. 369 // These fields should have default values.
368 DCHECK_EQ(STATE_INVALID, blocked_state_); 370 DCHECK_EQ(STATE_INVALID, blocked_state_);
369 DCHECK_EQ(0u, content_pack_categories_.size()); 371 DCHECK_EQ(0u, content_pack_categories_.size());
370 372
371 return entry.Pass(); 373 return entry.Pass();
372 } 374 }
373 375
374 // TODO(zea): perhaps sync state (scroll position, form entries, etc.) as well? 376 // TODO(zea): perhaps sync state (scroll position, form entries, etc.) as well?
375 // See http://crbug.com/67068. 377 // See http://crbug.com/67068.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 sync_data.set_blocked_state( 472 sync_data.set_blocked_state(
471 static_cast<sync_pb::TabNavigation_BlockedState>(blocked_state_)); 473 static_cast<sync_pb::TabNavigation_BlockedState>(blocked_state_));
472 } 474 }
473 475
474 for (std::set<std::string>::const_iterator it = 476 for (std::set<std::string>::const_iterator it =
475 content_pack_categories_.begin(); 477 content_pack_categories_.begin();
476 it != content_pack_categories_.end(); ++it) { 478 it != content_pack_categories_.end(); ++it) {
477 sync_data.add_content_pack_categories(*it); 479 sync_data.add_content_pack_categories(*it);
478 } 480 }
479 481
482 // Copy all redirect chain entries except the last URL (which should match
483 // the virtual_url).
484 if (redirect_chain_.size() > 1) { // Single entry chains have no redirection.
485 size_t last_entry = redirect_chain_.size() - 1;
486 for (size_t i = 0; i < last_entry; i++) {
487 sync_pb::NavigationRedirect* navigation_redirect =
488 sync_data.add_navigation_redirect();
489 navigation_redirect->set_url(redirect_chain_[i].spec());
490 }
491 // If the last URL didn't match the virtual_url, record it separately.
492 if (sync_data.virtual_url() != redirect_chain_[last_entry].spec()) {
493 sync_data.set_last_navigation_redirect_url(
494 redirect_chain_[last_entry].spec());
495 }
496 }
497
480 sync_data.set_is_restored(is_restored_); 498 sync_data.set_is_restored(is_restored_);
481 499
482 return sync_data; 500 return sync_data;
483 } 501 }
484 502
485 // static 503 // static
486 std::vector<NavigationEntry*> SerializedNavigationEntry::ToNavigationEntries( 504 std::vector<NavigationEntry*> SerializedNavigationEntry::ToNavigationEntries(
487 const std::vector<SerializedNavigationEntry>& navigations, 505 const std::vector<SerializedNavigationEntry>& navigations,
488 content::BrowserContext* browser_context) { 506 content::BrowserContext* browser_context) {
489 int page_id = 0; 507 int page_id = 0;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 541 }
524 542
525 if (referrer_.url != old_referrer.url || 543 if (referrer_.url != old_referrer.url ||
526 referrer_.policy != old_referrer.policy) { 544 referrer_.policy != old_referrer.policy) {
527 referrer_ = content::Referrer(); 545 referrer_ = content::Referrer();
528 page_state_ = page_state_.RemoveReferrer(); 546 page_state_ = page_state_.RemoveReferrer();
529 } 547 }
530 } 548 }
531 549
532 } // namespace sessions 550 } // namespace sessions
OLDNEW
« no previous file with comments | « components/sessions/serialized_navigation_entry.h ('k') | components/sessions/serialized_navigation_entry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698