| 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/app_shortcut_manager.h" | 5 #include "chrome/browser/extensions/app_shortcut_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 9 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/web_applications/web_app.h" | 11 #include "chrome/browser/web_applications/web_app.h" |
| 11 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
| 13 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/extensions/extension_resource.h" | 14 #include "chrome/common/extensions/extension_resource.h" |
| 13 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
| 14 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
| 15 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 // Allow tests to disable shortcut creation, to prevent developers' desktops | 20 // Allow tests to disable shortcut creation, to prevent developers' desktops |
| 19 // becoming overrun with shortcuts. | 21 // becoming overrun with shortcuts. |
| 20 bool disable_shortcut_creation_for_tests = false; | 22 bool disable_shortcut_creation_for_tests = false; |
| 21 } // namespace | 23 } // namespace |
| (...skipping 26 matching lines...) Expand all Loading... |
| 48 InstallApplicationShortcuts(extension); | 50 InstallApplicationShortcuts(extension); |
| 49 } | 51 } |
| 50 | 52 |
| 51 // static | 53 // static |
| 52 void AppShortcutManager::SetShortcutCreationDisabledForTesting(bool disabled) { | 54 void AppShortcutManager::SetShortcutCreationDisabledForTesting(bool disabled) { |
| 53 disable_shortcut_creation_for_tests = disabled; | 55 disable_shortcut_creation_for_tests = disabled; |
| 54 } | 56 } |
| 55 | 57 |
| 56 void AppShortcutManager::InstallApplicationShortcuts( | 58 void AppShortcutManager::InstallApplicationShortcuts( |
| 57 const Extension* extension) { | 59 const Extension* extension) { |
| 58 #if !defined(OS_MACOSX) | 60 #if defined(OS_MACOSX) |
| 61 // TODO(sail): For now only install shortcuts if enable platform apps is true. |
| 62 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 63 switches::kEnablePlatformApps)) { |
| 64 return; |
| 65 } |
| 66 #endif |
| 67 |
| 59 const int kAppIconSize = 32; | 68 const int kAppIconSize = 32; |
| 60 | 69 |
| 61 shortcut_info_.extension_id = extension->id(); | 70 shortcut_info_.extension_id = extension->id(); |
| 62 shortcut_info_.url = GURL(extension->launch_web_url()); | 71 shortcut_info_.url = GURL(extension->launch_web_url()); |
| 63 shortcut_info_.title = UTF8ToUTF16(extension->name()); | 72 shortcut_info_.title = UTF8ToUTF16(extension->name()); |
| 64 shortcut_info_.description = UTF8ToUTF16(extension->description()); | 73 shortcut_info_.description = UTF8ToUTF16(extension->description()); |
| 65 shortcut_info_.create_in_applications_menu = true; | 74 shortcut_info_.create_in_applications_menu = true; |
| 66 shortcut_info_.create_in_quick_launch_bar = true; | 75 shortcut_info_.create_in_quick_launch_bar = true; |
| 67 shortcut_info_.create_on_desktop = true; | 76 shortcut_info_.create_on_desktop = true; |
| 68 | 77 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 84 ExtensionIconSet::MATCH_SMALLER); | 93 ExtensionIconSet::MATCH_SMALLER); |
| 85 } | 94 } |
| 86 | 95 |
| 87 // icon_resource may still be empty at this point, in which case LoadImage | 96 // icon_resource may still be empty at this point, in which case LoadImage |
| 88 // which call the OnImageLoaded callback with a NULL image and exit | 97 // which call the OnImageLoaded callback with a NULL image and exit |
| 89 // immediately. | 98 // immediately. |
| 90 tracker_.LoadImage(extension, | 99 tracker_.LoadImage(extension, |
| 91 icon_resource, | 100 icon_resource, |
| 92 max_size, | 101 max_size, |
| 93 ImageLoadingTracker::DONT_CACHE); | 102 ImageLoadingTracker::DONT_CACHE); |
| 94 #endif | |
| 95 } | 103 } |
| OLD | NEW |