OLD | NEW |
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/password_change_processor.h" | 5 #include "chrome/browser/sync/glue/password_change_processor.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/tracked.h" | 10 #include "base/tracked.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/password_manager/password_store.h" | 12 #include "chrome/browser/password_manager/password_store.h" |
13 #include "chrome/browser/password_manager/password_store_change.h" | 13 #include "chrome/browser/password_manager/password_store_change.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/sync/glue/password_model_associator.h" | 15 #include "chrome/browser/sync/glue/password_model_associator.h" |
16 #include "chrome/browser/sync/profile_sync_service.h" | 16 #include "chrome/browser/sync/profile_sync_service.h" |
17 #include "chrome/browser/sync/protocol/password_specifics.pb.h" | 17 #include "chrome/browser/sync/protocol/password_specifics.pb.h" |
| 18 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/chrome_notification_types.h" |
18 #include "content/common/notification_details.h" | 20 #include "content/common/notification_details.h" |
19 #include "content/common/notification_source.h" | 21 #include "content/common/notification_source.h" |
20 #include "content/common/notification_type.h" | |
21 #include "webkit/glue/password_form.h" | 22 #include "webkit/glue/password_form.h" |
22 | 23 |
23 namespace browser_sync { | 24 namespace browser_sync { |
24 | 25 |
25 PasswordChangeProcessor::PasswordChangeProcessor( | 26 PasswordChangeProcessor::PasswordChangeProcessor( |
26 PasswordModelAssociator* model_associator, | 27 PasswordModelAssociator* model_associator, |
27 PasswordStore* password_store, | 28 PasswordStore* password_store, |
28 UnrecoverableErrorHandler* error_handler) | 29 UnrecoverableErrorHandler* error_handler) |
29 : ChangeProcessor(error_handler), | 30 : ChangeProcessor(error_handler), |
30 model_associator_(model_associator), | 31 model_associator_(model_associator), |
31 password_store_(password_store), | 32 password_store_(password_store), |
32 observing_(false), | 33 observing_(false), |
33 expected_loop_(MessageLoop::current()) { | 34 expected_loop_(MessageLoop::current()) { |
34 DCHECK(model_associator); | 35 DCHECK(model_associator); |
35 DCHECK(error_handler); | 36 DCHECK(error_handler); |
36 #if defined(OS_MACOSX) | 37 #if defined(OS_MACOSX) |
37 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 38 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
38 #else | 39 #else |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
40 #endif | 41 #endif |
41 StartObserving(); | 42 StartObserving(); |
42 } | 43 } |
43 | 44 |
44 PasswordChangeProcessor::~PasswordChangeProcessor() { | 45 PasswordChangeProcessor::~PasswordChangeProcessor() { |
45 DCHECK(expected_loop_ == MessageLoop::current()); | 46 DCHECK(expected_loop_ == MessageLoop::current()); |
46 } | 47 } |
47 | 48 |
48 void PasswordChangeProcessor::Observe(NotificationType type, | 49 void PasswordChangeProcessor::Observe(int type, |
49 const NotificationSource& source, | 50 const NotificationSource& source, |
50 const NotificationDetails& details) { | 51 const NotificationDetails& details) { |
51 DCHECK(expected_loop_ == MessageLoop::current()); | 52 DCHECK(expected_loop_ == MessageLoop::current()); |
52 DCHECK(NotificationType::LOGINS_CHANGED == type); | 53 DCHECK(chrome::NOTIFICATION_LOGINS_CHANGED == type); |
53 if (!observing_) | 54 if (!observing_) |
54 return; | 55 return; |
55 | 56 |
56 DCHECK(running()); | 57 DCHECK(running()); |
57 | 58 |
58 sync_api::WriteTransaction trans(FROM_HERE, share_handle()); | 59 sync_api::WriteTransaction trans(FROM_HERE, share_handle()); |
59 | 60 |
60 sync_api::ReadNode password_root(&trans); | 61 sync_api::ReadNode password_root(&trans); |
61 if (!password_root.InitByTagLookup(kPasswordTag)) { | 62 if (!password_root.InitByTagLookup(kPasswordTag)) { |
62 error_handler()->OnUnrecoverableError(FROM_HERE, | 63 error_handler()->OnUnrecoverableError(FROM_HERE, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 216 |
216 void PasswordChangeProcessor::StopImpl() { | 217 void PasswordChangeProcessor::StopImpl() { |
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
218 observing_ = false; | 219 observing_ = false; |
219 } | 220 } |
220 | 221 |
221 | 222 |
222 void PasswordChangeProcessor::StartObserving() { | 223 void PasswordChangeProcessor::StartObserving() { |
223 DCHECK(expected_loop_ == MessageLoop::current()); | 224 DCHECK(expected_loop_ == MessageLoop::current()); |
224 notification_registrar_.Add(this, | 225 notification_registrar_.Add(this, |
225 NotificationType::LOGINS_CHANGED, | 226 chrome::NOTIFICATION_LOGINS_CHANGED, |
226 Source<PasswordStore>(password_store_)); | 227 Source<PasswordStore>(password_store_)); |
227 } | 228 } |
228 | 229 |
229 void PasswordChangeProcessor::StopObserving() { | 230 void PasswordChangeProcessor::StopObserving() { |
230 DCHECK(expected_loop_ == MessageLoop::current()); | 231 DCHECK(expected_loop_ == MessageLoop::current()); |
231 notification_registrar_.Remove(this, | 232 notification_registrar_.Remove(this, |
232 NotificationType::LOGINS_CHANGED, | 233 chrome::NOTIFICATION_LOGINS_CHANGED, |
233 Source<PasswordStore>(password_store_)); | 234 Source<PasswordStore>(password_store_)); |
234 } | 235 } |
235 | 236 |
236 } // namespace browser_sync | 237 } // namespace browser_sync |
OLD | NEW |