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

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

Issue 10735048: Revert 146065 - Remove app shortcuts when app is uninstalled on Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/shell_integration_linux.h » ('j') | 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) 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 18 matching lines...) Expand all
29 #else 29 #else
30 const int kDesiredSizes[] = {32}; 30 const int kDesiredSizes[] = {32};
31 #endif 31 #endif
32 } // namespace 32 } // namespace
33 33
34 AppShortcutManager::AppShortcutManager(Profile* profile) 34 AppShortcutManager::AppShortcutManager(Profile* profile)
35 : profile_(profile), 35 : profile_(profile),
36 tracker_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 36 tracker_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
37 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, 37 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED,
38 content::Source<Profile>(profile_)); 38 content::Source<Profile>(profile_));
39 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
40 content::Source<Profile>(profile_));
41 } 39 }
42 40
43 void AppShortcutManager::OnImageLoaded(const gfx::Image& image, 41 void AppShortcutManager::OnImageLoaded(const gfx::Image& image,
44 const std::string& extension_id, 42 const std::string& extension_id,
45 int index) { 43 int index) {
46 // If the image failed to load (e.g. if the resource being loaded was empty) 44 // If the image failed to load (e.g. if the resource being loaded was empty)
47 // use the standard application icon. 45 // use the standard application icon.
48 if (image.IsEmpty()) { 46 if (image.IsEmpty()) {
49 gfx::Image default_icon = 47 gfx::Image default_icon =
50 ResourceBundle::GetSharedInstance().GetImageNamed(IDR_APP_DEFAULT_ICON); 48 ResourceBundle::GetSharedInstance().GetImageNamed(IDR_APP_DEFAULT_ICON);
51 int size = kDesiredSizes[arraysize(kDesiredSizes) - 1]; 49 int size = kDesiredSizes[arraysize(kDesiredSizes) - 1];
52 SkBitmap bmp = skia::ImageOperations::Resize( 50 SkBitmap bmp = skia::ImageOperations::Resize(
53 *default_icon.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST, 51 *default_icon.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST,
54 size, size); 52 size, size);
55 shortcut_info_.favicon = gfx::Image(bmp); 53 shortcut_info_.favicon = gfx::Image(bmp);
56 } else { 54 } else {
57 shortcut_info_.favicon = image; 55 shortcut_info_.favicon = image;
58 } 56 }
59 57
60 web_app::CreateShortcut(profile_->GetPath(), shortcut_info_); 58 web_app::CreateShortcut(profile_->GetPath(), shortcut_info_);
61 } 59 }
62 60
63 void AppShortcutManager::Observe(int type, 61 void AppShortcutManager::Observe(int type,
64 const content::NotificationSource& source, 62 const content::NotificationSource& source,
65 const content::NotificationDetails& details) { 63 const content::NotificationDetails& details) {
66 #if !defined(OS_MACOSX) 64 DCHECK(type == chrome::NOTIFICATION_EXTENSION_INSTALLED);
67 switch (type) { 65 #if !defined(OS_MACOSX)
68 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { 66 const Extension* extension = content::Details<const Extension>(
69 const Extension* extension = content::Details<const Extension>( 67 details).ptr();
70 details).ptr(); 68 if (!disable_shortcut_creation_for_tests &&
71 if (!disable_shortcut_creation_for_tests && 69 extension->is_platform_app() &&
72 extension->is_platform_app() && 70 extension->location() != Extension::LOAD)
73 extension->location() != Extension::LOAD) { 71 InstallApplicationShortcuts(extension);
74 InstallApplicationShortcuts(extension); 72 #endif
75 }
76 break;
77 }
78 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
79 std::string extension_id = *content::Details<std::string>(details).ptr();
80 if (!disable_shortcut_creation_for_tests)
81 web_app::DeleteAllShortcuts(profile_->GetPath(), extension_id);
82 break;
83 }
84 default:
85 NOTREACHED();
86 }
87 #endif
88 } 73 }
89 74
90 // static 75 // static
91 void AppShortcutManager::SetShortcutCreationDisabledForTesting(bool disabled) { 76 void AppShortcutManager::SetShortcutCreationDisabledForTesting(bool disabled) {
92 disable_shortcut_creation_for_tests = disabled; 77 disable_shortcut_creation_for_tests = disabled;
93 } 78 }
94 79
95 void AppShortcutManager::InstallApplicationShortcuts( 80 void AppShortcutManager::InstallApplicationShortcuts(
96 const Extension* extension) { 81 const Extension* extension) {
97 shortcut_info_.extension_id = extension->id(); 82 shortcut_info_.extension_id = extension->id();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 116 }
132 info_list.push_back( 117 info_list.push_back(
133 ImageLoadingTracker::ImageInfo(resource, gfx::Size(size, size))); 118 ImageLoadingTracker::ImageInfo(resource, gfx::Size(size, size)));
134 } 119 }
135 120
136 // |icon_resources| may still be empty at this point, in which case LoadImage 121 // |icon_resources| may still be empty at this point, in which case LoadImage
137 // will call the OnImageLoaded callback with an empty image and exit 122 // will call the OnImageLoaded callback with an empty image and exit
138 // immediately. 123 // immediately.
139 tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE); 124 tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE);
140 } 125 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/shell_integration_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698