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

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 9346013: Publish app shortcuts on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 8 years, 10 months 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 | Annotate | Revision Log
OLDNEW
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 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2628 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2629 iter != nacl_module_list_.end(); ++iter) { 2629 iter != nacl_module_list_.end(); ++iter) {
2630 if (iter->url == url) 2630 if (iter->url == url)
2631 return iter; 2631 return iter;
2632 } 2632 }
2633 return nacl_module_list_.end(); 2633 return nacl_module_list_.end();
2634 } 2634 }
2635 2635
2636 void ExtensionService::StartInstallApplicationShortcut( 2636 void ExtensionService::StartInstallApplicationShortcut(
2637 const Extension* extension) { 2637 const Extension* extension) {
2638 #if !defined(OS_MACOSX) 2638 #if defined(OS_MACOSX)
2639 // TODO(sail): For now only install shortcuts for if enable platform apps
Mark Mentovai 2012/02/08 05:53:26 Revise grammar (get rid of “for?”)
sail 2012/02/08 06:12:51 Done.
2640 // is true and if the extension is a platform app.
2641 if (!extension->is_platform_app() ||
2642 !CommandLine::ForCurrentProcess()->HasSwitch(
2643 switches::kEnablePlatformApps)) {
2644 return;
2645 }
2646 #endif
2647
2639 const int kAppIconSize = 32; 2648 const int kAppIconSize = 32;
2640 2649
2641 shortcut_info_.extension_id = extension->id(); 2650 shortcut_info_.extension_id = extension->id();
2642 shortcut_info_.url = GURL(extension->launch_web_url()); 2651 shortcut_info_.url = GURL(extension->launch_web_url());
2643 shortcut_info_.title = UTF8ToUTF16(extension->name()); 2652 shortcut_info_.title = UTF8ToUTF16(extension->name());
2644 shortcut_info_.description = UTF8ToUTF16(extension->description()); 2653 shortcut_info_.description = UTF8ToUTF16(extension->description());
2645 shortcut_info_.create_in_applications_menu = true; 2654 shortcut_info_.create_in_applications_menu = true;
2646 shortcut_info_.create_in_quick_launch_bar = true; 2655 shortcut_info_.create_in_quick_launch_bar = true;
2647 shortcut_info_.create_on_desktop = true; 2656 shortcut_info_.create_on_desktop = true;
2648 2657
(...skipping 15 matching lines...) Expand all
2664 ExtensionIconSet::MATCH_SMALLER); 2673 ExtensionIconSet::MATCH_SMALLER);
2665 } 2674 }
2666 2675
2667 // icon_resource may still be empty at this point, in which case LoadImage 2676 // icon_resource may still be empty at this point, in which case LoadImage
2668 // which call the OnImageLoaded callback with a NULL image and exit 2677 // which call the OnImageLoaded callback with a NULL image and exit
2669 // immediately. 2678 // immediately.
2670 tracker_.LoadImage(extension, 2679 tracker_.LoadImage(extension,
2671 icon_resource, 2680 icon_resource,
2672 max_size, 2681 max_size,
2673 ImageLoadingTracker::DONT_CACHE); 2682 ImageLoadingTracker::DONT_CACHE);
2674 #endif
2675 } 2683 }
2676 2684
2677 void ExtensionService::OnImageLoaded(SkBitmap *image, 2685 void ExtensionService::OnImageLoaded(SkBitmap *image,
2678 const ExtensionResource &resource, 2686 const ExtensionResource &resource,
2679 int index) { 2687 int index) {
2680 // If the image failed to load (e.g. if the resource being loaded was empty) 2688 // If the image failed to load (e.g. if the resource being loaded was empty)
2681 // use the standard application icon. 2689 // use the standard application icon.
2682 if (!image || image->isNull()) 2690 if (!image || image->isNull())
2683 image = ExtensionIconSource::LoadImageByResourceId(IDR_APP_DEFAULT_ICON); 2691 image = ExtensionIconSource::LoadImageByResourceId(IDR_APP_DEFAULT_ICON);
2684 2692
2685 shortcut_info_.favicon = *image; 2693 shortcut_info_.favicon = *image;
2686 web_app::CreateShortcut(profile_->GetPath(), shortcut_info_); 2694 web_app::CreateShortcut(profile_->GetPath(), shortcut_info_);
2687 } 2695 }
2688 2696
2689 extensions::SocketController* ExtensionService::socket_controller() { 2697 extensions::SocketController* ExtensionService::socket_controller() {
2690 // TODO(miket): Find a better place for SocketController to live. It needs 2698 // TODO(miket): Find a better place for SocketController to live. It needs
2691 // to be scoped such that it can be created and destroyed on the IO thread. 2699 // to be scoped such that it can be created and destroyed on the IO thread.
2692 // 2700 //
2693 // To coexist with certain unit tests that don't have an IO thread message 2701 // To coexist with certain unit tests that don't have an IO thread message
2694 // loop available at ExtensionService shutdown, we lazy-initialize this 2702 // loop available at ExtensionService shutdown, we lazy-initialize this
2695 // object so that those cases neither create nor destroy a SocketController. 2703 // object so that those cases neither create nor destroy a SocketController.
2696 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 2704 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2697 if (!socket_controller_) { 2705 if (!socket_controller_) {
2698 socket_controller_ = new extensions::SocketController(); 2706 socket_controller_ = new extensions::SocketController();
2699 } 2707 }
2700 return socket_controller_; 2708 return socket_controller_;
2701 } 2709 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698