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

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.cc

Issue 2700783002: s/\bArc\b/ARC/g for ARC related code. (Closed)
Patch Set: Address ARC++ Created 3 years, 10 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/app_list/arc/arc_package_sync_data_type_controller.h " 5 #include "chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.h "
6 6
7 #include "base/threading/thread_task_runner_handle.h" 7 #include "base/threading/thread_task_runner_handle.h"
8 #include "chrome/browser/chromeos/arc/arc_util.h" 8 #include "chrome/browser/chromeos/arc/arc_util.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
11 #include "components/prefs/pref_service.h" 11 #include "components/prefs/pref_service.h"
12 #include "components/sync/base/pref_names.h" 12 #include "components/sync/base/pref_names.h"
13 #include "components/sync/base/sync_prefs.h" 13 #include "components/sync/base/sync_prefs.h"
14 #include "components/sync/driver/sync_client.h" 14 #include "components/sync/driver/sync_client.h"
15 #include "components/sync/driver/sync_service.h" 15 #include "components/sync/driver/sync_service.h"
16 16
17 // ArcPackage sync service is controlled by apps checkbox in sync settings. Arc 17 // ArcPackage sync service is controlled by apps checkbox in sync settings. ARC
18 // apps and regular Chrome apps have same user control. 18 // apps and regular Chrome apps have same user control.
19 namespace { 19 namespace {
20 20
21 // Indicates whether ARC is enabled on this machine. 21 // Indicates whether ARC is enabled on this machine.
22 bool IsArcEnabled(Profile* profile) { 22 bool IsArcEnabled(Profile* profile) {
23 return arc::IsArcAllowedForProfile(profile) && 23 return arc::IsArcAllowedForProfile(profile) &&
24 profile->GetPrefs()->GetBoolean(prefs::kArcEnabled); 24 profile->GetPrefs()->GetBoolean(prefs::kArcEnabled);
25 } 25 }
26 26
27 } // namespace 27 } // namespace
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 void ArcPackageSyncDataTypeController::StopModels() { 64 void ArcPackageSyncDataTypeController::StopModels() {
65 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile_); 65 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile_);
66 if (arc_prefs) 66 if (arc_prefs)
67 arc_prefs->RemoveObserver(this); 67 arc_prefs->RemoveObserver(this);
68 } 68 }
69 69
70 void ArcPackageSyncDataTypeController::OnPackageListInitialRefreshed() { 70 void ArcPackageSyncDataTypeController::OnPackageListInitialRefreshed() {
71 // model_normal_start_ is true by default. Normally, 71 // model_normal_start_ is true by default. Normally,
72 // ArcPackageSyncDataTypeController::StartModels() gets called before Arc 72 // ArcPackageSyncDataTypeController::StartModels() gets called before ARC
73 // package list is refreshed. But in integration test, the order can be either 73 // package list is refreshed. But in integration test, the order can be either
74 // way. If OnPackageListInitialRefreshed comes before 74 // way. If OnPackageListInitialRefreshed comes before
75 // ArcPackageSyncDataTypeController ::StartModels(), this function is no-op 75 // ArcPackageSyncDataTypeController ::StartModels(), this function is no-op
76 // and waits for StartModels() to be called. 76 // and waits for StartModels() to be called.
77 if (model_normal_start_) 77 if (model_normal_start_)
78 return; 78 return;
79 79
80 model_normal_start_ = true; 80 model_normal_start_ = true;
81 OnModelLoaded(); 81 OnModelLoaded();
82 } 82 }
83 83
84 void ArcPackageSyncDataTypeController::OnArcEnabledPrefChanged() { 84 void ArcPackageSyncDataTypeController::OnArcEnabledPrefChanged() {
85 DCHECK(CalledOnValidThread()); 85 DCHECK(CalledOnValidThread());
86 86
87 if (!ReadyForStart()) { 87 if (!ReadyForStart()) {
88 // If enable Arc in settings is turned off then generate an unrecoverable 88 // If enable ARC in settings is turned off then generate an unrecoverable
89 // error. 89 // error.
90 if (state() != NOT_RUNNING && state() != STOPPING) { 90 if (state() != NOT_RUNNING && state() != STOPPING) {
91 syncer::SyncError error( 91 syncer::SyncError error(
92 FROM_HERE, syncer::SyncError::DATATYPE_POLICY_ERROR, 92 FROM_HERE, syncer::SyncError::DATATYPE_POLICY_ERROR,
93 "Arc package sync is now disabled because user disables Arc.", 93 "ARC package sync is now disabled because user disables ARC.",
94 type()); 94 type());
95 CreateErrorHandler()->OnUnrecoverableError(error); 95 CreateErrorHandler()->OnUnrecoverableError(error);
96 } 96 }
97 return; 97 return;
98 } 98 }
99 EnableDataType(); 99 EnableDataType();
100 } 100 }
101 101
102 void ArcPackageSyncDataTypeController::EnableDataType() { 102 void ArcPackageSyncDataTypeController::EnableDataType() {
103 syncer::SyncService* sync_service = sync_client_->GetSyncService(); 103 syncer::SyncService* sync_service = sync_client_->GetSyncService();
104 DCHECK(sync_service); 104 DCHECK(sync_service);
105 sync_service->ReenableDatatype(type()); 105 sync_service->ReenableDatatype(type());
106 } 106 }
107 107
108 bool ArcPackageSyncDataTypeController::ShouldSyncArc() const { 108 bool ArcPackageSyncDataTypeController::ShouldSyncArc() const {
109 syncer::SyncService* sync_service = sync_client_->GetSyncService(); 109 syncer::SyncService* sync_service = sync_client_->GetSyncService();
110 DCHECK(sync_service); 110 DCHECK(sync_service);
111 return sync_service->GetPreferredDataTypes().Has(type()); 111 return sync_service->GetPreferredDataTypes().Has(type());
112 } 112 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_default_app_list.cc ('k') | chrome/browser/ui/app_list/arc/arc_package_syncable_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698