Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / sync / sessions / sessions_util.cc
blobe5a9384d9640a2b9c2a32ca882e8fe1684ff2e61
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/sync/sessions/sessions_util.h"
7 #include "chrome/browser/sync/glue/synced_tab_delegate.h"
8 #include "chrome/browser/sync/glue/synced_window_delegate.h"
9 #include "chrome/common/url_constants.h"
10 #include "content/public/browser/navigation_entry.h"
11 #include "url/gurl.h"
13 namespace browser_sync {
15 namespace sessions_util {
17 bool ShouldSyncTab(const SyncedTabDelegate& tab) {
18 if (SyncedWindowDelegate::FindById(tab.GetWindowId()) == NULL)
19 return false;
21 // Does the tab have a valid NavigationEntry?
22 if (tab.ProfileIsSupervised() && tab.GetBlockedNavigations()->size() > 0)
23 return true;
25 int entry_count = tab.GetEntryCount();
26 if (entry_count == 0)
27 return false; // This deliberately ignores a new pending entry.
29 int pending_index = tab.GetPendingEntryIndex();
30 bool found_valid_url = false;
31 for (int i = 0; i < entry_count; ++i) {
32 const content::NavigationEntry* entry = (i == pending_index) ?
33 tab.GetPendingEntry() : tab.GetEntryAtIndex(i);
34 if (!entry)
35 return false;
36 const GURL& virtual_url = entry->GetVirtualURL();
37 if (virtual_url.is_valid() &&
38 !virtual_url.SchemeIs(content::kChromeUIScheme) &&
39 !virtual_url.SchemeIs(chrome::kChromeNativeScheme) &&
40 !virtual_url.SchemeIsFile()) {
41 found_valid_url = true;
44 return found_valid_url;
47 } // namespace sessions_util
49 } // namespace browser_sync