Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / sync / glue / synced_session_util.cc
blobef939048ac6b1006f17531a2644f51ba197c4f33
1 // Copyright 2015 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/glue/synced_session_util.h"
7 #include "chrome/common/url_constants.h"
8 #include "components/sessions/session_types.h"
9 #include "content/public/common/url_constants.h"
11 namespace {
13 // Controls which foreign tabs we're interested in syncing/displaying. Checks
14 // that the tab has navigations and contains at least one valid url.
15 // Note: chrome:// and file:// are not considered valid urls (for syncing).
16 bool ShouldSyncSessionTab(const sessions::SessionTab& tab) {
17 if (tab.navigations.empty())
18 return false;
19 bool found_valid_url = false;
20 for (size_t i = 0; i < tab.navigations.size(); ++i) {
21 const GURL& virtual_url = tab.navigations.at(i).virtual_url();
22 if (virtual_url.is_valid() &&
23 !virtual_url.SchemeIs(content::kChromeUIScheme) &&
24 !virtual_url.SchemeIs(chrome::kChromeNativeScheme) &&
25 !virtual_url.SchemeIsFile()) {
26 found_valid_url = true;
27 break;
30 return found_valid_url;
33 } // namespace
35 namespace browser_sync {
37 bool SessionWindowHasNoTabsToSync(const sessions::SessionWindow& window) {
38 int num_populated = 0;
39 for (auto i = window.tabs.begin(); i != window.tabs.end(); ++i) {
40 const sessions::SessionTab* tab = *i;
41 if (ShouldSyncSessionTab(*tab))
42 num_populated++;
44 return (num_populated == 0);
47 } // namespace browser_sync