| OLD | NEW |
| 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/session_change_processor.h" | 5 #include "chrome/browser/sync/glue/session_change_processor.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "chrome/browser/extensions/tab_helper.h" | 11 #include "chrome/browser/extensions/tab_helper.h" |
| 12 #include "chrome/browser/history/history_notifications.h" | 12 #include "chrome/browser/history/history_notifications.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/sync/glue/session_model_associator.h" | 14 #include "chrome/browser/sync/glue/session_model_associator.h" |
| 15 #include "chrome/browser/sync/profile_sync_service.h" | 15 #include "chrome/browser/sync/profile_sync_service.h" |
| 16 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" | 16 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" |
| 17 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| 20 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
| 21 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 #include "sync/api/sync_error.h" | 25 #include "sync/api/sync_error.h" |
| 26 #include "sync/internal_api/public/base/model_type.h" | 26 #include "sync/internal_api/public/base/model_type.h" |
| 27 #include "sync/internal_api/public/base/model_type_payload_map.h" | 27 #include "sync/internal_api/public/base/model_type_state_map.h" |
| 28 #include "sync/internal_api/public/change_record.h" | 28 #include "sync/internal_api/public/change_record.h" |
| 29 #include "sync/internal_api/public/read_node.h" | 29 #include "sync/internal_api/public/read_node.h" |
| 30 #include "sync/protocol/session_specifics.pb.h" | 30 #include "sync/protocol/session_specifics.pb.h" |
| 31 | 31 |
| 32 using content::BrowserThread; | 32 using content::BrowserThread; |
| 33 using content::NavigationController; | 33 using content::NavigationController; |
| 34 using content::WebContents; | 34 using content::WebContents; |
| 35 | 35 |
| 36 namespace browser_sync { | 36 namespace browser_sync { |
| 37 | 37 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // refreshes just because the refresh page is open in a background tab). | 207 // refreshes just because the refresh page is open in a background tab). |
| 208 if (!modified_tabs.empty()) { | 208 if (!modified_tabs.empty()) { |
| 209 SyncedTabDelegate* tab = modified_tabs.front(); | 209 SyncedTabDelegate* tab = modified_tabs.front(); |
| 210 const content::NavigationEntry* entry = tab->GetActiveEntry(); | 210 const content::NavigationEntry* entry = tab->GetActiveEntry(); |
| 211 if (!tab->IsBeingDestroyed() && | 211 if (!tab->IsBeingDestroyed() && |
| 212 entry && | 212 entry && |
| 213 entry->GetVirtualURL().is_valid() && | 213 entry->GetVirtualURL().is_valid() && |
| 214 entry->GetVirtualURL().spec() == kNTPOpenTabSyncURL) { | 214 entry->GetVirtualURL().spec() == kNTPOpenTabSyncURL) { |
| 215 DVLOG(1) << "Triggering sync refresh for sessions datatype."; | 215 DVLOG(1) << "Triggering sync refresh for sessions datatype."; |
| 216 const syncer::ModelType type = syncer::SESSIONS; | 216 const syncer::ModelType type = syncer::SESSIONS; |
| 217 syncer::ModelTypePayloadMap payload_map; | 217 syncer::ModelTypeStateMap state_map; |
| 218 payload_map[type] = ""; | 218 state_map.insert(std::make_pair(type, syncer::InvalidationState())); |
| 219 content::NotificationService::current()->Notify( | 219 content::NotificationService::current()->Notify( |
| 220 chrome::NOTIFICATION_SYNC_REFRESH_LOCAL, | 220 chrome::NOTIFICATION_SYNC_REFRESH_LOCAL, |
| 221 content::Source<Profile>(profile_), | 221 content::Source<Profile>(profile_), |
| 222 content::Details<const syncer::ModelTypePayloadMap>(&payload_map)); | 222 content::Details<const syncer::ModelTypeStateMap>(&state_map)); |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 | 225 |
| 226 // Associate tabs first so the synced session tracker is aware of them. | 226 // Associate tabs first so the synced session tracker is aware of them. |
| 227 // Note that if we fail to associate, it means something has gone wrong, | 227 // Note that if we fail to associate, it means something has gone wrong, |
| 228 // such as our local session being deleted, so we disassociate and associate | 228 // such as our local session being deleted, so we disassociate and associate |
| 229 // again. | 229 // again. |
| 230 bool reassociation_needed = !modified_tabs.empty() && | 230 bool reassociation_needed = !modified_tabs.empty() && |
| 231 !session_model_associator_->AssociateTabs(modified_tabs, NULL); | 231 !session_model_associator_->AssociateTabs(modified_tabs, NULL); |
| 232 | 232 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 notification_registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED, | 366 notification_registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED, |
| 367 content::Source<Profile>(profile_)); | 367 content::Source<Profile>(profile_)); |
| 368 } | 368 } |
| 369 | 369 |
| 370 void SessionChangeProcessor::StopObserving() { | 370 void SessionChangeProcessor::StopObserving() { |
| 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 372 notification_registrar_.RemoveAll(); | 372 notification_registrar_.RemoveAll(); |
| 373 } | 373 } |
| 374 | 374 |
| 375 } // namespace browser_sync | 375 } // namespace browser_sync |
| OLD | NEW |