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

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

Issue 3063002: Merge 53127 - Added checks to handle unsyncable extensions.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 5 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 | « no previous file | chrome/browser/extensions/extensions_service_unittest.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/extensions_service.h" 5 #include "chrome/browser/extensions/extensions_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
(...skipping 17 matching lines...) Expand all
28 #include "chrome/browser/extensions/extension_history_api.h" 28 #include "chrome/browser/extensions/extension_history_api.h"
29 #include "chrome/browser/extensions/extension_host.h" 29 #include "chrome/browser/extensions/extension_host.h"
30 #include "chrome/browser/extensions/extension_process_manager.h" 30 #include "chrome/browser/extensions/extension_process_manager.h"
31 #include "chrome/browser/extensions/extension_updater.h" 31 #include "chrome/browser/extensions/extension_updater.h"
32 #include "chrome/browser/extensions/external_extension_provider.h" 32 #include "chrome/browser/extensions/external_extension_provider.h"
33 #include "chrome/browser/extensions/external_pref_extension_provider.h" 33 #include "chrome/browser/extensions/external_pref_extension_provider.h"
34 #include "chrome/browser/net/chrome_url_request_context.h" 34 #include "chrome/browser/net/chrome_url_request_context.h"
35 #include "chrome/browser/pref_service.h" 35 #include "chrome/browser/pref_service.h"
36 #include "chrome/browser/profile.h" 36 #include "chrome/browser/profile.h"
37 #include "chrome/browser/search_engines/template_url_model.h" 37 #include "chrome/browser/search_engines/template_url_model.h"
38 #include "chrome/browser/sync/glue/extension_util.h"
38 #include "chrome/common/child_process_logging.h" 39 #include "chrome/common/child_process_logging.h"
39 #include "chrome/common/chrome_switches.h" 40 #include "chrome/common/chrome_switches.h"
40 #include "chrome/common/extensions/extension.h" 41 #include "chrome/common/extensions/extension.h"
41 #include "chrome/common/extensions/extension_constants.h" 42 #include "chrome/common/extensions/extension_constants.h"
42 #include "chrome/common/extensions/extension_error_utils.h" 43 #include "chrome/common/extensions/extension_error_utils.h"
43 #include "chrome/common/extensions/extension_file_util.h" 44 #include "chrome/common/extensions/extension_file_util.h"
44 #include "chrome/common/extensions/extension_l10n_util.h" 45 #include "chrome/common/extensions/extension_l10n_util.h"
45 #include "chrome/common/notification_service.h" 46 #include "chrome/common/notification_service.h"
46 #include "chrome/common/notification_type.h" 47 #include "chrome/common/notification_type.h"
47 #include "chrome/common/json_value_serializer.h" 48 #include "chrome/common/json_value_serializer.h"
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 929
929 void ExtensionsService::OnExtensionInstalled(Extension* extension, 930 void ExtensionsService::OnExtensionInstalled(Extension* extension,
930 bool allow_privilege_increase) { 931 bool allow_privilege_increase) {
931 // Ensure extension is deleted unless we transfer ownership. 932 // Ensure extension is deleted unless we transfer ownership.
932 scoped_ptr<Extension> scoped_extension(extension); 933 scoped_ptr<Extension> scoped_extension(extension);
933 Extension::State initial_state = Extension::DISABLED; 934 Extension::State initial_state = Extension::DISABLED;
934 bool initial_enable_incognito = false; 935 bool initial_enable_incognito = false;
935 PendingExtensionMap::iterator it = 936 PendingExtensionMap::iterator it =
936 pending_extensions_.find(extension->id()); 937 pending_extensions_.find(extension->id());
937 if (it != pending_extensions_.end()) { 938 if (it != pending_extensions_.end()) {
939 PendingExtensionInfo pending_extension_info = it->second;
940 pending_extensions_.erase(it);
941 it = pending_extensions_.end();
938 // Set initial state from pending extension data. 942 // Set initial state from pending extension data.
939 if (it->second.is_theme != extension->is_theme()) { 943 if (pending_extension_info.is_theme != extension->is_theme()) {
940 LOG(WARNING) 944 LOG(WARNING)
941 << "Not installing pending extension " << extension->id() 945 << "Not installing pending extension " << extension->id()
942 << " with is_theme = " << extension->is_theme() 946 << " with is_theme = " << extension->is_theme()
943 << "; expected is_theme = " << it->second.is_theme; 947 << "; expected is_theme = " << pending_extension_info.is_theme;
944 // Delete the extension directory since we're not going to 948 // Delete the extension directory since we're not going to
945 // load it. 949 // load it.
946 ChromeThread::PostTask( 950 ChromeThread::PostTask(
947 ChromeThread::FILE, FROM_HERE, 951 ChromeThread::FILE, FROM_HERE,
948 NewRunnableFunction(&DeleteFileHelper, extension->path(), true)); 952 NewRunnableFunction(&DeleteFileHelper, extension->path(), true));
949 return; 953 return;
950 } 954 }
951 if (it->second.is_theme) { 955 if (!extension->is_theme() &&
952 DCHECK(it->second.enable_on_install); 956 !browser_sync::IsExtensionSyncable(*extension)) {
957 // We're an extension installed via sync that is unsyncable,
958 // i.e. we may have been syncable previously. We block these
959 // installs. We'll have to update the clause above if we decide
960 // to sync other extension-like things, like apps or user
961 // scripts.
962 //
963 // Note that this creates a small window where a user who tries
964 // to download/install an extension that is simultaneously
965 // installed via sync (and blocked) will find his download
966 // blocked.
967 //
968 // TODO(akalin): Remove this check once we've put in UI to
969 // approve synced extensions.
970 LOG(WARNING)
971 << "Not installing non-syncable extension " << extension->id();
972 // Delete the extension directory since we're not going to
973 // load it.
974 ChromeThread::PostTask(
975 ChromeThread::FILE, FROM_HERE,
976 NewRunnableFunction(&DeleteFileHelper, extension->path(), true));
977 return;
978 }
979 if (pending_extension_info.is_theme) {
980 DCHECK(pending_extension_info.enable_on_install);
953 initial_state = Extension::ENABLED; 981 initial_state = Extension::ENABLED;
954 DCHECK(!it->second.enable_incognito_on_install); 982 DCHECK(!pending_extension_info.enable_incognito_on_install);
955 initial_enable_incognito = false; 983 initial_enable_incognito = false;
956 } else { 984 } else {
957 initial_state = 985 initial_state =
958 it->second.enable_on_install ? 986 pending_extension_info.enable_on_install ?
959 Extension::ENABLED : Extension::DISABLED; 987 Extension::ENABLED : Extension::DISABLED;
960 initial_enable_incognito = 988 initial_enable_incognito =
961 it->second.enable_incognito_on_install; 989 pending_extension_info.enable_incognito_on_install;
962 } 990 }
963
964 pending_extensions_.erase(it);
965 } else { 991 } else {
966 // Make sure we don't enable a disabled extension. 992 // Make sure we don't enable a disabled extension.
967 Extension::State existing_state = 993 Extension::State existing_state =
968 extension_prefs_->GetExtensionState(extension->id()); 994 extension_prefs_->GetExtensionState(extension->id());
969 initial_state = 995 initial_state =
970 (existing_state == Extension::DISABLED) ? 996 (existing_state == Extension::DISABLED) ?
971 Extension::DISABLED : Extension::ENABLED; 997 Extension::DISABLED : Extension::ENABLED;
972 initial_enable_incognito = false; 998 initial_enable_incognito = false;
973 } 999 }
974 1000
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 // Finish installing on UI thread. 1363 // Finish installing on UI thread.
1338 ChromeThread::PostTask( 1364 ChromeThread::PostTask(
1339 ChromeThread::UI, FROM_HERE, 1365 ChromeThread::UI, FROM_HERE,
1340 NewRunnableMethod( 1366 NewRunnableMethod(
1341 frontend_, 1367 frontend_,
1342 &ExtensionsService::ContinueLoadAllExtensions, 1368 &ExtensionsService::ContinueLoadAllExtensions,
1343 extensions_to_reload, 1369 extensions_to_reload,
1344 start_time, 1370 start_time,
1345 true)); 1371 true));
1346 } 1372 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extensions_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698