OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/session_change_processor.h" | 5 #include "chrome/browser/sync/glue/session_change_processor.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/scoped_vector.h" | 12 #include "base/scoped_vector.h" |
13 #include "chrome/browser/profiles/profile.h" | |
13 #include "chrome/browser/sync/engine/syncapi.h" | 14 #include "chrome/browser/sync/engine/syncapi.h" |
14 #include "chrome/browser/sync/glue/session_model_associator.h" | 15 #include "chrome/browser/sync/glue/session_model_associator.h" |
16 #include "chrome/browser/sync/profile_sync_service.h" | |
15 #include "chrome/browser/tab_contents/navigation_controller.h" | 17 #include "chrome/browser/tab_contents/navigation_controller.h" |
16 #include "chrome/browser/tab_contents/tab_contents.h" | 18 #include "chrome/browser/tab_contents/tab_contents.h" |
17 #include "chrome/common/notification_details.h" | 19 #include "chrome/common/notification_details.h" |
18 #include "chrome/common/notification_service.h" | 20 #include "chrome/common/notification_service.h" |
19 #include "chrome/common/notification_source.h" | 21 #include "chrome/common/notification_source.h" |
20 | 22 |
21 namespace browser_sync { | 23 namespace browser_sync { |
22 | 24 |
23 SessionChangeProcessor::SessionChangeProcessor( | 25 SessionChangeProcessor::SessionChangeProcessor( |
24 UnrecoverableErrorHandler* error_handler, | 26 UnrecoverableErrorHandler* error_handler, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 "Session node lookup failed."); | 178 "Session node lookup failed."); |
177 return; | 179 return; |
178 } | 180 } |
179 | 181 |
180 // Check that the changed node is a child of the session folder. | 182 // Check that the changed node is a child of the session folder. |
181 DCHECK(root.GetId() == sync_node.GetParentId()); | 183 DCHECK(root.GetId() == sync_node.GetParentId()); |
182 DCHECK(syncable::SESSIONS == sync_node.GetModelType()); | 184 DCHECK(syncable::SESSIONS == sync_node.GetModelType()); |
183 | 185 |
184 const sync_pb::SessionSpecifics& specifics( | 186 const sync_pb::SessionSpecifics& specifics( |
185 sync_node.GetSessionSpecifics()); | 187 sync_node.GetSessionSpecifics()); |
188 if (specifics.session_tag() == | |
189 session_model_associator_->GetCurrentMachineTag() && | |
190 profile_->GetProfileSyncService()->cros_user() != "test user") { | |
tim (not reviewing)
2011/02/11 06:52:31
hmm... there's got to be a better way...
Nicolas Zea
2011/02/14 21:18:41
Done.
| |
191 // We should only ever receive a change to our own machine's session info | |
192 // if encryption was turned on. In that case, the data is still the same, | |
193 // so we can ignore. | |
194 LOG(WARNING) << "Dropping modification to local session."; | |
195 return; | |
196 } | |
186 const int64 mtime = sync_node.GetModificationTime(); | 197 const int64 mtime = sync_node.GetModificationTime(); |
187 // Model associator handles foreign session update and add the same. | 198 // Model associator handles foreign session update and add the same. |
188 session_model_associator_->AssociateForeignSpecifics(specifics, mtime); | 199 session_model_associator_->AssociateForeignSpecifics(specifics, mtime); |
189 } | 200 } |
190 | 201 |
191 // Notify foreign session handlers that there are new sessions. | 202 // Notify foreign session handlers that there are new sessions. |
192 NotificationService::current()->Notify( | 203 NotificationService::current()->Notify( |
193 NotificationType::FOREIGN_SESSION_UPDATED, | 204 NotificationType::FOREIGN_SESSION_UPDATED, |
194 NotificationService::AllSources(), | 205 NotificationService::AllSources(), |
195 NotificationService::NoDetails()); | 206 NotificationService::NoDetails()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 NotificationService::AllSources()); | 242 NotificationService::AllSources()); |
232 } | 243 } |
233 | 244 |
234 void SessionChangeProcessor::StopObserving() { | 245 void SessionChangeProcessor::StopObserving() { |
235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
236 DCHECK(profile_); | 247 DCHECK(profile_); |
237 notification_registrar_.RemoveAll(); | 248 notification_registrar_.RemoveAll(); |
238 } | 249 } |
239 | 250 |
240 } // namespace browser_sync | 251 } // namespace browser_sync |
OLD | NEW |