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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "chrome/browser/search_engines/template_url_service.h" 65 #include "chrome/browser/search_engines/template_url_service.h"
66 #include "chrome/browser/search_engines/template_url_service_factory.h" 66 #include "chrome/browser/search_engines/template_url_service_factory.h"
67 #include "chrome/browser/sync/api/sync_change.h" 67 #include "chrome/browser/sync/api/sync_change.h"
68 #include "chrome/browser/themes/theme_service.h" 68 #include "chrome/browser/themes/theme_service.h"
69 #include "chrome/browser/themes/theme_service_factory.h" 69 #include "chrome/browser/themes/theme_service_factory.h"
70 #include "chrome/browser/ui/browser.h" 70 #include "chrome/browser/ui/browser.h"
71 #include "chrome/browser/ui/browser_list.h" 71 #include "chrome/browser/ui/browser_list.h"
72 #include "chrome/browser/ui/global_error_service.h" 72 #include "chrome/browser/ui/global_error_service.h"
73 #include "chrome/browser/ui/global_error_service_factory.h" 73 #include "chrome/browser/ui/global_error_service_factory.h"
74 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 74 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
75 #include "chrome/browser/ui/webui/extension_icon_source.h"
75 #include "chrome/browser/ui/webui/favicon_source.h" 76 #include "chrome/browser/ui/webui/favicon_source.h"
76 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" 77 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
78 #include "chrome/browser/web_applications/web_app.h"
77 #include "chrome/common/child_process_logging.h" 79 #include "chrome/common/child_process_logging.h"
78 #include "chrome/common/chrome_notification_types.h" 80 #include "chrome/common/chrome_notification_types.h"
79 #include "chrome/common/chrome_paths.h" 81 #include "chrome/common/chrome_paths.h"
80 #include "chrome/common/chrome_switches.h" 82 #include "chrome/common/chrome_switches.h"
81 #include "chrome/common/extensions/extension.h" 83 #include "chrome/common/extensions/extension.h"
82 #include "chrome/common/extensions/extension_constants.h" 84 #include "chrome/common/extensions/extension_constants.h"
83 #include "chrome/common/extensions/extension_error_utils.h" 85 #include "chrome/common/extensions/extension_error_utils.h"
84 #include "chrome/common/extensions/extension_file_util.h" 86 #include "chrome/common/extensions/extension_file_util.h"
85 #include "chrome/common/extensions/extension_messages.h" 87 #include "chrome/common/extensions/extension_messages.h"
86 #include "chrome/common/extensions/extension_resource.h" 88 #include "chrome/common/extensions/extension_resource.h"
87 #include "chrome/common/pref_names.h" 89 #include "chrome/common/pref_names.h"
88 #include "chrome/common/url_constants.h" 90 #include "chrome/common/url_constants.h"
89 #include "content/browser/plugin_process_host.h" 91 #include "content/browser/plugin_process_host.h"
90 #include "content/browser/plugin_service.h" 92 #include "content/browser/plugin_service.h"
91 #include "content/browser/user_metrics.h" 93 #include "content/browser/user_metrics.h"
92 #include "content/public/browser/browser_thread.h" 94 #include "content/public/browser/browser_thread.h"
93 #include "content/public/browser/devtools_agent_host_registry.h" 95 #include "content/public/browser/devtools_agent_host_registry.h"
94 #include "content/public/browser/devtools_manager.h" 96 #include "content/public/browser/devtools_manager.h"
95 #include "content/public/browser/notification_service.h" 97 #include "content/public/browser/notification_service.h"
96 #include "content/public/browser/notification_types.h" 98 #include "content/public/browser/notification_types.h"
97 #include "content/public/browser/render_process_host.h" 99 #include "content/public/browser/render_process_host.h"
98 #include "content/public/common/pepper_plugin_info.h" 100 #include "content/public/common/pepper_plugin_info.h"
99 #include "googleurl/src/gurl.h" 101 #include "googleurl/src/gurl.h"
102 #include "grit/theme_resources.h"
100 #include "net/base/registry_controlled_domain.h" 103 #include "net/base/registry_controlled_domain.h"
101 #include "webkit/database/database_tracker.h" 104 #include "webkit/database/database_tracker.h"
102 #include "webkit/database/database_util.h" 105 #include "webkit/database/database_util.h"
103 106
104 #if defined(OS_CHROMEOS) 107 #if defined(OS_CHROMEOS)
105 #include "chrome/browser/chromeos/cros/cros_library.h" 108 #include "chrome/browser/chromeos/cros/cros_library.h"
106 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" 109 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h"
107 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" 110 #include "chrome/browser/chromeos/extensions/input_method_event_router.h"
108 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" 111 #include "chrome/browser/chromeos/extensions/media_player_event_router.h"
109 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 112 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 install_directory_(install_directory), 382 install_directory_(install_directory),
380 extensions_enabled_(extensions_enabled), 383 extensions_enabled_(extensions_enabled),
381 show_extensions_prompts_(true), 384 show_extensions_prompts_(true),
382 ready_(false), 385 ready_(false),
383 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 386 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
384 menu_manager_(profile), 387 menu_manager_(profile),
385 app_notification_manager_(new AppNotificationManager(profile)), 388 app_notification_manager_(new AppNotificationManager(profile)),
386 permissions_manager_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 389 permissions_manager_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
387 apps_promo_(profile->GetPrefs()), 390 apps_promo_(profile->GetPrefs()),
388 event_routers_initialized_(false), 391 event_routers_initialized_(false),
389 extension_warnings_(profile) { 392 extension_warnings_(profile),
393 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.
390 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 394 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
391 395
392 // Figure out if extension installation should be enabled. 396 // Figure out if extension installation should be enabled.
393 if (command_line->HasSwitch(switches::kDisableExtensions)) { 397 if (command_line->HasSwitch(switches::kDisableExtensions)) {
394 extensions_enabled_ = false; 398 extensions_enabled_ = false;
395 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { 399 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) {
396 extensions_enabled_ = false; 400 extensions_enabled_ = false;
397 } 401 }
398 402
399 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, 403 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED,
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 // the webRequest API), set the preference. Otherwise clear it, in case the 2092 // the webRequest API), set the preference. Otherwise clear it, in case the
2089 // extension stopped using a relevant API. 2093 // extension stopped using a relevant API.
2090 extension_prefs_->SetDelaysNetworkRequests( 2094 extension_prefs_->SetDelaysNetworkRequests(
2091 extension->id(), extension->ImplicitlyDelaysNetworkStartup()); 2095 extension->id(), extension->ImplicitlyDelaysNetworkStartup());
2092 2096
2093 content::NotificationService::current()->Notify( 2097 content::NotificationService::current()->Notify(
2094 chrome::NOTIFICATION_EXTENSION_INSTALLED, 2098 chrome::NOTIFICATION_EXTENSION_INSTALLED,
2095 content::Source<Profile>(profile_), 2099 content::Source<Profile>(profile_),
2096 content::Details<const Extension>(extension)); 2100 content::Details<const Extension>(extension));
2097 2101
2102 // Temporary feature to always install shortcuts for platform apps to
2103 // facilitate early testing.
2104 // TODO(benwells): Remove before launching platform apps.
2105 if (extension->is_platform_app()) {
2106 StartInstallApplicationShortcut(extension);
2107 }
2108
2098 // Transfer ownership of |extension| to AddExtension. 2109 // Transfer ownership of |extension| to AddExtension.
2099 AddExtension(scoped_extension); 2110 AddExtension(scoped_extension);
2100 } 2111 }
2101 2112
2102 const Extension* ExtensionService::GetExtensionByIdInternal( 2113 const Extension* ExtensionService::GetExtensionByIdInternal(
2103 const std::string& id, bool include_enabled, bool include_disabled, 2114 const std::string& id, bool include_enabled, bool include_disabled,
2104 bool include_terminated) const { 2115 bool include_terminated) const {
2105 std::string lowercase_id = StringToLowerASCII(id); 2116 std::string lowercase_id = StringToLowerASCII(id);
2106 if (include_enabled) { 2117 if (include_enabled) {
2107 const Extension* extension = extensions_.GetByID(lowercase_id); 2118 const Extension* extension = extensions_.GetByID(lowercase_id);
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 2511
2501 ExtensionService::NaClModuleInfoList::iterator 2512 ExtensionService::NaClModuleInfoList::iterator
2502 ExtensionService::FindNaClModule(const GURL& url) { 2513 ExtensionService::FindNaClModule(const GURL& url) {
2503 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2514 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2504 iter != nacl_module_list_.end(); ++iter) { 2515 iter != nacl_module_list_.end(); ++iter) {
2505 if (iter->url == url) 2516 if (iter->url == url)
2506 return iter; 2517 return iter;
2507 } 2518 }
2508 return nacl_module_list_.end(); 2519 return nacl_module_list_.end();
2509 } 2520 }
2521
2522 void ExtensionService::StartInstallApplicationShortcut(
2523 const Extension* extension) {
2524 #if !defined(OS_MACOSX)
2525 const int kAppIconSize = 32;
2526
2527 shortcut_info_.extension_id = extension->id();
2528 shortcut_info_.url = GURL(extension->launch_web_url());
2529 shortcut_info_.title = UTF8ToUTF16(extension->name());
2530 shortcut_info_.description = UTF8ToUTF16(extension->description());
2531 shortcut_info_.create_in_applications_menu = true;
2532 shortcut_info_.create_in_quick_launch_bar = true;
2533 shortcut_info_.create_on_desktop = true;
2534
2535 // The icon will be resized to |max_size|.
2536 const gfx::Size max_size(kAppIconSize, kAppIconSize);
2537
2538 // 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
2539 // we will resize whatever we can get. Making a large icon smaller
2540 // is prefered to making a small icon larger, so look for a larger
2541 // icon first:
2542 ExtensionResource icon_resource = extension->GetIconResource(
2543 kAppIconSize,
2544 ExtensionIconSet::MATCH_BIGGER);
2545
2546 // If no icon exists that is the desired size or larger, get the
2547 // largest icon available:
2548 if (icon_resource.empty()) {
2549 icon_resource = extension->GetIconResource(
2550 kAppIconSize,
2551 ExtensionIconSet::MATCH_SMALLER);
2552 }
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
2553
2554 tracker_.LoadImage(extension,
2555 icon_resource,
2556 max_size,
2557 ImageLoadingTracker::DONT_CACHE);
2558 #endif
2559 }
2560
2561 void ExtensionService::OnImageLoaded(SkBitmap *image,
2562 const ExtensionResource &resource,
2563 int index)
2564 {
2565 if (!image || image->isNull())
2566 image = ExtensionIconSource::LoadImageByResourceId(IDR_APP_DEFAULT_ICON);
2567
2568 shortcut_info_.favicon = *image;
2569 web_app::CreateShortcut(profile_->GetPath(), shortcut_info_, NULL);
2570 }
OLDNEW
« 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