| Index: chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
|
| diff --git a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
|
| index 2dd3d542ab3c65dc1d545cad5c11819f7d180c16..81f8005cde5fba23309e9565d729d92f6ebbd555 100644
|
| --- a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
|
| +++ b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc
|
| @@ -7,7 +7,9 @@
|
| #include "base/memory/ref_counted.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/sessions/session_tab_helper.h"
|
| +#include "components/sessions/content/content_serialized_navigation_builder.h"
|
| #include "components/sync_driver/glue/synced_window_delegate.h"
|
| +#include "content/public/browser/favicon_status.h"
|
| #include "content/public/browser/navigation_controller.h"
|
| #include "content/public/browser/navigation_entry.h"
|
| #include "content/public/browser/web_contents.h"
|
| @@ -25,6 +27,20 @@ using content::NavigationEntry;
|
|
|
| DEFINE_WEB_CONTENTS_USER_DATA_KEY(TabContentsSyncedTabDelegate);
|
|
|
| +namespace {
|
| +
|
| +// Helper to access the correct NavigationEntry, accounting for pending entries.
|
| +NavigationEntry* GetPossiblyPendingEntryAtIndex(
|
| + content::WebContents* web_contents,
|
| + int i) {
|
| + int pending_index = web_contents->GetController().GetPendingEntryIndex();
|
| + return (pending_index == i)
|
| + ? web_contents->GetController().GetPendingEntry()
|
| + : web_contents->GetController().GetEntryAtIndex(i);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| TabContentsSyncedTabDelegate::TabContentsSyncedTabDelegate(
|
| content::WebContents* web_contents)
|
| : web_contents_(web_contents), sync_session_id_(0) {}
|
| @@ -43,10 +59,6 @@ bool TabContentsSyncedTabDelegate::IsBeingDestroyed() const {
|
| return web_contents_->IsBeingDestroyed();
|
| }
|
|
|
| -Profile* TabContentsSyncedTabDelegate::profile() const {
|
| - return Profile::FromBrowserContext(web_contents_->GetBrowserContext());
|
| -}
|
| -
|
| std::string TabContentsSyncedTabDelegate::GetExtensionAppId() const {
|
| #if defined(ENABLE_EXTENSIONS)
|
| const scoped_refptr<const extensions::Extension> extension_app(
|
| @@ -69,27 +81,37 @@ int TabContentsSyncedTabDelegate::GetEntryCount() const {
|
| return web_contents_->GetController().GetEntryCount();
|
| }
|
|
|
| -int TabContentsSyncedTabDelegate::GetPendingEntryIndex() const {
|
| - return web_contents_->GetController().GetPendingEntryIndex();
|
| +GURL TabContentsSyncedTabDelegate::GetVirtualURLAtIndex(int i) const {
|
| + NavigationEntry* entry = GetPossiblyPendingEntryAtIndex(web_contents_, i);
|
| + return entry->GetVirtualURL();
|
| }
|
|
|
| -NavigationEntry* TabContentsSyncedTabDelegate::GetPendingEntry() const {
|
| - return web_contents_->GetController().GetPendingEntry();
|
| +GURL TabContentsSyncedTabDelegate::GetFaviconURLAtIndex(int i) const {
|
| + NavigationEntry* entry = GetPossiblyPendingEntryAtIndex(web_contents_, i);
|
| + return (entry->GetFavicon().valid ? entry->GetFavicon().url : GURL());
|
| }
|
|
|
| -NavigationEntry* TabContentsSyncedTabDelegate::GetEntryAtIndex(int i) const {
|
| - return web_contents_->GetController().GetEntryAtIndex(i);
|
| +ui::PageTransition TabContentsSyncedTabDelegate::GetTransitionAtIndex(
|
| + int i) const {
|
| + NavigationEntry* entry = GetPossiblyPendingEntryAtIndex(web_contents_, i);
|
| + return entry->GetTransitionType();
|
| }
|
|
|
| -NavigationEntry* TabContentsSyncedTabDelegate::GetActiveEntry() const {
|
| - return web_contents_->GetController().GetVisibleEntry();
|
| +void TabContentsSyncedTabDelegate::GetSerializedNavigationAtIndex(
|
| + int i,
|
| + sessions::SerializedNavigationEntry* serialized_entry) const {
|
| + NavigationEntry* entry = GetPossiblyPendingEntryAtIndex(web_contents_, i);
|
| + *serialized_entry =
|
| + sessions::ContentSerializedNavigationBuilder::FromNavigationEntry(i,
|
| + *entry);
|
| }
|
|
|
| bool TabContentsSyncedTabDelegate::ProfileIsSupervised() const {
|
| - return profile()->IsSupervised();
|
| + return Profile::FromBrowserContext(web_contents_->GetBrowserContext())
|
| + ->IsSupervised();
|
| }
|
|
|
| -const std::vector<const content::NavigationEntry*>*
|
| +const std::vector<const sessions::SerializedNavigationEntry*>*
|
| TabContentsSyncedTabDelegate::GetBlockedNavigations() const {
|
| #if defined(ENABLE_SUPERVISED_USERS)
|
| SupervisedUserNavigationObserver* navigation_observer =
|
| @@ -111,10 +133,6 @@ bool TabContentsSyncedTabDelegate::IsPinned() const {
|
|
|
| bool TabContentsSyncedTabDelegate::HasWebContents() const { return true; }
|
|
|
| -content::WebContents* TabContentsSyncedTabDelegate::GetWebContents() const {
|
| - return web_contents_;
|
| -}
|
| -
|
| int TabContentsSyncedTabDelegate::GetSyncId() const {
|
| return sync_session_id_;
|
| }
|
|
|