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

Side by Side Diff: chrome/browser/extensions/bookmark_app_helper.cc

Issue 935893002: Don't show launcher or chrome://apps after adding a bookmark app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile on mac; incognito on mac 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 | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/extensions/bookmark_app_helper.h" 5 #include "chrome/browser/extensions/bookmark_app_helper.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 8
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 415
416 Browser* browser = chrome::FindBrowserWithWebContents(contents_); 416 Browser* browser = chrome::FindBrowserWithWebContents(contents_);
417 if (!browser) { 417 if (!browser) {
418 // The browser can be null in tests. 418 // The browser can be null in tests.
419 callback_.Run(extension, web_app_info_); 419 callback_.Run(extension, web_app_info_);
420 return; 420 return;
421 } 421 }
422 422
423 // Pin the app to the relevant launcher depending on the OS. 423 // Pin the app to the relevant launcher depending on the OS.
424 Profile* current_profile = profile_->GetOriginalProfile(); 424 Profile* current_profile = profile_->GetOriginalProfile();
425 chrome::HostDesktopType desktop = browser->host_desktop_type();
426 425
427 // On Mac, shortcuts are automatically created for hosted apps when they are 426 // On Mac, shortcuts are automatically created for hosted apps when they are
428 // installed, so there is no need to call this again." 427 // installed, so there is no need to create them again.
429 #if !defined(OS_MACOSX) 428 #if !defined(OS_MACOSX)
429 chrome::HostDesktopType desktop = browser->host_desktop_type();
430 if (desktop != chrome::HOST_DESKTOP_TYPE_ASH) { 430 if (desktop != chrome::HOST_DESKTOP_TYPE_ASH) {
431 web_app::ShortcutLocations creation_locations; 431 web_app::ShortcutLocations creation_locations;
432 #if defined(OS_LINUX) 432 #if defined(OS_LINUX)
433 creation_locations.on_desktop = true; 433 creation_locations.on_desktop = true;
434 #else 434 #else
435 creation_locations.on_desktop = false; 435 creation_locations.on_desktop = false;
436 #endif 436 #endif
437 creation_locations.applications_menu_location = 437 creation_locations.applications_menu_location =
438 web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS; 438 web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS;
439 creation_locations.in_quick_launch_bar = true; 439 creation_locations.in_quick_launch_bar = true;
440 web_app::CreateShortcuts(web_app::SHORTCUT_CREATION_BY_USER, 440 web_app::CreateShortcuts(web_app::SHORTCUT_CREATION_BY_USER,
441 creation_locations, current_profile, extension); 441 creation_locations, current_profile, extension);
442 #if defined(USE_ASH) 442 #if defined(USE_ASH)
443 } else { 443 } else {
444 ChromeLauncherController::instance()->PinAppWithID(extension->id()); 444 ChromeLauncherController::instance()->PinAppWithID(extension->id());
445 #endif 445 #endif
446 } 446 }
447 #endif 447 #endif
448 448
449 // Show the newly installed app in the app launcher, in finder (on Mac) or
450 // chrome://apps.
451 if (IsAppLauncherEnabled()) {
452 AppListService::Get(desktop)
453 ->ShowForAppInstall(current_profile, extension->id(), false);
454 #if defined(OS_MACOSX) 449 #if defined(OS_MACOSX)
455 } else if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 450 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
456 switches::kDisableHostedAppShimCreation)) { 451 switches::kDisableHostedAppShimCreation)) {
457 web_app::RevealAppShimInFinderForApp(profile_, extension); 452 web_app::RevealAppShimInFinderForApp(current_profile, extension);
453 }
458 #endif 454 #endif
459 } else {
460 chrome::NavigateParams params(current_profile,
461 GURL(chrome::kChromeUIAppsURL),
462 ui::PAGE_TRANSITION_LINK);
463 params.disposition = SINGLETON_TAB;
464 chrome::Navigate(&params);
465
466 content::NotificationService::current()->Notify(
467 chrome::NOTIFICATION_APP_INSTALLED_TO_NTP,
468 content::Source<content::WebContents>(params.target_contents),
469 content::Details<const std::string>(&extension->id()));
470 }
471 455
472 callback_.Run(extension, web_app_info_); 456 callback_.Run(extension, web_app_info_);
473 } 457 }
474 458
475 void BookmarkAppHelper::Observe(int type, 459 void BookmarkAppHelper::Observe(int type,
476 const content::NotificationSource& source, 460 const content::NotificationSource& source,
477 const content::NotificationDetails& details) { 461 const content::NotificationDetails& details) {
478 switch (type) { 462 switch (type) {
479 case extensions::NOTIFICATION_CRX_INSTALLER_DONE: { 463 case extensions::NOTIFICATION_CRX_INSTALLER_DONE: {
480 const Extension* extension = 464 const Extension* extension =
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); 526 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback));
543 } 527 }
544 528
545 bool IsValidBookmarkAppUrl(const GURL& url) { 529 bool IsValidBookmarkAppUrl(const GURL& url) {
546 URLPattern origin_only_pattern(Extension::kValidWebExtentSchemes); 530 URLPattern origin_only_pattern(Extension::kValidWebExtentSchemes);
547 origin_only_pattern.SetMatchAllURLs(true); 531 origin_only_pattern.SetMatchAllURLs(true);
548 return url.is_valid() && origin_only_pattern.MatchesURL(url); 532 return url.is_valid() && origin_only_pattern.MatchesURL(url);
549 } 533 }
550 534
551 } // namespace extensions 535 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698