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 NigoriChangeProcessor::NigoriChangeProcessor( |
| 18 syncer::SyncEncryptionHandler* encryption_handler) |
| 19 : user_share_(NULL), |
| 20 encryption_handler_(encryption_handler) { |
| 21 } |
| 22 NigoriChangeProcessor::~NigoriChangeProcessor() {} |
| 23 |
| 24 void NigoriChangeProcessor::AssociateModels(syncer::UserShare* user_share) { |
| 25 user_share_ = user_share; |
| 26 encryption_handler_->ReloadNigori(); |
| 27 } |
| 28 |
| 29 void NigoriChangeProcessor::DisassociateModels() { |
| 30 user_share_ = NULL; |
| 31 encryption_handler_ = NULL; |
| 32 } |
| 33 |
| 34 bool NigoriChangeProcessor::ReceivedExperiments( |
| 35 syncer::Experiments* experiments) { |
| 36 if (!user_share_) |
| 37 return false; // Tests may not always have user shares. |
| 38 syncer::ReadTransaction trans(FROM_HERE, user_share_); |
| 39 syncer::ReadNode node(&trans); |
| 40 if (node.InitByTagLookup(syncer::kNigoriTag) != syncer::BaseNode::INIT_OK) { |
| 41 DVLOG(1) << "Couldn't find Nigori node."; |
| 42 return false; |
| 43 } |
| 44 bool found_experiment = false; |
| 45 if (node.GetNigoriSpecifics().sync_tab_favicons()) { |
| 46 experiments->sync_tab_favicons = true; |
| 47 found_experiment = true; |
| 48 } |
| 49 return found_experiment; |
| 50 } |
| 51 |
| 52 } // namespace browser_sync |
OLD | NEW |