diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-09 16:35:18 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-09 16:35:18 +0000 |
commit | ec5b50d6d76fc975f0e7b5e037f28974e13cabb5 (patch) | |
tree | 9643090a68cd8ff404aae0c79330822a855d5270 /chrome/browser/profile_impl.cc | |
parent | e161c191f63808fb0503af5ab05ae5ac176ecfe9 (diff) | |
download | chromium_src-ec5b50d6d76fc975f0e7b5e037f28974e13cabb5.zip chromium_src-ec5b50d6d76fc975f0e7b5e037f28974e13cabb5.tar.gz chromium_src-ec5b50d6d76fc975f0e7b5e037f28974e13cabb5.tar.bz2 |
Implement new strategy for default apps. Instead of using
the component extension system, simply install them as
normal apps the first time Chrome runs. Remove the old
style default apps.
This also removes support for --disable-apps, which doesn't
seem necessary since we already have --disable-extensions.
BUG=53972
TEST=Uninstall any installed apps. Remove the
"default_apps_installed" and "app_promo_counter" keys from
Preferences if they are present.
Start Chrome with the --enable-default-apps flag, navigate
to chrome://extensions/, and click "update now" in the
developer tools. This is to make the updater grab the
apps from the store quicker, so that you don't have to wait
while testing. Normally Chrome would do this by itself
after 5-40 mins.
Go to NTP. You should see gmail, calendar, and docs default
apps show up along with the promo (the text that says "New!
A world of ...").
Refresh the NTP 10 times. The promo should go away on the
10th time.
There are other details. To test each of these, remove all
installed apps and remove the keys from the preferences to
reset the state.
* If you close Chrome before getting the default apps. They
should still show up the next time Chrome is started (after
clicking 'Update now')
* Clicking "hide this message" should hide the promo and it
shouldn't come back on refresh.
* Installing or uninstalling any app should hide the promo,
and it shouldn't come back.
* If the keys from the preferences are removed, but apps
are left installed, the default apps should not be
installed when clicking 'update now'.
* The default apps should only be installed in locale
en-US.
Review URL: http://codereview.chromium.org/3522015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profile_impl.cc')
-rw-r--r-- | chrome/browser/profile_impl.cc | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/chrome/browser/profile_impl.cc b/chrome/browser/profile_impl.cc index af95572..899e068daa 100644 --- a/chrome/browser/profile_impl.cc +++ b/chrome/browser/profile_impl.cc @@ -26,6 +26,7 @@ #include "chrome/browser/chrome_thread.h" #include "chrome/browser/dom_ui/ntp_resource_cache.h" #include "chrome/browser/download/download_manager.h" +#include "chrome/browser/extensions/default_apps.h" #include "chrome/browser/extensions/extension_devtools_manager.h" #include "chrome/browser/extensions/extension_error_reporter.h" #include "chrome/browser/extensions/extension_info_map.h" @@ -168,15 +169,6 @@ bool HasACacheSubdir(const FilePath &dir) { file_util::PathExists(GetMediaCachePath(dir)); } -// Returns true if the default apps should be loaded (so that the app panel is -// not empty). -bool IncludeDefaultApps() { -#if defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD) - return true; -#endif - return false; -} - // Simple task to log the size of the current profile. class ProfileSizeTask : public Task { public: @@ -240,6 +232,7 @@ Profile* Profile::CreateProfile(const FilePath& path) { // static void ProfileImpl::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kSavingBrowserHistoryDisabled, false); + DefaultApps::RegisterUserPrefs(prefs); } ProfileImpl::ProfileImpl(const FilePath& path) @@ -375,6 +368,18 @@ void ProfileImpl::InitExtensions() { GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName), true); + RegisterComponentExtensions(); + extensions_service_->Init(); + InstallDefaultApps(); + + // Load any extensions specified with --load-extension. + if (command_line->HasSwitch(switches::kLoadExtension)) { + FilePath path = command_line->GetSwitchValuePath(switches::kLoadExtension); + extensions_service_->LoadExtension(path); + } +} + +void ProfileImpl::RegisterComponentExtensions() { // Register the component extensions. typedef std::list<std::pair<std::string, int> > ComponentExtensionList; ComponentExtensionList component_extensions; @@ -392,22 +397,9 @@ void ProfileImpl::InitExtensions() { component_extensions.push_back( std::make_pair("web_store", IDR_WEBSTORE_MANIFEST)); - // Some sample apps to make our lives easier while we are developing extension - // apps. This way we don't have to constantly install these over and over. - if (Extension::AppsAreEnabled() && IncludeDefaultApps()) { - component_extensions.push_back( - std::make_pair("gmail_app", IDR_GMAIL_APP_MANIFEST)); - component_extensions.push_back( - std::make_pair("calendar_app", IDR_CALENDAR_APP_MANIFEST)); - component_extensions.push_back( - std::make_pair("docs_app", IDR_DOCS_APP_MANIFEST)); - } - #if defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD) - if (Extension::AppsAreEnabled()) { - component_extensions.push_back( - std::make_pair("chat_manager", IDR_TALK_APP_MANIFEST)); - } + component_extensions.push_back( + std::make_pair("chat_manager", IDR_TALK_APP_MANIFEST)); #endif for (ComponentExtensionList::iterator iter = component_extensions.begin(); @@ -425,13 +417,31 @@ void ProfileImpl::InitExtensions() { extensions_service_->register_component_extension( ExtensionsService::ComponentExtensionInfo(manifest, path)); } +} - extensions_service_->Init(); +void ProfileImpl::InstallDefaultApps() { +#if !defined(OS_CHROMEOS) + // On desktop Chrome, we don't have default apps on by, err, default yet. + if (!CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableDefaultApps)) { + return; + } +#endif - // Load any extensions specified with --load-extension. - if (command_line->HasSwitch(switches::kLoadExtension)) { - FilePath path = command_line->GetSwitchValuePath(switches::kLoadExtension); - extensions_service_->LoadExtension(path); + // The web store only supports en-US at the moment, so we don't install + // default apps in other locales. + if (g_browser_process->GetApplicationLocale() != "en-US") + return; + + ExtensionsService* extensions_service = GetExtensionsService(); + const ExtensionIdSet* app_ids = + extensions_service->default_apps()->GetAppsToInstall(); + if (!app_ids) + return; + + for (ExtensionIdSet::const_iterator iter = app_ids->begin(); + iter != app_ids->end(); ++iter) { + extensions_service->AddPendingExtensionFromDefaultAppList(*iter); } } |