| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/sync/glue/nigori_change_processor.h" |
| 6 |
| 7 #include "base/tracked_objects.h" |
| 8 #include "sync/internal_api/public/read_node.h" |
| 9 #include "sync/internal_api/public/read_transaction.h" |
| 10 #include "sync/internal_api/public/sync_encryption_handler.h" |
| 11 #include "sync/internal_api/public/user_share.h" |
| 12 #include "sync/internal_api/public/util/experiments.h" |
| 13 #include "sync/protocol/nigori_specifics.pb.h" |
| 14 |
| 15 namespace browser_sync { |
| 16 |
| 17 namespace { |
| 18 // The maximum number of times we will automatically overwrite the nigori node |
| 19 // because the encryption keys don't match (per chrome instantiation). |
| 20 static const int kNigoriOverwriteLimit = 10; |
| 21 } |
| 22 |
| 23 NigoriChangeProcessor::NigoriChangeProcessor( |
| 24 syncer::SyncEncryptionHandler* encryption_handler) |
| 25 : user_share_(NULL), |
| 26 encryption_handler_(encryption_handler) { |
| 27 } |
| 28 NigoriChangeProcessor::~NigoriChangeProcessor() {} |
| 29 |
| 30 void NigoriChangeProcessor::AssociateModels(syncer::UserShare* user_share) { |
| 31 user_share_ = user_share; |
| 32 encryption_handler_->ReloadNigori(); |
| 33 } |
| 34 |
| 35 void NigoriChangeProcessor::DisassociateModels() { |
| 36 user_share_ = NULL; |
| 37 encryption_handler_ = NULL; |
| 38 } |
| 39 |
| 40 bool NigoriChangeProcessor::ReceivedExperiments( |
| 41 syncer::Experiments* experiments) { |
| 42 if (!user_share_) |
| 43 return false; // Tests may not have user shares. |
| 44 syncer::ReadTransaction trans(FROM_HERE, user_share_); |
| 45 syncer::ReadNode node(&trans); |
| 46 if (node.InitByTagLookup(syncer::kNigoriTag) != syncer::BaseNode::INIT_OK) { |
| 47 DVLOG(1) << "Couldn't find Nigori node."; |
| 48 return false; |
| 49 } |
| 50 bool found_experiment = false; |
| 51 if (node.GetNigoriSpecifics().sync_tab_favicons()) { |
| 52 experiments->sync_tab_favicons = true; |
| 53 found_experiment = true; |
| 54 } |
| 55 return found_experiment; |
| 56 } |
| 57 |
| 58 } // namespace browser_sync |
| OLD | NEW |