Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 #include "chrome/common/chrome_notification_types.h" | 86 #include "chrome/common/chrome_notification_types.h" |
| 87 #include "chrome/common/chrome_paths.h" | 87 #include "chrome/common/chrome_paths.h" |
| 88 #include "chrome/common/chrome_switches.h" | 88 #include "chrome/common/chrome_switches.h" |
| 89 #include "chrome/common/chrome_version_info.h" | 89 #include "chrome/common/chrome_version_info.h" |
| 90 #include "chrome/common/extensions/extension.h" | 90 #include "chrome/common/extensions/extension.h" |
| 91 #include "chrome/common/extensions/extension_error_utils.h" | 91 #include "chrome/common/extensions/extension_error_utils.h" |
| 92 #include "chrome/common/extensions/extension_file_util.h" | 92 #include "chrome/common/extensions/extension_file_util.h" |
| 93 #include "chrome/common/extensions/extension_manifest_constants.h" | 93 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 94 #include "chrome/common/extensions/extension_messages.h" | 94 #include "chrome/common/extensions/extension_messages.h" |
| 95 #include "chrome/common/extensions/extension_resource.h" | 95 #include "chrome/common/extensions/extension_resource.h" |
| 96 #include "chrome/common/extensions/requirements_provider.h" | |
| 96 #include "chrome/common/pref_names.h" | 97 #include "chrome/common/pref_names.h" |
| 97 #include "chrome/common/url_constants.h" | 98 #include "chrome/common/url_constants.h" |
| 98 #include "content/public/browser/browser_thread.h" | 99 #include "content/public/browser/browser_thread.h" |
| 99 #include "content/public/browser/devtools_agent_host_registry.h" | 100 #include "content/public/browser/devtools_agent_host_registry.h" |
| 100 #include "content/public/browser/devtools_manager.h" | 101 #include "content/public/browser/devtools_manager.h" |
| 101 #include "content/public/browser/notification_service.h" | 102 #include "content/public/browser/notification_service.h" |
| 102 #include "content/public/browser/notification_types.h" | 103 #include "content/public/browser/notification_types.h" |
| 103 #include "content/public/browser/plugin_service.h" | 104 #include "content/public/browser/plugin_service.h" |
| 104 #include "content/public/browser/render_process_host.h" | 105 #include "content/public/browser/render_process_host.h" |
| 105 #include "content/public/common/pepper_plugin_info.h" | 106 #include "content/public/common/pepper_plugin_info.h" |
| 106 #include "googleurl/src/gurl.h" | 107 #include "googleurl/src/gurl.h" |
| 107 #include "grit/generated_resources.h" | 108 #include "grit/generated_resources.h" |
| 108 #include "net/base/registry_controlled_domain.h" | 109 #include "net/base/registry_controlled_domain.h" |
| 109 #include "sync/api/sync_change.h" | 110 #include "sync/api/sync_change.h" |
| 110 #include "sync/api/sync_error_factory.h" | 111 #include "sync/api/sync_error_factory.h" |
| 111 #include "ui/base/l10n/l10n_util.h" | 112 #include "ui/base/l10n/l10n_util.h" |
| 112 #include "webkit/database/database_tracker.h" | 113 #include "webkit/database/database_tracker.h" |
| 113 #include "webkit/database/database_util.h" | 114 #include "webkit/database/database_util.h" |
| 114 | 115 |
| 115 #if defined(OS_CHROMEOS) | 116 #if defined(OS_CHROMEOS) |
| 116 #include "chrome/browser/chromeos/cros/cros_library.h" | 117 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 117 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" | 118 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" |
| 118 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" | 119 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
| 119 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" | 120 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" |
| 120 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" | 121 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" |
| 121 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 122 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 122 #include "chrome/browser/extensions/extension_input_ime_api.h" | |
| 123 #include "webkit/fileapi/file_system_context.h" | 123 #include "webkit/fileapi/file_system_context.h" |
| 124 #include "webkit/fileapi/file_system_mount_point_provider.h" | 124 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 125 #endif | 125 #endif |
| 126 | 126 |
| 127 using base::Time; | 127 using base::Time; |
| 128 using content::BrowserContext; | 128 using content::BrowserContext; |
| 129 using content::BrowserThread; | 129 using content::BrowserThread; |
| 130 using content::DevToolsAgentHost; | 130 using content::DevToolsAgentHost; |
| 131 using content::DevToolsAgentHostRegistry; | 131 using content::DevToolsAgentHostRegistry; |
| 132 using content::PluginService; | 132 using content::PluginService; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 app_notification_manager_(new AppNotificationManager(profile)), | 339 app_notification_manager_(new AppNotificationManager(profile)), |
| 340 apps_promo_(profile->GetPrefs()), | 340 apps_promo_(profile->GetPrefs()), |
| 341 event_routers_initialized_(false), | 341 event_routers_initialized_(false), |
| 342 update_once_all_providers_are_ready_(false), | 342 update_once_all_providers_are_ready_(false), |
| 343 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 343 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 344 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 344 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 345 extension_warnings_(profile), | 345 extension_warnings_(profile), |
| 346 api_resource_controller_(NULL), | 346 api_resource_controller_(NULL), |
| 347 app_shortcut_manager_(profile) { | 347 app_shortcut_manager_(profile) { |
| 348 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 348 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 349 | 349 requirements_provider_.reset(extensions::RequirementsProvider::Create()); |
| 350 // Figure out if extension installation should be enabled. | 350 // Figure out if extension installation should be enabled. |
| 351 if (command_line->HasSwitch(switches::kDisableExtensions)) { | 351 if (command_line->HasSwitch(switches::kDisableExtensions)) { |
| 352 extensions_enabled_ = false; | 352 extensions_enabled_ = false; |
| 353 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { | 353 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { |
| 354 extensions_enabled_ = false; | 354 extensions_enabled_ = false; |
| 355 } | 355 } |
| 356 | 356 |
| 357 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 357 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
| 358 content::NotificationService::AllBrowserContextsAndSources()); | 358 content::NotificationService::AllBrowserContextsAndSources()); |
| 359 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 359 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 base::Bind( | 571 base::Bind( |
| 572 &extension_file_util::DeleteFile, extension_path, false))) | 572 &extension_file_util::DeleteFile, extension_path, false))) |
| 573 NOTREACHED(); | 573 NOTREACHED(); |
| 574 | 574 |
| 575 return false; | 575 return false; |
| 576 } | 576 } |
| 577 | 577 |
| 578 // We want a silent install only for non-pending extensions and | 578 // We want a silent install only for non-pending extensions and |
| 579 // pending extensions that have install_silently set. | 579 // pending extensions that have install_silently set. |
| 580 Browser* browser = browser::FindLastActiveWithProfile(profile_); | 580 Browser* browser = browser::FindLastActiveWithProfile(profile_); |
| 581 | |
| 581 ExtensionInstallPrompt* client = | 582 ExtensionInstallPrompt* client = |
| 582 (!pending_extension_info || pending_extension_info->install_silently()) ? | 583 (!pending_extension_info || pending_extension_info->install_silently()) ? |
| 583 NULL : chrome::CreateExtensionInstallPromptWithBrowser(browser); | 584 NULL : chrome::CreateExtensionInstallPromptWithBrowser(browser); |
| 584 | 585 |
| 585 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(this, client)); | 586 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(this, client)); |
| 586 installer->set_expected_id(id); | 587 installer->set_expected_id(id); |
| 587 if (pending_extension_info) { | 588 if (pending_extension_info) { |
| 588 installer->set_install_source(pending_extension_info->install_source()); | 589 installer->set_install_source(pending_extension_info->install_source()); |
| 589 if (pending_extension_info->install_silently()) | 590 if (pending_extension_info->install_silently()) |
| 590 installer->set_allow_silent_install(true); | 591 installer->set_allow_silent_install(true); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 606 } | 607 } |
| 607 | 608 |
| 608 // Bookmark apps being updated is kind of a contradiction, but that's because | 609 // Bookmark apps being updated is kind of a contradiction, but that's because |
| 609 // we mark the default apps as bookmark apps, and they're hosted in the web | 610 // we mark the default apps as bookmark apps, and they're hosted in the web |
| 610 // store, thus they can get updated. See http://crbug.com/101605 for more | 611 // store, thus they can get updated. See http://crbug.com/101605 for more |
| 611 // details. | 612 // details. |
| 612 if (extension && extension->from_bookmark()) | 613 if (extension && extension->from_bookmark()) |
| 613 creation_flags |= Extension::FROM_BOOKMARK; | 614 creation_flags |= Extension::FROM_BOOKMARK; |
| 614 | 615 |
| 615 installer->set_creation_flags(creation_flags); | 616 installer->set_creation_flags(creation_flags); |
| 616 | |
| 617 installer->set_delete_source(true); | 617 installer->set_delete_source(true); |
| 618 installer->set_download_url(download_url); | 618 installer->set_download_url(download_url); |
| 619 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); | 619 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); |
| 620 installer->InstallCrx(extension_path); | 620 installer->InstallCrx(extension_path); |
| 621 | 621 |
| 622 if (out_crx_installer) | 622 if (out_crx_installer) |
| 623 *out_crx_installer = installer; | 623 *out_crx_installer = installer; |
| 624 | 624 |
| 625 return true; | 625 return true; |
| 626 } | 626 } |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1924 | 1924 |
| 1925 // If the extension was disabled for a reload, then enable it. | 1925 // If the extension was disabled for a reload, then enable it. |
| 1926 if (disabled_extension_paths_.erase(extension->id()) > 0) | 1926 if (disabled_extension_paths_.erase(extension->id()) > 0) |
| 1927 EnableExtension(extension->id()); | 1927 EnableExtension(extension->id()); |
| 1928 | 1928 |
| 1929 // Check if the extension's privileges have changed and disable the | 1929 // Check if the extension's privileges have changed and disable the |
| 1930 // extension if necessary. | 1930 // extension if necessary. |
| 1931 InitializePermissions(extension); | 1931 InitializePermissions(extension); |
| 1932 | 1932 |
| 1933 bool disabled = extension_prefs_->IsExtensionDisabled(extension->id()); | 1933 bool disabled = extension_prefs_->IsExtensionDisabled(extension->id()); |
| 1934 | |
| 1935 string16 error; | |
| 1936 if (!requirements_provider_->Supports(*extension->manifest(), &error)) { | |
|
Aaron Boodman
2012/07/16 21:16:12
Didn't it look like some of the requirements neede
| |
| 1937 disabled = true; | |
| 1938 Extension::InstallWarningVector warnings; | |
| 1939 warnings.push_back(Extension::InstallWarning( | |
| 1940 Extension::InstallWarning::FORMAT_TEXT, UTF16ToUTF8(error))); | |
| 1941 // TODO(eriq): Avoid this messy cast. | |
| 1942 const_cast<Extension*>(extension)->AddInstallWarnings(warnings); | |
| 1943 } | |
| 1944 | |
| 1934 if (disabled) { | 1945 if (disabled) { |
| 1935 disabled_extensions_.Insert(scoped_extension); | 1946 disabled_extensions_.Insert(scoped_extension); |
| 1936 SyncExtensionChangeIfNeeded(*extension); | 1947 SyncExtensionChangeIfNeeded(*extension); |
| 1937 content::NotificationService::current()->Notify( | 1948 content::NotificationService::current()->Notify( |
| 1938 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 1949 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 1939 content::Source<Profile>(profile_), | 1950 content::Source<Profile>(profile_), |
| 1940 content::Details<const Extension>(extension)); | 1951 content::Details<const Extension>(extension)); |
| 1941 | 1952 |
| 1942 if (extension_prefs_->GetDisableReason(extension->id()) == | 1953 if (extension_prefs_->GetDisableReason(extension->id()) == |
| 1943 Extension::DISABLE_PERMISSIONS_INCREASE) { | 1954 Extension::DISABLE_PERMISSIONS_INCREASE) { |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2560 | 2571 |
| 2561 // To coexist with certain unit tests that don't have a work-thread message | 2572 // To coexist with certain unit tests that don't have a work-thread message |
| 2562 // loop available at ExtensionService shutdown, we lazy-initialize this | 2573 // loop available at ExtensionService shutdown, we lazy-initialize this |
| 2563 // object so that those cases neither create nor destroy an | 2574 // object so that those cases neither create nor destroy an |
| 2564 // APIResourceController. | 2575 // APIResourceController. |
| 2565 if (!api_resource_controller_.get()) { | 2576 if (!api_resource_controller_.get()) { |
| 2566 api_resource_controller_.reset(new extensions::APIResourceController()); | 2577 api_resource_controller_.reset(new extensions::APIResourceController()); |
| 2567 } | 2578 } |
| 2568 return api_resource_controller_.get(); | 2579 return api_resource_controller_.get(); |
| 2569 } | 2580 } |
| OLD | NEW |