OLD | NEW |
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 19 matching lines...) Expand all Loading... |
30 #include "chrome/browser/extensions/extension_history_api.h" | 30 #include "chrome/browser/extensions/extension_history_api.h" |
31 #include "chrome/browser/extensions/extension_host.h" | 31 #include "chrome/browser/extensions/extension_host.h" |
32 #include "chrome/browser/extensions/extension_process_manager.h" | 32 #include "chrome/browser/extensions/extension_process_manager.h" |
33 #include "chrome/browser/extensions/extension_updater.h" | 33 #include "chrome/browser/extensions/extension_updater.h" |
34 #include "chrome/browser/extensions/external_extension_provider.h" | 34 #include "chrome/browser/extensions/external_extension_provider.h" |
35 #include "chrome/browser/extensions/external_pref_extension_provider.h" | 35 #include "chrome/browser/extensions/external_pref_extension_provider.h" |
36 #include "chrome/browser/net/chrome_url_request_context.h" | 36 #include "chrome/browser/net/chrome_url_request_context.h" |
37 #include "chrome/browser/pref_service.h" | 37 #include "chrome/browser/pref_service.h" |
38 #include "chrome/browser/profile.h" | 38 #include "chrome/browser/profile.h" |
39 #include "chrome/browser/search_engines/template_url_model.h" | 39 #include "chrome/browser/search_engines/template_url_model.h" |
| 40 #include "chrome/browser/sync/glue/extension_sync_traits.h" |
40 #include "chrome/browser/sync/glue/extension_util.h" | 41 #include "chrome/browser/sync/glue/extension_util.h" |
41 #include "chrome/common/child_process_logging.h" | 42 #include "chrome/common/child_process_logging.h" |
42 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
43 #include "chrome/common/extensions/extension.h" | 44 #include "chrome/common/extensions/extension.h" |
44 #include "chrome/common/extensions/extension_constants.h" | 45 #include "chrome/common/extensions/extension_constants.h" |
45 #include "chrome/common/extensions/extension_error_utils.h" | 46 #include "chrome/common/extensions/extension_error_utils.h" |
46 #include "chrome/common/extensions/extension_file_util.h" | 47 #include "chrome/common/extensions/extension_file_util.h" |
47 #include "chrome/common/extensions/extension_l10n_util.h" | 48 #include "chrome/common/extensions/extension_l10n_util.h" |
48 #include "chrome/common/notification_service.h" | 49 #include "chrome/common/notification_service.h" |
49 #include "chrome/common/notification_type.h" | 50 #include "chrome/common/notification_type.h" |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 << "Not installing pending extension " << extension->id() | 956 << "Not installing pending extension " << extension->id() |
956 << " with is_theme = " << extension->is_theme() | 957 << " with is_theme = " << extension->is_theme() |
957 << "; expected is_theme = " << pending_extension_info.is_theme; | 958 << "; expected is_theme = " << pending_extension_info.is_theme; |
958 // Delete the extension directory since we're not going to | 959 // Delete the extension directory since we're not going to |
959 // load it. | 960 // load it. |
960 ChromeThread::PostTask( | 961 ChromeThread::PostTask( |
961 ChromeThread::FILE, FROM_HERE, | 962 ChromeThread::FILE, FROM_HERE, |
962 NewRunnableFunction(&DeleteFileHelper, extension->path(), true)); | 963 NewRunnableFunction(&DeleteFileHelper, extension->path(), true)); |
963 return; | 964 return; |
964 } | 965 } |
| 966 // TODO(akalin): When we do apps sync, we have to work with its |
| 967 // traits, too. |
| 968 const browser_sync::ExtensionSyncTraits extension_sync_traits = |
| 969 browser_sync::GetExtensionSyncTraits(); |
| 970 // If an extension is a theme, we bypass the valid/syncable check |
| 971 // as themes are harmless. |
965 if (!extension->is_theme() && | 972 if (!extension->is_theme() && |
966 !browser_sync::IsExtensionSyncable(*extension)) { | 973 !browser_sync::IsExtensionValidAndSyncable( |
| 974 *extension, extension_sync_traits.allowed_extension_types)) { |
967 // We're an extension installed via sync that is unsyncable, | 975 // We're an extension installed via sync that is unsyncable, |
968 // i.e. we may have been syncable previously. We block these | 976 // i.e. we may have been syncable previously. We block these |
969 // installs. We'll have to update the clause above if we decide | 977 // installs. We'll have to update the clause above if we decide |
970 // to sync other extension-like things, like apps or user | 978 // to sync other extension-like things, like apps or user |
971 // scripts. | 979 // scripts. |
972 // | 980 // |
973 // Note that this creates a small window where a user who tries | 981 // Note that this creates a small window where a user who tries |
974 // to download/install an extension that is simultaneously | 982 // to download/install an extension that is simultaneously |
975 // installed via sync (and blocked) will find his download | 983 // installed via sync (and blocked) will find his download |
976 // blocked. | 984 // blocked. |
977 // | 985 // |
978 // TODO(akalin): Remove this check once we've put in UI to | 986 // TODO(akalin): Remove this check once we've put in UI to |
979 // approve synced extensions. | 987 // approve synced extensions. |
980 LOG(WARNING) | 988 LOG(WARNING) |
981 << "Not installing non-syncable extension " << extension->id(); | 989 << "Not installing invalid or unsyncable extension " |
| 990 << extension->id(); |
982 // Delete the extension directory since we're not going to | 991 // Delete the extension directory since we're not going to |
983 // load it. | 992 // load it. |
984 ChromeThread::PostTask( | 993 ChromeThread::PostTask( |
985 ChromeThread::FILE, FROM_HERE, | 994 ChromeThread::FILE, FROM_HERE, |
986 NewRunnableFunction(&DeleteFileHelper, extension->path(), true)); | 995 NewRunnableFunction(&DeleteFileHelper, extension->path(), true)); |
987 return; | 996 return; |
988 } | 997 } |
989 if (pending_extension_info.is_theme) { | 998 if (pending_extension_info.is_theme) { |
990 DCHECK(pending_extension_info.enable_on_install); | 999 DCHECK(pending_extension_info.enable_on_install); |
991 initial_state = Extension::ENABLED; | 1000 initial_state = Extension::ENABLED; |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 // Finish installing on UI thread. | 1398 // Finish installing on UI thread. |
1390 ChromeThread::PostTask( | 1399 ChromeThread::PostTask( |
1391 ChromeThread::UI, FROM_HERE, | 1400 ChromeThread::UI, FROM_HERE, |
1392 NewRunnableMethod( | 1401 NewRunnableMethod( |
1393 frontend_, | 1402 frontend_, |
1394 &ExtensionsService::ContinueLoadAllExtensions, | 1403 &ExtensionsService::ContinueLoadAllExtensions, |
1395 extensions_to_reload, | 1404 extensions_to_reload, |
1396 start_time, | 1405 start_time, |
1397 true)); | 1406 true)); |
1398 } | 1407 } |
OLD | NEW |