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

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

Issue 6852029: [Sync] Move some extension-sync-related logic to ExtensionService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac compile error Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 20 matching lines...) Expand all
31 #include "chrome/browser/extensions/extension_cookies_api.h" 31 #include "chrome/browser/extensions/extension_cookies_api.h"
32 #include "chrome/browser/extensions/extension_data_deleter.h" 32 #include "chrome/browser/extensions/extension_data_deleter.h"
33 #include "chrome/browser/extensions/extension_error_reporter.h" 33 #include "chrome/browser/extensions/extension_error_reporter.h"
34 #include "chrome/browser/extensions/extension_history_api.h" 34 #include "chrome/browser/extensions/extension_history_api.h"
35 #include "chrome/browser/extensions/extension_host.h" 35 #include "chrome/browser/extensions/extension_host.h"
36 #include "chrome/browser/extensions/extension_management_api.h" 36 #include "chrome/browser/extensions/extension_management_api.h"
37 #include "chrome/browser/extensions/extension_preference_api.h" 37 #include "chrome/browser/extensions/extension_preference_api.h"
38 #include "chrome/browser/extensions/extension_process_manager.h" 38 #include "chrome/browser/extensions/extension_process_manager.h"
39 #include "chrome/browser/extensions/extension_processes_api.h" 39 #include "chrome/browser/extensions/extension_processes_api.h"
40 #include "chrome/browser/extensions/extension_special_storage_policy.h" 40 #include "chrome/browser/extensions/extension_special_storage_policy.h"
41 #include "chrome/browser/extensions/extension_sync_data.h"
41 #include "chrome/browser/extensions/extension_updater.h" 42 #include "chrome/browser/extensions/extension_updater.h"
42 #include "chrome/browser/extensions/extension_web_ui.h" 43 #include "chrome/browser/extensions/extension_web_ui.h"
43 #include "chrome/browser/extensions/extension_webnavigation_api.h" 44 #include "chrome/browser/extensions/extension_webnavigation_api.h"
44 #include "chrome/browser/extensions/external_extension_provider_impl.h" 45 #include "chrome/browser/extensions/external_extension_provider_impl.h"
45 #include "chrome/browser/extensions/external_extension_provider_interface.h" 46 #include "chrome/browser/extensions/external_extension_provider_interface.h"
46 #include "chrome/browser/extensions/pending_extension_manager.h" 47 #include "chrome/browser/extensions/pending_extension_manager.h"
47 #include "chrome/browser/net/chrome_url_request_context.h" 48 #include "chrome/browser/net/chrome_url_request_context.h"
48 #include "chrome/browser/prefs/pref_service.h" 49 #include "chrome/browser/prefs/pref_service.h"
49 #include "chrome/browser/profiles/profile.h" 50 #include "chrome/browser/profiles/profile.h"
50 #include "chrome/browser/search_engines/template_url_model.h" 51 #include "chrome/browser/search_engines/template_url_model.h"
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 } 1182 }
1182 1183
1183 void ExtensionService::CheckForUpdatesSoon() { 1184 void ExtensionService::CheckForUpdatesSoon() {
1184 if (updater()) { 1185 if (updater()) {
1185 updater()->CheckSoon(); 1186 updater()->CheckSoon();
1186 } else { 1187 } else {
1187 LOG(WARNING) << "CheckForUpdatesSoon() called with auto-update turned off"; 1188 LOG(WARNING) << "CheckForUpdatesSoon() called with auto-update turned off";
1188 } 1189 }
1189 } 1190 }
1190 1191
1192 void ExtensionService::ProcessSyncData(
1193 const ExtensionSyncData& extension_sync_data,
1194 PendingExtensionInfo::ShouldAllowInstallPredicate
1195 should_allow_install) {
asargent_no_longer_on_chrome 2011/04/15 18:42:30 Nit: consider just calling this "allow" or somethi
akalin 2011/04/15 21:19:39 Done.
1196 const std::string& id = extension_sync_data.id;
1197
1198 // Handle uninstalls first.
1199 if (extension_sync_data.uninstalled) {
1200 std::string error;
1201 if (!UninstallExtensionHelper(this, id)) {
1202 LOG(WARNING) << "Could not uninstall extension " << id
1203 << " for sync";
1204 }
1205 return;
1206 }
1207
1208 const Extension* extension = GetExtensionByIdInternal(id, true, true);
1209 // TODO(akalin): Figure out what to do with terminated extensions.
1210
1211 // Handle already-installed extensions (just update settings).
1212 //
1213 // TODO(akalin): Ideally, we should be able to set prefs for an
1214 // extension regardless of whether or not it's installed (and have
1215 // it automatially apply on install).
1216 if (extension) {
1217 if (extension_sync_data.enabled) {
1218 EnableExtension(id);
1219 } else {
1220 DisableExtension(id);
1221 }
1222 SetIsIncognitoEnabled(id, extension_sync_data.incognito_enabled);
1223 int result = extension->version()->CompareTo(extension_sync_data.version);
1224 if (result < 0) {
1225 // Extension is outdated.
1226 CheckForUpdatesSoon();
1227 } else if (result > 0) {
1228 // Sync version is outdated. Do nothing for now, as sync code
1229 // in other places will eventually update the sync data.
1230 //
1231 // TODO(akalin): Move that code here.
1232 }
1233 return;
1234 }
1235
1236 // Handle not-yet-installed extensions.
1237 //
1238 // TODO(akalin): Replace silent update with a list of enabled
1239 // permissions.
1240 pending_extension_manager()->AddFromSync(
1241 id,
1242 extension_sync_data.update_url,
1243 should_allow_install,
1244 true, // install_silently
1245 extension_sync_data.enabled,
1246 extension_sync_data.incognito_enabled);
1247 CheckForUpdatesSoon();
1248 }
1249
1191 bool ExtensionService::IsIncognitoEnabled( 1250 bool ExtensionService::IsIncognitoEnabled(
1192 const std::string& extension_id) const { 1251 const std::string& extension_id) const {
1193 // If this is an existing component extension we always allow it to 1252 // If this is an existing component extension we always allow it to
1194 // work in incognito mode. 1253 // work in incognito mode.
1195 const Extension* extension = GetExtensionById(extension_id, true); 1254 const Extension* extension = GetExtensionById(extension_id, true);
1196 if (extension && extension->location() == Extension::COMPONENT) 1255 if (extension && extension->location() == Extension::COMPONENT)
1197 return true; 1256 return true;
1198 1257
1199 // Check the prefs. 1258 // Check the prefs.
1200 return extension_prefs_->IsIncognitoEnabled(extension_id); 1259 return extension_prefs_->IsIncognitoEnabled(extension_id);
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 } 1984 }
1926 1985
1927 void ExtensionService::SetBeingUpgraded(const Extension* extension, 1986 void ExtensionService::SetBeingUpgraded(const Extension* extension,
1928 bool value) { 1987 bool value) {
1929 extension_runtime_data_[extension->id()].being_upgraded = value; 1988 extension_runtime_data_[extension->id()].being_upgraded = value;
1930 } 1989 }
1931 1990
1932 PropertyBag* ExtensionService::GetPropertyBag(const Extension* extension) { 1991 PropertyBag* ExtensionService::GetPropertyBag(const Extension* extension) {
1933 return &extension_runtime_data_[extension->id()].property_bag; 1992 return &extension_runtime_data_[extension->id()].property_bag;
1934 } 1993 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698