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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "chrome/browser/extensions/extension_tab_helper.h" 13 #include "chrome/browser/extensions/extension_tab_helper.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/sync/engine/syncapi.h" 15 #include "chrome/browser/sync/engine/syncapi.h"
16 #include "chrome/browser/sync/glue/session_model_associator.h" 16 #include "chrome/browser/sync/glue/session_model_associator.h"
17 #include "chrome/browser/sync/profile_sync_service.h" 17 #include "chrome/browser/sync/profile_sync_service.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
19 #include "chrome/common/chrome_notification_types.h"
19 #include "content/browser/tab_contents/navigation_controller.h" 20 #include "content/browser/tab_contents/navigation_controller.h"
20 #include "content/browser/tab_contents/tab_contents.h" 21 #include "content/browser/tab_contents/tab_contents.h"
21 #include "content/common/notification_details.h" 22 #include "content/common/notification_details.h"
22 #include "content/common/notification_service.h" 23 #include "content/common/notification_service.h"
23 #include "content/common/notification_source.h" 24 #include "content/common/notification_source.h"
24 25
25 namespace browser_sync { 26 namespace browser_sync {
26 27
27 SessionChangeProcessor::SessionChangeProcessor( 28 SessionChangeProcessor::SessionChangeProcessor(
28 UnrecoverableErrorHandler* error_handler, 29 UnrecoverableErrorHandler* error_handler,
(...skipping 28 matching lines...) Expand all
57 const NotificationSource& source, 58 const NotificationSource& source,
58 const NotificationDetails& details) { 59 const NotificationDetails& details) {
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
60 DCHECK(running()); 61 DCHECK(running());
61 DCHECK(profile_); 62 DCHECK(profile_);
62 63
63 // Track which windows and/or tabs are modified. 64 // Track which windows and/or tabs are modified.
64 std::vector<TabContentsWrapper*> modified_tabs; 65 std::vector<TabContentsWrapper*> modified_tabs;
65 bool windows_changed = false; 66 bool windows_changed = false;
66 switch (type.value) { 67 switch (type.value) {
67 case NotificationType::BROWSER_OPENED: { 68 case chrome::BROWSER_OPENED: {
68 Browser* browser = Source<Browser>(source).ptr(); 69 Browser* browser = Source<Browser>(source).ptr();
69 if (browser->profile() != profile_) { 70 if (browser->profile() != profile_) {
70 return; 71 return;
71 } 72 }
72 73
73 windows_changed = true; 74 windows_changed = true;
74 break; 75 break;
75 } 76 }
76 77
77 case NotificationType::TAB_PARENTED: { 78 case NotificationType::TAB_PARENTED: {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 TabContentsWrapper* tab = 123 TabContentsWrapper* tab =
123 TabContentsWrapper::GetCurrentWrapperForContents( 124 TabContentsWrapper::GetCurrentWrapperForContents(
124 Source<NavigationController>(source).ptr()->tab_contents()); 125 Source<NavigationController>(source).ptr()->tab_contents());
125 if (!tab || tab->profile() != profile_) { 126 if (!tab || tab->profile() != profile_) {
126 return; 127 return;
127 } 128 }
128 modified_tabs.push_back(tab); 129 modified_tabs.push_back(tab);
129 break; 130 break;
130 } 131 }
131 132
132 case NotificationType::TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED: { 133 case chrome::TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED: {
133 ExtensionTabHelper* extension_tab_helper = 134 ExtensionTabHelper* extension_tab_helper =
134 Source<ExtensionTabHelper>(source).ptr(); 135 Source<ExtensionTabHelper>(source).ptr();
135 if (extension_tab_helper->tab_contents()->profile() != profile_) { 136 if (extension_tab_helper->tab_contents()->profile() != profile_) {
136 return; 137 return;
137 } 138 }
138 if (extension_tab_helper->extension_app()) { 139 if (extension_tab_helper->extension_app()) {
139 modified_tabs.push_back(extension_tab_helper->tab_contents_wrapper()); 140 modified_tabs.push_back(extension_tab_helper->tab_contents_wrapper());
140 } 141 }
141 break; 142 break;
142 } 143 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 LOG(WARNING) << "Dropping modification to local session."; 214 LOG(WARNING) << "Dropping modification to local session.";
214 return; 215 return;
215 } 216 }
216 const int64 mtime = sync_node.GetModificationTime(); 217 const int64 mtime = sync_node.GetModificationTime();
217 // Model associator handles foreign session update and add the same. 218 // Model associator handles foreign session update and add the same.
218 session_model_associator_->AssociateForeignSpecifics(specifics, mtime); 219 session_model_associator_->AssociateForeignSpecifics(specifics, mtime);
219 } 220 }
220 221
221 // Notify foreign session handlers that there are new sessions. 222 // Notify foreign session handlers that there are new sessions.
222 NotificationService::current()->Notify( 223 NotificationService::current()->Notify(
223 NotificationType::FOREIGN_SESSION_UPDATED, 224 chrome::FOREIGN_SESSION_UPDATED,
224 NotificationService::AllSources(), 225 NotificationService::AllSources(),
225 NotificationService::NoDetails()); 226 NotificationService::NoDetails());
226 227
227 StartObserving(); 228 StartObserving();
228 } 229 }
229 230
230 void SessionChangeProcessor::StartImpl(Profile* profile) { 231 void SessionChangeProcessor::StartImpl(Profile* profile) {
231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
232 DCHECK(profile); 233 DCHECK(profile);
233 DCHECK(profile_ == NULL); 234 DCHECK(profile_ == NULL);
(...skipping 13 matching lines...) Expand all
247 notification_registrar_.Add(this, NotificationType::TAB_PARENTED, 248 notification_registrar_.Add(this, NotificationType::TAB_PARENTED,
248 NotificationService::AllSources()); 249 NotificationService::AllSources());
249 notification_registrar_.Add(this, NotificationType::TAB_CLOSED, 250 notification_registrar_.Add(this, NotificationType::TAB_CLOSED,
250 NotificationService::AllSources()); 251 NotificationService::AllSources());
251 notification_registrar_.Add(this, NotificationType::NAV_LIST_PRUNED, 252 notification_registrar_.Add(this, NotificationType::NAV_LIST_PRUNED,
252 NotificationService::AllSources()); 253 NotificationService::AllSources());
253 notification_registrar_.Add(this, NotificationType::NAV_ENTRY_CHANGED, 254 notification_registrar_.Add(this, NotificationType::NAV_ENTRY_CHANGED,
254 NotificationService::AllSources()); 255 NotificationService::AllSources());
255 notification_registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, 256 notification_registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
256 NotificationService::AllSources()); 257 NotificationService::AllSources());
257 notification_registrar_.Add(this, NotificationType::BROWSER_OPENED, 258 notification_registrar_.Add(this, chrome::BROWSER_OPENED,
258 NotificationService::AllSources()); 259 NotificationService::AllSources());
259 notification_registrar_.Add(this, 260 notification_registrar_.Add(this,
260 NotificationType::TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, 261 chrome::TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED,
261 NotificationService::AllSources()); 262 NotificationService::AllSources());
262 } 263 }
263 264
264 void SessionChangeProcessor::StopObserving() { 265 void SessionChangeProcessor::StopObserving() {
265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
266 DCHECK(profile_); 267 DCHECK(profile_);
267 notification_registrar_.RemoveAll(); 268 notification_registrar_.RemoveAll();
268 } 269 }
269 270
270 } // namespace browser_sync 271 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698