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

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 8862007: Installing a platform application will add all application shortucts. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Don't do it for mac Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 5da59ed9267b9ec3aa90b0db457ea0ae3e26d50e..2010d7cd598a0caffec117d501b0dbfe74868e1b 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -72,8 +72,10 @@
#include "chrome/browser/ui/global_error_service.h"
#include "chrome/browser/ui/global_error_service_factory.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
+#include "chrome/browser/ui/webui/extension_icon_source.h"
#include "chrome/browser/ui/webui/favicon_source.h"
#include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
+#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
@@ -97,6 +99,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/common/pepper_plugin_info.h"
#include "googleurl/src/gurl.h"
+#include "grit/theme_resources.h"
#include "net/base/registry_controlled_domain.h"
#include "webkit/database/database_tracker.h"
#include "webkit/database/database_util.h"
@@ -386,7 +389,8 @@ ExtensionService::ExtensionService(Profile* profile,
permissions_manager_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
apps_promo_(profile->GetPrefs()),
event_routers_initialized_(false),
- extension_warnings_(profile) {
+ extension_warnings_(profile),
+ tracker_(this) {
miket_OOO 2011/12/09 18:42:02 Please see http://codesearch.google.com/#OAMlx_jo-
benwells 2011/12/12 03:03:00 Done.
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Figure out if extension installation should be enabled.
@@ -2095,6 +2099,13 @@ void ExtensionService::OnExtensionInstalled(
content::Source<Profile>(profile_),
content::Details<const Extension>(extension));
+ // Temporary feature to always install shortcuts for platform apps to
+ // facilitate early testing.
+ // TODO(benwells): Remove before launching platform apps.
+ if (extension->is_platform_app()) {
+ StartInstallApplicationShortcut(extension);
+ }
+
// Transfer ownership of |extension| to AddExtension.
AddExtension(scoped_extension);
}
@@ -2507,3 +2518,53 @@ ExtensionService::NaClModuleInfoList::iterator
}
return nacl_module_list_.end();
}
+
+void ExtensionService::StartInstallApplicationShortcut(
+ const Extension* extension) {
+#if !defined(OS_MACOSX)
+ const int kAppIconSize = 32;
+
+ shortcut_info_.extension_id = extension->id();
+ shortcut_info_.url = GURL(extension->launch_web_url());
+ shortcut_info_.title = UTF8ToUTF16(extension->name());
+ shortcut_info_.description = UTF8ToUTF16(extension->description());
+ shortcut_info_.create_in_applications_menu = true;
+ shortcut_info_.create_in_quick_launch_bar = true;
+ shortcut_info_.create_on_desktop = true;
+
+ // The icon will be resized to |max_size|.
+ const gfx::Size max_size(kAppIconSize, kAppIconSize);
+
+ // Look for an icon. If there is no icon at the ideal size,
miket_OOO 2011/12/09 18:42:02 Prevailing style calls for single space after peri
benwells 2011/12/12 03:03:00 Point taken! As a committed single spacer, I will
+ // we will resize whatever we can get. Making a large icon smaller
+ // is prefered to making a small icon larger, so look for a larger
+ // icon first:
+ ExtensionResource icon_resource = extension->GetIconResource(
+ kAppIconSize,
+ ExtensionIconSet::MATCH_BIGGER);
+
+ // If no icon exists that is the desired size or larger, get the
+ // largest icon available:
+ if (icon_resource.empty()) {
+ icon_resource = extension->GetIconResource(
+ kAppIconSize,
+ ExtensionIconSet::MATCH_SMALLER);
+ }
miket_OOO 2011/12/09 18:42:02 Is another .empty() case possible at this point? (
benwells 2011/12/12 03:03:00 Yes, but the LoadImage call and OnImageLoaded call
+
+ tracker_.LoadImage(extension,
+ icon_resource,
+ max_size,
+ ImageLoadingTracker::DONT_CACHE);
+#endif
+}
+
+void ExtensionService::OnImageLoaded(SkBitmap *image,
+ const ExtensionResource &resource,
+ int index)
+{
+ if (!image || image->isNull())
+ image = ExtensionIconSource::LoadImageByResourceId(IDR_APP_DEFAULT_ICON);
+
+ shortcut_info_.favicon = *image;
+ web_app::CreateShortcut(profile_->GetPath(), shortcut_info_, NULL);
+}
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698