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

Side by Side Diff: chrome/browser/extensions/extension_sync_service.cc

Issue 1200833004: Apps&Extensions for Supervised Users: send permission request on outdated re-enables (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests! Created 5 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/extensions/extension_sync_service.h" 5 #include "chrome/browser/extensions/extension_sync_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/extensions/bookmark_app_helper.h" 9 #include "chrome/browser/extensions/bookmark_app_helper.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 13 matching lines...) Expand all
24 #include "extensions/browser/extension_util.h" 24 #include "extensions/browser/extension_util.h"
25 #include "extensions/browser/uninstall_reason.h" 25 #include "extensions/browser/uninstall_reason.h"
26 #include "extensions/common/extension.h" 26 #include "extensions/common/extension.h"
27 #include "extensions/common/extension_set.h" 27 #include "extensions/common/extension_set.h"
28 #include "extensions/common/image_util.h" 28 #include "extensions/common/image_util.h"
29 #include "extensions/common/permissions/permission_message_provider.h" 29 #include "extensions/common/permissions/permission_message_provider.h"
30 #include "extensions/common/permissions/permissions_data.h" 30 #include "extensions/common/permissions/permissions_data.h"
31 #include "sync/api/sync_change.h" 31 #include "sync/api/sync_change.h"
32 #include "sync/api/sync_error_factory.h" 32 #include "sync/api/sync_error_factory.h"
33 33
34 #if defined(ENABLE_SUPERVISED_USERS)
35 #include "chrome/browser/supervised_user/supervised_user_service.h"
36 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
37 #endif
38
34 using extensions::AppSorting; 39 using extensions::AppSorting;
35 using extensions::Extension; 40 using extensions::Extension;
36 using extensions::ExtensionPrefs; 41 using extensions::ExtensionPrefs;
37 using extensions::ExtensionRegistry; 42 using extensions::ExtensionRegistry;
38 using extensions::ExtensionSet; 43 using extensions::ExtensionSet;
39 using extensions::ExtensionSyncData; 44 using extensions::ExtensionSyncData;
40 using extensions::ExtensionSystem; 45 using extensions::ExtensionSystem;
41 using extensions::SyncBundle; 46 using extensions::SyncBundle;
42 47
43 namespace { 48 namespace {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 bundle->PushSyncAddOrUpdate(extension.id(), 138 bundle->PushSyncAddOrUpdate(extension.id(),
134 CreateSyncData(extension).GetSyncData()); 139 CreateSyncData(extension).GetSyncData());
135 DCHECK(!ExtensionPrefs::Get(profile_)->NeedsSync(extension.id())); 140 DCHECK(!ExtensionPrefs::Get(profile_)->NeedsSync(extension.id()));
136 } else { 141 } else {
137 ExtensionPrefs::Get(profile_)->SetNeedsSync(extension.id(), true); 142 ExtensionPrefs::Get(profile_)->SetNeedsSync(extension.id(), true);
138 if (extension_service()->is_ready() && !flare_.is_null()) 143 if (extension_service()->is_ready() && !flare_.is_null())
139 flare_.Run(type); // Tell sync to start ASAP. 144 flare_.Run(type); // Tell sync to start ASAP.
140 } 145 }
141 } 146 }
142 147
148 bool ExtensionSyncService::HasPendingReenable(
149 const std::string& id,
150 const base::Version& version) const {
151 auto it = pending_updates_.find(id);
152 if (it == pending_updates_.end())
153 return false;
154 const PendingUpdate& pending = it->second;
155 return pending.version.Equals(version) &&
156 pending.grant_permissions_and_reenable;
157 }
158
143 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( 159 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing(
144 syncer::ModelType type, 160 syncer::ModelType type,
145 const syncer::SyncDataList& initial_sync_data, 161 const syncer::SyncDataList& initial_sync_data,
146 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 162 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
147 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { 163 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) {
148 CHECK(sync_processor.get()); 164 CHECK(sync_processor.get());
149 LOG_IF(FATAL, type != syncer::EXTENSIONS && type != syncer::APPS) 165 LOG_IF(FATAL, type != syncer::EXTENSIONS && type != syncer::APPS)
150 << "Got " << type << " ModelType"; 166 << "Got " << type << " ModelType";
151 167
152 SyncBundle* bundle = GetSyncBundle(type); 168 SyncBundle* bundle = GetSyncBundle(type);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 DCHECK(granted_permissions.get()); 348 DCHECK(granted_permissions.get());
333 bool is_privilege_increase = 349 bool is_privilege_increase =
334 extensions::PermissionMessageProvider::Get()->IsPrivilegeIncrease( 350 extensions::PermissionMessageProvider::Get()->IsPrivilegeIncrease(
335 *granted_permissions, 351 *granted_permissions,
336 extension->permissions_data()->active_permissions(), 352 extension->permissions_data()->active_permissions(),
337 extension->GetType()); 353 extension->GetType());
338 if (!is_privilege_increase) 354 if (!is_privilege_increase)
339 extension_service()->EnableExtension(id); 355 extension_service()->EnableExtension(id);
340 else if (extension_sync_data.supports_disable_reasons()) 356 else if (extension_sync_data.supports_disable_reasons())
341 reenable_after_update = true; 357 reenable_after_update = true;
358
359 #if defined(ENABLE_SUPERVISED_USERS)
360 if (is_privilege_increase && version_compare_result > 0 &&
Marc Treib 2015/10/16 12:40:36 This was that bug - I was generating a permission
361 extensions::util::IsExtensionSupervised(extension, profile_)) {
362 SupervisedUserServiceFactory::GetForProfile(profile_)
363 ->AddExtensionUpdateRequest(id, *extension->version());
364 }
365 #endif
342 } 366 }
343 } else { 367 } else {
344 // The extension is not installed yet. Set it to enabled; we'll check for 368 // The extension is not installed yet. Set it to enabled; we'll check for
345 // permission increase when it's actually installed. 369 // permission increase when it's actually installed.
346 extension_service()->EnableExtension(id); 370 extension_service()->EnableExtension(id);
347 } 371 }
348 } else { 372 } else {
349 int disable_reasons = extension_sync_data.disable_reasons(); 373 int disable_reasons = extension_sync_data.disable_reasons();
350 if (extension_sync_data.remote_install()) { 374 if (extension_sync_data.remote_install()) {
351 if (!(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { 375 if (!(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 if (IsCorrectSyncType(*extension, type) && 642 if (IsCorrectSyncType(*extension, type) &&
619 extensions::util::ShouldSync(extension.get(), profile_) && 643 extensions::util::ShouldSync(extension.get(), profile_) &&
620 (include_everything || 644 (include_everything ||
621 ExtensionPrefs::Get(profile_)->NeedsSync(extension->id()))) { 645 ExtensionPrefs::Get(profile_)->NeedsSync(extension->id()))) {
622 // We should never have pending data for an installed extension. 646 // We should never have pending data for an installed extension.
623 DCHECK(!GetSyncBundle(type)->HasPendingExtensionData(extension->id())); 647 DCHECK(!GetSyncBundle(type)->HasPendingExtensionData(extension->id()));
624 sync_data_list->push_back(CreateSyncData(*extension)); 648 sync_data_list->push_back(CreateSyncData(*extension));
625 } 649 }
626 } 650 }
627 } 651 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_sync_service.h ('k') | chrome/browser/supervised_user/supervised_user_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698