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

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

Issue 9310079: Moved app shortcut code out of ExtensionService. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed stupid virtual ommission Created 8 years, 10 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.h ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <shlobj.h> 8 #include <shlobj.h>
9 #endif // defined(OS_WIN) 9 #endif // defined(OS_WIN)
10 10
(...skipping 18 matching lines...) Expand all
29 #endif 29 #endif
30 30
31 #if defined(OS_WIN) 31 #if defined(OS_WIN)
32 #include "ui/gfx/icon_util.h" 32 #include "ui/gfx/icon_util.h"
33 #endif // defined(OS_WIN) 33 #endif // defined(OS_WIN)
34 34
35 using content::BrowserThread; 35 using content::BrowserThread;
36 36
37 namespace { 37 namespace {
38 38
39 // Allow tests to disable shortcut creation, to prevent developers desktops
40 // becoming overrun with shortcuts.
41 bool disable_shortcut_creation_for_tests = false;
42
43 #if defined(OS_WIN) 39 #if defined(OS_WIN)
44 const FilePath::CharType kIconChecksumFileExt[] = FILE_PATH_LITERAL(".ico.md5"); 40 const FilePath::CharType kIconChecksumFileExt[] = FILE_PATH_LITERAL(".ico.md5");
45 41
46 // Returns true if |ch| is in visible ASCII range and not one of 42 // Returns true if |ch| is in visible ASCII range and not one of
47 // "/ \ : * ? " < > | ; ,". 43 // "/ \ : * ? " < > | ; ,".
48 bool IsValidFilePathChar(char16 c) { 44 bool IsValidFilePathChar(char16 c) {
49 if (c < 32) 45 if (c < 32)
50 return false; 46 return false;
51 47
52 switch (c) { 48 switch (c) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 sizeof(base::MD5Digest)) != 0; 147 sizeof(base::MD5Digest)) != 0;
152 } 148 }
153 149
154 #endif // defined(OS_WIN) 150 #endif // defined(OS_WIN)
155 151
156 void CreateShortcutTask(const FilePath& web_app_path, 152 void CreateShortcutTask(const FilePath& web_app_path,
157 const FilePath& profile_path, 153 const FilePath& profile_path,
158 const ShellIntegration::ShortcutInfo& shortcut_info) { 154 const ShellIntegration::ShortcutInfo& shortcut_info) {
159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
160 156
161 if (disable_shortcut_creation_for_tests)
162 return;
163
164 #if defined(OS_POSIX) && !defined(OS_MACOSX) 157 #if defined(OS_POSIX) && !defined(OS_MACOSX)
165 scoped_ptr<base::Environment> env(base::Environment::Create()); 158 scoped_ptr<base::Environment> env(base::Environment::Create());
166 159
167 std::string shortcut_template; 160 std::string shortcut_template;
168 if (!ShellIntegration::GetDesktopShortcutTemplate(env.get(), 161 if (!ShellIntegration::GetDesktopShortcutTemplate(env.get(),
169 &shortcut_template)) { 162 &shortcut_template)) {
170 return; 163 return;
171 } 164 }
172 ShellIntegration::CreateDesktopShortcut(shortcut_info, shortcut_template); 165 ShellIntegration::CreateDesktopShortcut(shortcut_info, shortcut_template);
173 return; // assuming always success. 166 return; // assuming always success.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 BrowserThread::FILE, 416 BrowserThread::FILE,
424 FROM_HERE, 417 FROM_HERE,
425 base::Bind(&CreateShortcutTask, 418 base::Bind(&CreateShortcutTask,
426 web_app::internals::GetWebAppDataDirectory( 419 web_app::internals::GetWebAppDataDirectory(
427 web_app::GetDataDir(data_dir), 420 web_app::GetDataDir(data_dir),
428 shortcut_info), 421 shortcut_info),
429 data_dir, 422 data_dir,
430 shortcut_info)); 423 shortcut_info));
431 } 424 }
432 425
433 void SetDisableShortcutCreationForTests(bool disable) {
434 disable_shortcut_creation_for_tests = disable;
435 }
436
437 bool IsValidUrl(const GURL& url) { 426 bool IsValidUrl(const GURL& url) {
438 static const char* const kValidUrlSchemes[] = { 427 static const char* const kValidUrlSchemes[] = {
439 chrome::kFileScheme, 428 chrome::kFileScheme,
440 chrome::kFtpScheme, 429 chrome::kFtpScheme,
441 chrome::kHttpScheme, 430 chrome::kHttpScheme,
442 chrome::kHttpsScheme, 431 chrome::kHttpsScheme,
443 chrome::kExtensionScheme, 432 chrome::kExtensionScheme,
444 }; 433 };
445 434
446 for (size_t i = 0; i < arraysize(kValidUrlSchemes); ++i) { 435 for (size_t i = 0; i < arraysize(kValidUrlSchemes); ++i) {
(...skipping 27 matching lines...) Expand all
474 463
475 #if defined(TOOLKIT_USES_GTK) 464 #if defined(TOOLKIT_USES_GTK)
476 std::string GetWMClassFromAppName(std::string app_name) { 465 std::string GetWMClassFromAppName(std::string app_name) {
477 file_util::ReplaceIllegalCharactersInPath(&app_name, '_'); 466 file_util::ReplaceIllegalCharactersInPath(&app_name, '_');
478 TrimString(app_name, "_", &app_name); 467 TrimString(app_name, "_", &app_name);
479 return app_name; 468 return app_name;
480 } 469 }
481 #endif 470 #endif
482 471
483 } // namespace web_app 472 } // namespace web_app
OLDNEW
« no previous file with comments | « chrome/browser/web_applications/web_app.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698