Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(780)

Side by Side Diff: chrome/browser/sync/glue/synced_session.cc

Issue 923183003: Move URL fixup to a preliminary phase that doesn't affect virtual URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoid duplicate code Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/sync/glue/synced_session.h" 5 #include "chrome/browser/sync/glue/synced_session.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/common/url_constants.h" 8 #include "chrome/common/url_constants.h"
9 #include "content/public/browser/navigation_entry.h" 9 #include "content/public/browser/navigation_entry.h"
10 #include "content/public/common/url_constants.h" 10 #include "content/public/common/url_constants.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 case SyncedSession::TYPE_OTHER: 49 case SyncedSession::TYPE_OTHER:
50 // Intentionally fall-through 50 // Intentionally fall-through
51 default: 51 default:
52 header.set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_OTHER); 52 header.set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_OTHER);
53 break; 53 break;
54 } 54 }
55 return header; 55 return header;
56 } 56 }
57 57
58 // Note: if you modify this, make sure you modify 58 // Note: if you modify this, make sure you modify
59 // SessionModelAssociator::ShouldSyncTab to ensure the logic matches. 59 // browser_sync::sessions_util::ShouldSyncTab to ensure the logic matches.
60 bool ShouldSyncSessionTab(const sessions::SessionTab& tab) { 60 bool ShouldSyncSessionTab(const sessions::SessionTab& tab) {
61 if (tab.navigations.empty()) 61 if (tab.navigations.empty())
62 return false; 62 return false;
63 bool found_valid_url = false; 63 bool found_valid_url = false;
64 for (size_t i = 0; i < tab.navigations.size(); ++i) { 64 for (size_t i = 0; i < tab.navigations.size(); ++i) {
65 const GURL& virtual_url = tab.navigations.at(i).virtual_url(); 65 const GURL& virtual_url = tab.navigations.at(i).virtual_url();
66 if (virtual_url.is_valid() && 66 if (virtual_url.is_valid() &&
67 !virtual_url.SchemeIs(content::kChromeUIScheme) && 67 !virtual_url.SchemeIs(content::kChromeUIScheme) &&
68 !virtual_url.SchemeIs(chrome::kChromeNativeScheme) && 68 !virtual_url.SchemeIs(chrome::kChromeNativeScheme) &&
69 !virtual_url.SchemeIsFile()) { 69 !virtual_url.SchemeIsFile()) {
70 found_valid_url = true; 70 found_valid_url = true;
71 break; 71 break;
72 } 72 }
73 } 73 }
74 return found_valid_url; 74 return found_valid_url;
75 } 75 }
76 76
77 bool SessionWindowHasNoTabsToSync(const sessions::SessionWindow& window) { 77 bool SessionWindowHasNoTabsToSync(const sessions::SessionWindow& window) {
78 int num_populated = 0; 78 int num_populated = 0;
79 for (auto i = window.tabs.begin(); i != window.tabs.end(); ++i) { 79 for (auto i = window.tabs.begin(); i != window.tabs.end(); ++i) {
80 const sessions::SessionTab* tab = *i; 80 const sessions::SessionTab* tab = *i;
81 if (ShouldSyncSessionTab(*tab)) 81 if (ShouldSyncSessionTab(*tab))
82 num_populated++; 82 num_populated++;
83 } 83 }
84 return (num_populated == 0); 84 return (num_populated == 0);
85 } 85 }
86 86
87 } // namespace browser_sync 87 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698