| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/sync/tab_contents_synced_tab_delegate.h" | 5 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/sessions/session_tab_helper.h" | 9 #include "chrome/browser/sessions/session_tab_helper.h" |
| 10 #include "chrome/common/features.h" |
| 10 #include "components/sessions/content/content_serialized_navigation_builder.h" | 11 #include "components/sessions/content/content_serialized_navigation_builder.h" |
| 11 #include "components/sync_sessions/sync_sessions_client.h" | 12 #include "components/sync_sessions/sync_sessions_client.h" |
| 12 #include "components/sync_sessions/synced_window_delegate.h" | 13 #include "components/sync_sessions/synced_window_delegate.h" |
| 13 #include "components/sync_sessions/synced_window_delegates_getter.h" | 14 #include "components/sync_sessions/synced_window_delegates_getter.h" |
| 14 #include "content/public/browser/favicon_status.h" | 15 #include "content/public/browser/favicon_status.h" |
| 15 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
| 16 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 | 19 |
| 19 #if defined(ENABLE_EXTENSIONS) | 20 #if defined(ENABLE_EXTENSIONS) |
| 20 #include "chrome/browser/extensions/tab_helper.h" | 21 #include "chrome/browser/extensions/tab_helper.h" |
| 21 #include "extensions/common/extension.h" | 22 #include "extensions/common/extension.h" |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 #if defined(ENABLE_SUPERVISED_USERS) | 25 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 25 #include "chrome/browser/supervised_user/supervised_user_navigation_observer.h" | 26 #include "chrome/browser/supervised_user/supervised_user_navigation_observer.h" |
| 26 #endif | 27 #endif |
| 27 | 28 |
| 28 using content::NavigationEntry; | 29 using content::NavigationEntry; |
| 29 | 30 |
| 30 DEFINE_WEB_CONTENTS_USER_DATA_KEY(TabContentsSyncedTabDelegate); | 31 DEFINE_WEB_CONTENTS_USER_DATA_KEY(TabContentsSyncedTabDelegate); |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 // Helper to access the correct NavigationEntry, accounting for pending entries. | 35 // Helper to access the correct NavigationEntry, accounting for pending entries. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 *entry); | 109 *entry); |
| 109 } | 110 } |
| 110 | 111 |
| 111 bool TabContentsSyncedTabDelegate::ProfileIsSupervised() const { | 112 bool TabContentsSyncedTabDelegate::ProfileIsSupervised() const { |
| 112 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()) | 113 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()) |
| 113 ->IsSupervised(); | 114 ->IsSupervised(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 const std::vector<std::unique_ptr<const sessions::SerializedNavigationEntry>>* | 117 const std::vector<std::unique_ptr<const sessions::SerializedNavigationEntry>>* |
| 117 TabContentsSyncedTabDelegate::GetBlockedNavigations() const { | 118 TabContentsSyncedTabDelegate::GetBlockedNavigations() const { |
| 118 #if defined(ENABLE_SUPERVISED_USERS) | 119 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 119 SupervisedUserNavigationObserver* navigation_observer = | 120 SupervisedUserNavigationObserver* navigation_observer = |
| 120 SupervisedUserNavigationObserver::FromWebContents(web_contents_); | 121 SupervisedUserNavigationObserver::FromWebContents(web_contents_); |
| 121 DCHECK(navigation_observer); | 122 DCHECK(navigation_observer); |
| 122 return &navigation_observer->blocked_navigations(); | 123 return &navigation_observer->blocked_navigations(); |
| 123 #else | 124 #else |
| 124 NOTREACHED(); | 125 NOTREACHED(); |
| 125 return nullptr; | 126 return nullptr; |
| 126 #endif | 127 #endif |
| 127 } | 128 } |
| 128 | 129 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 155 for (int i = 0; i < entry_count; ++i) { | 156 for (int i = 0; i < entry_count; ++i) { |
| 156 const GURL& virtual_url = GetVirtualURLAtIndex(i); | 157 const GURL& virtual_url = GetVirtualURLAtIndex(i); |
| 157 if (!virtual_url.is_valid()) | 158 if (!virtual_url.is_valid()) |
| 158 continue; | 159 continue; |
| 159 | 160 |
| 160 if (sessions_client->ShouldSyncURL(virtual_url)) | 161 if (sessions_client->ShouldSyncURL(virtual_url)) |
| 161 return true; | 162 return true; |
| 162 } | 163 } |
| 163 return false; | 164 return false; |
| 164 } | 165 } |
| OLD | NEW |