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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 10235013: [Sync] Add support for automatic enabling of syncing tab favicons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert testserver for now Created 8 years, 8 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
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | sync/internal_api/sync_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "chrome/common/time_format.h" 54 #include "chrome/common/time_format.h"
55 #include "chrome/common/url_constants.h" 55 #include "chrome/common/url_constants.h"
56 #include "content/public/browser/notification_details.h" 56 #include "content/public/browser/notification_details.h"
57 #include "content/public/browser/notification_source.h" 57 #include "content/public/browser/notification_source.h"
58 #include "grit/generated_resources.h" 58 #include "grit/generated_resources.h"
59 #include "net/cookies/cookie_monster.h" 59 #include "net/cookies/cookie_monster.h"
60 #include "sync/internal_api/configure_reason.h" 60 #include "sync/internal_api/configure_reason.h"
61 #include "sync/js/js_arg_list.h" 61 #include "sync/js/js_arg_list.h"
62 #include "sync/js/js_event_details.h" 62 #include "sync/js/js_event_details.h"
63 #include "sync/util/cryptographer.h" 63 #include "sync/util/cryptographer.h"
64 #include "sync/util/experiments.h"
64 #include "ui/base/l10n/l10n_util.h" 65 #include "ui/base/l10n/l10n_util.h"
65 66
66 using browser_sync::ChangeProcessor; 67 using browser_sync::ChangeProcessor;
67 using browser_sync::DataTypeController; 68 using browser_sync::DataTypeController;
68 using browser_sync::DataTypeManager; 69 using browser_sync::DataTypeManager;
69 using browser_sync::JsBackend; 70 using browser_sync::JsBackend;
70 using browser_sync::JsController; 71 using browser_sync::JsController;
71 using browser_sync::JsEventDetails; 72 using browser_sync::JsEventDetails;
72 using browser_sync::JsEventHandler; 73 using browser_sync::JsEventHandler;
73 using browser_sync::SyncBackendHost; 74 using browser_sync::SyncBackendHost;
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 // server time as last reported by CheckServerReachable, so we don't have to 701 // server time as last reported by CheckServerReachable, so we don't have to
701 // rely on the local clock, which may be off significantly. 702 // rely on the local clock, which may be off significantly.
702 MessageLoop::current()->PostTask(FROM_HERE, 703 MessageLoop::current()->PostTask(FROM_HERE,
703 base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions, 704 base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions,
704 GetSessionModelAssociator()->AsWeakPtr())); 705 GetSessionModelAssociator()->AsWeakPtr()));
705 } 706 }
706 DVLOG(2) << "Notifying observers sync cycle completed"; 707 DVLOG(2) << "Notifying observers sync cycle completed";
707 NotifyObservers(); 708 NotifyObservers();
708 } 709 }
709 710
710 // TODO(sync): eventually support removing datatypes too. 711 void ProfileSyncService::OnExperimentsChanged(
711 void ProfileSyncService::OnDataTypesChanged( 712 const browser_sync::Experiments& experiments) {
712 syncable::ModelTypeSet to_add) { 713 if (current_experiments.Matches(experiments))
714 return;
715
713 // If this is a first time sync for a client, this will be called before 716 // If this is a first time sync for a client, this will be called before
714 // OnBackendInitialized() to ensure the new datatypes are available at sync 717 // OnBackendInitialized() to ensure the new datatypes are available at sync
715 // setup. As a result, the migrator won't exist yet. This is fine because for 718 // setup. As a result, the migrator won't exist yet. This is fine because for
716 // first time sync cases we're only concerned with making the datatype 719 // first time sync cases we're only concerned with making the datatype
717 // available. 720 // available.
718 if (migrator_.get() && 721 if (migrator_.get() &&
719 migrator_->state() != browser_sync::BackendMigrator::IDLE) { 722 migrator_->state() != browser_sync::BackendMigrator::IDLE) {
720 DVLOG(1) << "Dropping OnDataTypesChanged due to migrator busy."; 723 DVLOG(1) << "Dropping OnExperimentsChanged due to migrator busy.";
721 return; 724 return;
722 } 725 }
723 726
724 DVLOG(2) << "OnDataTypesChanged called with types: "
725 << syncable::ModelTypeSetToString(to_add);
726
727 const syncable::ModelTypeSet registered_types = GetRegisteredDataTypes(); 727 const syncable::ModelTypeSet registered_types = GetRegisteredDataTypes();
728 728 syncable::ModelTypeSet to_add;
729 if (experiments.sync_tabs)
730 to_add.Put(syncable::SESSIONS);
729 const syncable::ModelTypeSet to_register = 731 const syncable::ModelTypeSet to_register =
730 Difference(to_add, registered_types); 732 Difference(to_add, registered_types);
731 733 DVLOG(2) << "OnExperimentsChanged called with types: "
734 << syncable::ModelTypeSetToString(to_add);
732 DVLOG(2) << "Enabling types: " << syncable::ModelTypeSetToString(to_register); 735 DVLOG(2) << "Enabling types: " << syncable::ModelTypeSetToString(to_register);
733 736
734 for (syncable::ModelTypeSet::Iterator it = to_register.First(); 737 for (syncable::ModelTypeSet::Iterator it = to_register.First();
735 it.Good(); it.Inc()) { 738 it.Good(); it.Inc()) {
736 // Received notice to enable experimental type. Check if the type is 739 // Received notice to enable experimental type. Check if the type is
737 // registered, and if not register a new datatype controller. 740 // registered, and if not register a new datatype controller.
738 RegisterNewDataType(it.Get()); 741 RegisterNewDataType(it.Get());
739 #if !defined(OS_ANDROID) 742 #if !defined(OS_ANDROID)
740 // Enable the about:flags switch for the experimental type so we don't have 743 // Enable the about:flags switch for the experimental type so we don't have
741 // to always perform this reconfiguration. Once we set this, the type will 744 // to always perform this reconfiguration. Once we set this, the type will
(...skipping 19 matching lines...) Expand all
761 sync_prefs_.SetPreferredDataTypes(registered_types, registered_types); 764 sync_prefs_.SetPreferredDataTypes(registered_types, registered_types);
762 765
763 // Only automatically turn on types if we have already finished set up. 766 // Only automatically turn on types if we have already finished set up.
764 // Otherwise, just leave the experimental types on by default. 767 // Otherwise, just leave the experimental types on by default.
765 if (!to_register.Empty() && HasSyncSetupCompleted() && migrator_.get()) { 768 if (!to_register.Empty() && HasSyncSetupCompleted() && migrator_.get()) {
766 DVLOG(1) << "Dynamically enabling new datatypes: " 769 DVLOG(1) << "Dynamically enabling new datatypes: "
767 << syncable::ModelTypeSetToString(to_register); 770 << syncable::ModelTypeSetToString(to_register);
768 OnMigrationNeededForTypes(to_register); 771 OnMigrationNeededForTypes(to_register);
769 } 772 }
770 } 773 }
774
775 // Now enable any non-datatype features.
776 if (experiments.sync_tab_favicons) {
777 DVLOG(1) << "Enabling syncing of tab favicons.";
778 about_flags::SetExperimentEnabled(g_browser_process->local_state(),
779 "sync-tab-favicons",
780 true);
781 }
782
783 current_experiments = experiments;
771 } 784 }
772 785
773 void ProfileSyncService::UpdateAuthErrorState( 786 void ProfileSyncService::UpdateAuthErrorState(
774 const GoogleServiceAuthError& error) { 787 const GoogleServiceAuthError& error) {
775 is_auth_in_progress_ = false; 788 is_auth_in_progress_ = false;
776 last_auth_error_ = error; 789 last_auth_error_ = error;
777 790
778 // Fan the notification out to interested UI-thread components. 791 // Fan the notification out to interested UI-thread components.
779 NotifyObservers(); 792 NotifyObservers();
780 } 793 }
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1655 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1643 ProfileSyncService* old_this = this; 1656 ProfileSyncService* old_this = this;
1644 this->~ProfileSyncService(); 1657 this->~ProfileSyncService();
1645 new(old_this) ProfileSyncService( 1658 new(old_this) ProfileSyncService(
1646 new ProfileSyncComponentsFactoryImpl(profile, 1659 new ProfileSyncComponentsFactoryImpl(profile,
1647 CommandLine::ForCurrentProcess()), 1660 CommandLine::ForCurrentProcess()),
1648 profile, 1661 profile,
1649 signin, 1662 signin,
1650 behavior); 1663 behavior);
1651 } 1664 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | sync/internal_api/sync_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698