| OLD | NEW |
| 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 "chrome/browser/sync/glue/synced_tab_delegate.h" | 5 #include "chrome/browser/sync/glue/synced_tab_delegate.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/glue/synced_window_delegate.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" | 8 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "content/public/browser/navigation_entry.h" | 10 #include "content/public/browser/navigation_entry.h" |
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 | 12 |
| 13 using browser_sync::SyncedTabDelegate; | 13 using browser_sync::SyncedTabDelegate; |
| 14 | 14 |
| 15 namespace browser_sync { | 15 namespace browser_sync { |
| 16 | 16 |
| 17 SyncedTabDelegate::SyncedTabDelegate() {} |
| 18 SyncedTabDelegate::~SyncedTabDelegate() {} |
| 19 |
| 17 content::NavigationEntry* SyncedTabDelegate::GetCurrentEntryMaybePending() | 20 content::NavigationEntry* SyncedTabDelegate::GetCurrentEntryMaybePending() |
| 18 const { | 21 const { |
| 19 return GetEntryAtIndexMaybePending(GetCurrentEntryIndex()); | 22 return GetEntryAtIndexMaybePending(GetCurrentEntryIndex()); |
| 20 } | 23 } |
| 21 | 24 |
| 22 content::NavigationEntry* SyncedTabDelegate::GetEntryAtIndexMaybePending( | 25 content::NavigationEntry* SyncedTabDelegate::GetEntryAtIndexMaybePending( |
| 23 int i) const { | 26 int i) const { |
| 24 return (GetPendingEntryIndex() == i) ? GetPendingEntry() : GetEntryAtIndex(i); | 27 return (GetPendingEntryIndex() == i) ? GetPendingEntry() : GetEntryAtIndex(i); |
| 25 } | 28 } |
| 26 | 29 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 51 found_valid_url = true; | 54 found_valid_url = true; |
| 52 } else if (virtual_url == GURL(chrome::kChromeUIHistoryURL)) { | 55 } else if (virtual_url == GURL(chrome::kChromeUIHistoryURL)) { |
| 53 // The history page is treated specially as we want it to trigger syncable | 56 // The history page is treated specially as we want it to trigger syncable |
| 54 // events for UI purposes. | 57 // events for UI purposes. |
| 55 found_valid_url = true; | 58 found_valid_url = true; |
| 56 } | 59 } |
| 57 } | 60 } |
| 58 return found_valid_url; | 61 return found_valid_url; |
| 59 } | 62 } |
| 60 | 63 |
| 64 void SyncedTabDelegate::SetSyncedWindowGetter( |
| 65 scoped_ptr<SyncedWindowDelegatesGetter> getter) { |
| 66 synced_window_getter_.reset(getter.release()); |
| 67 } |
| 68 |
| 61 const SyncedWindowDelegate* SyncedTabDelegate::GetSyncedWindowDelegate() const { | 69 const SyncedWindowDelegate* SyncedTabDelegate::GetSyncedWindowDelegate() const { |
| 62 return SyncedWindowDelegate::FindById(GetWindowId()); | 70 if (!synced_window_getter_) { |
| 71 NOTREACHED(); |
| 72 return NULL; |
| 73 } |
| 74 return synced_window_getter_->FindById(GetWindowId()); |
| 63 } | 75 } |
| 64 | 76 |
| 65 } // namespace browser_sync | 77 } // namespace browser_sync |
| OLD | NEW |