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

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

Issue 915973002: Add bookmark apps to taskbar automatically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 base::Bind(&OnImageLoaded, shortcut_info, file_handlers_info, callback)); 276 base::Bind(&OnImageLoaded, shortcut_info, file_handlers_info, callback));
277 } 277 }
278 278
279 void GetShortcutInfoForApp(const extensions::Extension* extension, 279 void GetShortcutInfoForApp(const extensions::Extension* extension,
280 Profile* profile, 280 Profile* profile,
281 const ShortcutInfoCallback& callback) { 281 const ShortcutInfoCallback& callback) {
282 GetInfoForApp( 282 GetInfoForApp(
283 extension, profile, base::Bind(&IgnoreFileHandlersInfo, callback)); 283 extension, profile, base::Bind(&IgnoreFileHandlersInfo, callback));
284 } 284 }
285 285
286 bool ShouldCreateShortcutFor(Profile* profile, 286 bool ShouldCreateShortcutFor(web_app::ShortcutCreationReason reason,
287 Profile* profile,
287 const extensions::Extension* extension) { 288 const extensions::Extension* extension) {
288 bool app_type_requires_shortcut = extension->is_platform_app(); 289 // Shortcuts should never be created for component apps, or for apps that
290 // cannot be shown in the launcher.
291 if (extension->location() == extensions::Manifest::COMPONENT ||
292 !extensions::ui_util::CanDisplayInAppLauncher(extension, profile)) {
293 return false;
294 }
289 295
290 // An additional check here for OS X. We need app shims to be 296 // Otherwise, always create shortcuts for v2 packaged apps.
291 // able to show them in the dock. 297 if (extension->is_platform_app())
298 return true;
299
292 #if defined(OS_MACOSX) 300 #if defined(OS_MACOSX)
293 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 301 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
294 switches::kDisableHostedAppShimCreation)) { 302 switches::kDisableHostedAppShimCreation)) {
295 app_type_requires_shortcut = 303 return extension->is_hosted_app();
296 app_type_requires_shortcut || extension->is_hosted_app();
297 } 304 }
305
306 return false;
307 #else
308 // For other platforms, allow shortcut creation if it was explicitly
309 // requested by the user (i.e. is not automatic).
310 return reason == SHORTCUT_CREATION_BY_USER;
298 #endif 311 #endif
299
300 return (app_type_requires_shortcut &&
301 extension->location() != extensions::Manifest::COMPONENT &&
302 extensions::ui_util::CanDisplayInAppLauncher(extension, profile));
303 } 312 }
304 313
305 base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path, 314 base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path,
306 const std::string& extension_id, 315 const std::string& extension_id,
307 const GURL& url) { 316 const GURL& url) {
308 DCHECK(!profile_path.empty()); 317 DCHECK(!profile_path.empty());
309 base::FilePath app_data_dir(profile_path.Append(chrome::kWebAppDirname)); 318 base::FilePath app_data_dir(profile_path.Append(chrome::kWebAppDirname));
310 319
311 if (!extension_id.empty()) { 320 if (!extension_id.empty()) {
312 return app_data_dir.AppendASCII( 321 return app_data_dir.AppendASCII(
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 ScheduleCreatePlatformShortcut(SHORTCUT_CREATION_AUTOMATED, locations, 409 ScheduleCreatePlatformShortcut(SHORTCUT_CREATION_AUTOMATED, locations,
401 shortcut_info, extensions::FileHandlersInfo()); 410 shortcut_info, extensions::FileHandlersInfo());
402 } 411 }
403 412
404 void CreateShortcuts(ShortcutCreationReason reason, 413 void CreateShortcuts(ShortcutCreationReason reason,
405 const ShortcutLocations& locations, 414 const ShortcutLocations& locations,
406 Profile* profile, 415 Profile* profile,
407 const extensions::Extension* app) { 416 const extensions::Extension* app) {
408 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 417 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
409 418
410 if (!ShouldCreateShortcutFor(profile, app)) 419 if (!ShouldCreateShortcutFor(reason, profile, app))
411 return; 420 return;
412 421
413 GetInfoForApp( 422 GetInfoForApp(
414 app, profile, base::Bind(&CreateShortcutsWithInfo, reason, locations)); 423 app, profile, base::Bind(&CreateShortcutsWithInfo, reason, locations));
415 } 424 }
416 425
417 void DeleteAllShortcuts(Profile* profile, const extensions::Extension* app) { 426 void DeleteAllShortcuts(Profile* profile, const extensions::Extension* app) {
418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 427 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
419 428
420 ShortcutInfo shortcut_info = 429 ShortcutInfo shortcut_info =
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 482
474 #if defined(OS_LINUX) 483 #if defined(OS_LINUX)
475 std::string GetWMClassFromAppName(std::string app_name) { 484 std::string GetWMClassFromAppName(std::string app_name) {
476 base::i18n::ReplaceIllegalCharactersInPath(&app_name, '_'); 485 base::i18n::ReplaceIllegalCharactersInPath(&app_name, '_');
477 base::TrimString(app_name, "_", &app_name); 486 base::TrimString(app_name, "_", &app_name);
478 return app_name; 487 return app_name;
479 } 488 }
480 #endif 489 #endif
481 490
482 } // namespace web_app 491 } // namespace web_app
OLDNEW
« no previous file with comments | « chrome/browser/web_applications/web_app.h ('k') | chrome/browser/web_applications/web_app_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698