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

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: 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
« no previous file with comments | « chrome/browser/extensions/bookmark_app_helper.cc ('k') | no next file » | 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 "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,
jackhou1 2015/02/11 07:14:42 Need to update the use of this function in web_app
benwells 2015/02/12 02:09:36 Done.
287 Profile* profile,
287 const extensions::Extension* extension) { 288 const extensions::Extension* extension) {
288 bool app_type_requires_shortcut = extension->is_platform_app(); 289 // Only create shortcuts automatically if they are platform apps.
290 bool app_type_requires_shortcut = extension->is_platform_app() ||
291 reason == SHORTCUT_CREATION_BY_USER;
289 292
290 // An additional check here for OS X. We need app shims to be 293 // An additional check here for OS X. We need app shims to be
291 // able to show them in the dock. 294 // able to show them in the dock.
292 #if defined(OS_MACOSX) 295 #if defined(OS_MACOSX)
293 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 296 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
jackhou1 2015/02/11 07:14:42 With the inverted logic, if there's an automatic s
benwells 2015/02/12 02:09:36 Good point. I've update the logic to always create
294 switches::kEnableHostedAppShimCreation)) { 297 switches::kEnableHostedAppShimCreation)) {
295 app_type_requires_shortcut = 298 app_type_requires_shortcut =
296 app_type_requires_shortcut || extension->is_hosted_app(); 299 app_type_requires_shortcut && !extension->is_hosted_app();
297 } 300 }
298 #endif 301 #endif
299 302
300 return (app_type_requires_shortcut && 303 return (app_type_requires_shortcut &&
301 extension->location() != extensions::Manifest::COMPONENT && 304 extension->location() != extensions::Manifest::COMPONENT &&
302 extensions::ui_util::CanDisplayInAppLauncher(extension, profile)); 305 extensions::ui_util::CanDisplayInAppLauncher(extension, profile));
303 } 306 }
304 307
305 base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path, 308 base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path,
306 const std::string& extension_id, 309 const std::string& extension_id,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 ScheduleCreatePlatformShortcut(SHORTCUT_CREATION_AUTOMATED, locations, 403 ScheduleCreatePlatformShortcut(SHORTCUT_CREATION_AUTOMATED, locations,
401 shortcut_info, extensions::FileHandlersInfo()); 404 shortcut_info, extensions::FileHandlersInfo());
402 } 405 }
403 406
404 void CreateShortcuts(ShortcutCreationReason reason, 407 void CreateShortcuts(ShortcutCreationReason reason,
405 const ShortcutLocations& locations, 408 const ShortcutLocations& locations,
406 Profile* profile, 409 Profile* profile,
407 const extensions::Extension* app) { 410 const extensions::Extension* app) {
408 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 411 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
409 412
410 if (!ShouldCreateShortcutFor(profile, app)) 413 if (!ShouldCreateShortcutFor(reason, profile, app))
411 return; 414 return;
412 415
413 GetInfoForApp( 416 GetInfoForApp(
414 app, profile, base::Bind(&CreateShortcutsWithInfo, reason, locations)); 417 app, profile, base::Bind(&CreateShortcutsWithInfo, reason, locations));
415 } 418 }
416 419
417 void DeleteAllShortcuts(Profile* profile, const extensions::Extension* app) { 420 void DeleteAllShortcuts(Profile* profile, const extensions::Extension* app) {
418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 421 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
419 422
420 ShortcutInfo shortcut_info = 423 ShortcutInfo shortcut_info =
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 476
474 #if defined(OS_LINUX) 477 #if defined(OS_LINUX)
475 std::string GetWMClassFromAppName(std::string app_name) { 478 std::string GetWMClassFromAppName(std::string app_name) {
476 base::i18n::ReplaceIllegalCharactersInPath(&app_name, '_'); 479 base::i18n::ReplaceIllegalCharactersInPath(&app_name, '_');
477 base::TrimString(app_name, "_", &app_name); 480 base::TrimString(app_name, "_", &app_name);
478 return app_name; 481 return app_name;
479 } 482 }
480 #endif 483 #endif
481 484
482 } // namespace web_app 485 } // namespace web_app
OLDNEW
« no previous file with comments | « chrome/browser/extensions/bookmark_app_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698