Fix build break
[chromium-blink-merge.git] / chrome / browser / sync / glue / synced_session.cc
blob6da145d49666479ee40d040be0134d2be9e024ff
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
3 // found in the LICENSE file.
5 #include "chrome/browser/sync/glue/synced_session.h"
7 #include "base/stl_util.h"
8 #include "chrome/common/url_constants.h"
9 #include "content/public/browser/navigation_entry.h"
11 namespace browser_sync {
13 SyncedSession::SyncedSession() : session_tag("invalid"),
14 device_type(TYPE_UNSET) {
17 SyncedSession::~SyncedSession() {
18 STLDeleteContainerPairSecondPointers(windows.begin(), windows.end());
21 // Note: if you modify this, make sure you modify
22 // SessionModelAssociator::ShouldSyncTab to ensure the logic matches.
23 bool ShouldSyncSessionTab(const SessionTab& tab) {
24 if (tab.navigations.empty())
25 return false;
26 bool found_valid_url = false;
27 for (size_t i = 0; i < tab.navigations.size(); ++i) {
28 if (tab.navigations.at(i).virtual_url().is_valid() &&
29 !tab.navigations.at(i).virtual_url().SchemeIs("chrome") &&
30 !tab.navigations.at(i).virtual_url().SchemeIsFile()) {
31 found_valid_url = true;
34 return found_valid_url;
37 bool SessionWindowHasNoTabsToSync(const SessionWindow& window) {
38 int num_populated = 0;
39 for (std::vector<SessionTab*>::const_iterator i = window.tabs.begin();
40 i != window.tabs.end(); ++i) {
41 const SessionTab* tab = *i;
42 if (ShouldSyncSessionTab(*tab))
43 num_populated++;
45 return (num_populated == 0);
48 } // namespace browser_sync