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

Side by Side Diff: chrome/browser/web_applications/web_app_win.cc

Issue 9958006: Create Linux platform app shortcuts to run in their own process. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moved new function into shell_integration_linux.h Created 8 years, 8 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
« no previous file with comments | « chrome/browser/web_applications/web_app_mac.mm ('k') | chrome/chrome_browser.gypi » ('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/web_applications/web_app.h" 5 #include "chrome/browser/web_applications/web_app.h"
6 6
7 #include <shlobj.h> 7 #include <shlobj.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSHNOWAIT, 85 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSHNOWAIT,
86 NULL, NULL); 86 NULL, NULL);
87 } else { 87 } else {
88 return false; 88 return false;
89 } 89 }
90 } 90 }
91 91
92 return true; 92 return true;
93 } 93 }
94 94
95 void CreateShortcutTask(const FilePath& web_app_path, 95 bool CreatePlatformShortcut(
96 const FilePath& profile_path, 96 const FilePath& web_app_path,
97 const ShellIntegration::ShortcutInfo& shortcut_info) { 97 const FilePath& profile_path,
98 const ShellIntegration::ShortcutInfo& shortcut_info) {
98 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 99 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
99 100
100 // Shortcut paths under which to create shortcuts. 101 // Shortcut paths under which to create shortcuts.
101 std::vector<FilePath> shortcut_paths; 102 std::vector<FilePath> shortcut_paths;
102 103
103 // Locations to add to shortcut_paths. 104 // Locations to add to shortcut_paths.
104 struct { 105 struct {
105 const bool& use_this_location; 106 const bool& use_this_location;
106 int location_id; 107 int location_id;
107 const wchar_t* sub_dir; 108 const wchar_t* sub_dir;
(...skipping 20 matching lines...) Expand all
128 // Populate shortcut_paths. 129 // Populate shortcut_paths.
129 for (int i = 0; i < arraysize(locations); ++i) { 130 for (int i = 0; i < arraysize(locations); ++i) {
130 if (locations[i].use_this_location) { 131 if (locations[i].use_this_location) {
131 FilePath path; 132 FilePath path;
132 133
133 // Skip the Win7 case. 134 // Skip the Win7 case.
134 if (locations[i].location_id == base::PATH_START) 135 if (locations[i].location_id == base::PATH_START)
135 continue; 136 continue;
136 137
137 if (!PathService::Get(locations[i].location_id, &path)) { 138 if (!PathService::Get(locations[i].location_id, &path)) {
138 return; 139 return false;
139 } 140 }
140 141
141 if (locations[i].sub_dir != NULL) 142 if (locations[i].sub_dir != NULL)
142 path = path.Append(locations[i].sub_dir); 143 path = path.Append(locations[i].sub_dir);
143 144
144 shortcut_paths.push_back(path); 145 shortcut_paths.push_back(path);
145 } 146 }
146 } 147 }
147 148
148 bool pin_to_taskbar = 149 bool pin_to_taskbar =
149 shortcut_info.create_in_quick_launch_bar && 150 shortcut_info.create_in_quick_launch_bar &&
150 (base::win::GetVersion() >= base::win::VERSION_WIN7); 151 (base::win::GetVersion() >= base::win::VERSION_WIN7);
151 152
152 // For Win7's pinning support, any shortcut could be used. So we only create 153 // For Win7's pinning support, any shortcut could be used. So we only create
153 // the shortcut file when there is no shortcut file will be created. That is, 154 // the shortcut file when there is no shortcut file will be created. That is,
154 // user only selects "Pin to taskbar". 155 // user only selects "Pin to taskbar".
155 if (pin_to_taskbar && shortcut_paths.empty()) { 156 if (pin_to_taskbar && shortcut_paths.empty()) {
156 // Creates the shortcut in web_app_path in this case. 157 // Creates the shortcut in web_app_path in this case.
157 shortcut_paths.push_back(web_app_path); 158 shortcut_paths.push_back(web_app_path);
158 } 159 }
159 160
160 if (shortcut_paths.empty()) { 161 if (shortcut_paths.empty()) {
161 return; 162 return false;
162 }
163
164 // Ensure web_app_path exists.
165 if (!file_util::PathExists(web_app_path) &&
166 !file_util::CreateDirectory(web_app_path)) {
167 return;
168 } 163 }
169 164
170 // Generates file name to use with persisted ico and shortcut file. 165 // Generates file name to use with persisted ico and shortcut file.
171 FilePath file_name = 166 FilePath file_name =
172 web_app::internals::GetSanitizedFileName(shortcut_info.title); 167 web_app::internals::GetSanitizedFileName(shortcut_info.title);
173 168
174 // Creates an ico file to use with shortcut. 169 // Creates an ico file to use with shortcut.
175 FilePath icon_file = web_app_path.Append(file_name).ReplaceExtension( 170 FilePath icon_file = web_app_path.Append(file_name).ReplaceExtension(
176 FILE_PATH_LITERAL(".ico")); 171 FILE_PATH_LITERAL(".ico"));
177 if (!web_app::internals::CheckAndSaveIcon(icon_file, 172 if (!web_app::internals::CheckAndSaveIcon(icon_file,
178 *shortcut_info.favicon.ToSkBitmap())) { 173 *shortcut_info.favicon.ToSkBitmap())) {
179 return; 174 return false;
180 } 175 }
181 176
182 FilePath chrome_exe; 177 FilePath chrome_exe;
183 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { 178 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
184 return; 179 return false;
185 } 180 }
186 181
187 // Working directory. 182 // Working directory.
188 FilePath chrome_folder = chrome_exe.DirName(); 183 FilePath chrome_folder = chrome_exe.DirName();
189 184
190 CommandLine cmd_line(CommandLine::NO_PROGRAM); 185 CommandLine cmd_line(CommandLine::NO_PROGRAM);
191 if (shortcut_info.is_platform_app) { 186 if (shortcut_info.is_platform_app) {
192 cmd_line = ShellIntegration::CommandLineArgsForPlatformApp( 187 cmd_line = ShellIntegration::CommandLineArgsForPlatformApp(
193 shortcut_info.extension_id, web_app_path, shortcut_info.extension_path); 188 shortcut_info.extension_id, web_app_path, shortcut_info.extension_path);
194 } else { 189 } else {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 241 }
247 242
248 if (success && pin_to_taskbar) { 243 if (success && pin_to_taskbar) {
249 if (!shortcut_to_pin.empty()) { 244 if (!shortcut_to_pin.empty()) {
250 success &= file_util::TaskbarPinShortcutLink( 245 success &= file_util::TaskbarPinShortcutLink(
251 shortcut_to_pin.value().c_str()); 246 shortcut_to_pin.value().c_str());
252 } else { 247 } else {
253 success = false; 248 success = false;
254 } 249 }
255 } 250 }
251
252 return success;
256 } 253 }
257 254
258 } // namespace internals 255 } // namespace internals
259 256
260 } // namespace web_app 257 } // namespace web_app
OLDNEW
« no previous file with comments | « chrome/browser/web_applications/web_app_mac.mm ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698