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/command_line.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/web_applications/web_app.h" | 10 #include "chrome/browser/web_applications/web_app.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 shortcut_info_.favicon = image; | 55 shortcut_info_.favicon = image; |
56 } | 56 } |
57 | 57 |
58 web_app::CreateShortcut(profile_->GetPath(), shortcut_info_); | 58 web_app::CreateShortcut(profile_->GetPath(), shortcut_info_); |
59 } | 59 } |
60 | 60 |
61 void AppShortcutManager::Observe(int type, | 61 void AppShortcutManager::Observe(int type, |
62 const content::NotificationSource& source, | 62 const content::NotificationSource& source, |
63 const content::NotificationDetails& details) { | 63 const content::NotificationDetails& details) { |
64 DCHECK(type == chrome::NOTIFICATION_EXTENSION_INSTALLED); | 64 DCHECK(type == chrome::NOTIFICATION_EXTENSION_INSTALLED); |
65 const Extension* extension = content::Details<const Extension>(details).ptr(); | 65 #if !defined(OS_MACOSX) |
66 if (!disable_shortcut_creation_for_tests && extension->is_platform_app() && | 66 const Extension* extension = content::Details<const Extension>( |
67 extension->location() != Extension::LOAD) | 67 details).ptr(); |
68 InstallApplicationShortcuts(extension); | 68 if (!disable_shortcut_creation_for_tests && |
| 69 extension->is_platform_app() && |
| 70 extension->location() != Extension::LOAD) |
| 71 InstallApplicationShortcuts(extension); |
| 72 #endif |
69 } | 73 } |
70 | 74 |
71 // static | 75 // static |
72 void AppShortcutManager::SetShortcutCreationDisabledForTesting(bool disabled) { | 76 void AppShortcutManager::SetShortcutCreationDisabledForTesting(bool disabled) { |
73 disable_shortcut_creation_for_tests = disabled; | 77 disable_shortcut_creation_for_tests = disabled; |
74 } | 78 } |
75 | 79 |
76 void AppShortcutManager::InstallApplicationShortcuts( | 80 void AppShortcutManager::InstallApplicationShortcuts( |
77 const Extension* extension) { | 81 const Extension* extension) { |
78 #if defined(OS_MACOSX) | |
79 // TODO(sail): For now only install shortcuts if enable platform apps is true. | |
80 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
81 switches::kEnablePlatformApps)) { | |
82 return; | |
83 } | |
84 #endif | |
85 | |
86 shortcut_info_.extension_id = extension->id(); | 82 shortcut_info_.extension_id = extension->id(); |
87 shortcut_info_.url = GURL(extension->launch_web_url()); | 83 shortcut_info_.url = GURL(extension->launch_web_url()); |
88 shortcut_info_.title = UTF8ToUTF16(extension->name()); | 84 shortcut_info_.title = UTF8ToUTF16(extension->name()); |
89 shortcut_info_.description = UTF8ToUTF16(extension->description()); | 85 shortcut_info_.description = UTF8ToUTF16(extension->description()); |
90 shortcut_info_.extension_path = extension->path(); | 86 shortcut_info_.extension_path = extension->path(); |
91 shortcut_info_.is_platform_app = extension->is_platform_app(); | 87 shortcut_info_.is_platform_app = extension->is_platform_app(); |
92 shortcut_info_.create_in_applications_menu = true; | 88 shortcut_info_.create_in_applications_menu = true; |
93 shortcut_info_.create_in_quick_launch_bar = true; | 89 shortcut_info_.create_in_quick_launch_bar = true; |
94 shortcut_info_.create_on_desktop = true; | 90 shortcut_info_.create_on_desktop = true; |
95 | 91 |
(...skipping 23 matching lines...) Expand all Loading... |
119 } | 115 } |
120 info_list.push_back( | 116 info_list.push_back( |
121 ImageLoadingTracker::ImageInfo(resource, gfx::Size(size, size))); | 117 ImageLoadingTracker::ImageInfo(resource, gfx::Size(size, size))); |
122 } | 118 } |
123 | 119 |
124 // |icon_resources| may still be empty at this point, in which case LoadImage | 120 // |icon_resources| may still be empty at this point, in which case LoadImage |
125 // will call the OnImageLoaded callback with an empty image and exit | 121 // will call the OnImageLoaded callback with an empty image and exit |
126 // immediately. | 122 // immediately. |
127 tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE); | 123 tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE); |
128 } | 124 } |
OLD | NEW |