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

Side by Side Diff: chrome/browser/apps/shortcut_manager.cc

Issue 1497193002: Remove all the ephemeral apps code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review, Devlin review. Created 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/apps/shortcut_manager.h" 5 #include "chrome/browser/apps/shortcut_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/extension_ui_util.h"
16 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/profiles/profile_info_cache.h" 16 #include "chrome/browser/profiles/profile_info_cache.h"
18 #include "chrome/browser/profiles/profile_manager.h" 17 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/shell_integration.h" 18 #include "chrome/browser/shell_integration.h"
20 #include "chrome/browser/web_applications/web_app.h" 19 #include "chrome/browser/web_applications/web_app.h"
21 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
23 #include "components/pref_registry/pref_registry_syncable.h" 22 #include "components/pref_registry/pref_registry_syncable.h"
24 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
25 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
26 #include "extensions/browser/extension_registry.h" 25 #include "extensions/browser/extension_registry.h"
27 #include "extensions/browser/extension_system.h" 26 #include "extensions/browser/extension_system.h"
28 #include "extensions/browser/extension_util.h"
29 #include "extensions/common/extension_set.h" 27 #include "extensions/common/extension_set.h"
30 #include "extensions/common/one_shot_event.h" 28 #include "extensions/common/one_shot_event.h"
31 29
32 using extensions::Extension; 30 using extensions::Extension;
33 31
34 namespace { 32 namespace {
35 33
36 // This version number is stored in local prefs to check whether app shortcuts 34 // This version number is stored in local prefs to check whether app shortcuts
37 // need to be recreated. This might happen when we change various aspects of app 35 // need to be recreated. This might happen when we change various aspects of app
38 // shortcuts like command-line flags or associated icons, binaries, etc. 36 // shortcuts like command-line flags or associated icons, binaries, etc.
39 #if defined(OS_MACOSX) 37 #if defined(OS_MACOSX)
40 const int kCurrentAppShortcutsVersion = 4; 38 const int kCurrentAppShortcutsVersion = 4;
41 #else 39 #else
42 const int kCurrentAppShortcutsVersion = 0; 40 const int kCurrentAppShortcutsVersion = 0;
43 #endif 41 #endif
44 42
45 // Delay in seconds before running UpdateShortcutsForAllApps. 43 // Delay in seconds before running UpdateShortcutsForAllApps.
46 const int kUpdateShortcutsForAllAppsDelay = 10; 44 const int kUpdateShortcutsForAllAppsDelay = 10;
47 45
48 void CreateShortcutsForApp(Profile* profile, const Extension* app) { 46 void CreateShortcutsForApp(Profile* profile, const Extension* app) {
49 web_app::ShortcutLocations creation_locations; 47 web_app::ShortcutLocations creation_locations;
50 48
51 if (extensions::util::IsEphemeralApp(app->id(), profile)) { 49 // Creates a shortcut for an app in the Chrome Apps subdir of the
52 // Ephemeral apps should not have visible shortcuts, but may still require 50 // applications menu, if there is not already one present.
53 // platform-specific handling. 51 creation_locations.applications_menu_location =
54 creation_locations.applications_menu_location = 52 web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS;
55 web_app::APP_MENU_LOCATION_HIDDEN;
56 } else {
57 // Creates a shortcut for an app in the Chrome Apps subdir of the
58 // applications menu, if there is not already one present.
59 creation_locations.applications_menu_location =
60 web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS;
61 }
62 53
63 web_app::CreateShortcuts( 54 web_app::CreateShortcuts(
64 web_app::SHORTCUT_CREATION_AUTOMATED, creation_locations, profile, app); 55 web_app::SHORTCUT_CREATION_AUTOMATED, creation_locations, profile, app);
65 } 56 }
66 57
67 void SetCurrentAppShortcutsVersion(PrefService* prefs) { 58 void SetCurrentAppShortcutsVersion(PrefService* prefs) {
68 prefs->SetInteger(prefs::kAppShortcutsVersion, kCurrentAppShortcutsVersion); 59 prefs->SetInteger(prefs::kAppShortcutsVersion, kCurrentAppShortcutsVersion);
69 } 60 }
70 61
71 } // namespace 62 } // namespace
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // profile_manager might be NULL in testing environments or during shutdown. 103 // profile_manager might be NULL in testing environments or during shutdown.
113 if (profile_manager) 104 if (profile_manager)
114 profile_manager->GetProfileInfoCache().RemoveObserver(this); 105 profile_manager->GetProfileInfoCache().RemoveObserver(this);
115 } 106 }
116 } 107 }
117 108
118 void AppShortcutManager::OnExtensionWillBeInstalled( 109 void AppShortcutManager::OnExtensionWillBeInstalled(
119 content::BrowserContext* browser_context, 110 content::BrowserContext* browser_context,
120 const Extension* extension, 111 const Extension* extension,
121 bool is_update, 112 bool is_update,
122 bool from_ephemeral,
123 const std::string& old_name) { 113 const std::string& old_name) {
124 if (!extension->is_app()) 114 if (!extension->is_app())
125 return; 115 return;
126 116
127 // If the app is being updated, update any existing shortcuts but do not 117 // If the app is being updated, update any existing shortcuts but do not
128 // create new ones. If it is being installed, automatically create a 118 // create new ones. If it is being installed, automatically create a
129 // shortcut in the applications menu (e.g., Start Menu). 119 // shortcut in the applications menu (e.g., Start Menu).
130 if (is_update && !from_ephemeral) { 120 if (is_update) {
131 web_app::UpdateAllShortcuts( 121 web_app::UpdateAllShortcuts(
132 base::UTF8ToUTF16(old_name), profile_, extension); 122 base::UTF8ToUTF16(old_name), profile_, extension);
133 } else { 123 } else {
134 CreateShortcutsForApp(profile_, extension); 124 CreateShortcutsForApp(profile_, extension);
135 } 125 }
136 } 126 }
137 127
138 void AppShortcutManager::OnExtensionUninstalled( 128 void AppShortcutManager::OnExtensionUninstalled(
139 content::BrowserContext* browser_context, 129 content::BrowserContext* browser_context,
140 const Extension* extension, 130 const Extension* extension,
(...skipping 20 matching lines...) Expand all
161 return; 151 return;
162 152
163 content::BrowserThread::PostDelayedTask( 153 content::BrowserThread::PostDelayedTask(
164 content::BrowserThread::UI, 154 content::BrowserThread::UI,
165 FROM_HERE, 155 FROM_HERE,
166 base::Bind(&web_app::UpdateShortcutsForAllApps, 156 base::Bind(&web_app::UpdateShortcutsForAllApps,
167 profile_, 157 profile_,
168 base::Bind(&SetCurrentAppShortcutsVersion, prefs_)), 158 base::Bind(&SetCurrentAppShortcutsVersion, prefs_)),
169 base::TimeDelta::FromSeconds(kUpdateShortcutsForAllAppsDelay)); 159 base::TimeDelta::FromSeconds(kUpdateShortcutsForAllAppsDelay));
170 } 160 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/shortcut_manager.h ('k') | chrome/browser/background/background_application_list_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698