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

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

Issue 907473002: Polish UI of bookmark app creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix another whoopsie 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 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"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/extensions/crx_installer.h" 12 #include "chrome/browser/extensions/crx_installer.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/favicon_downloader.h" 14 #include "chrome/browser/extensions/favicon_downloader.h"
15 #include "chrome/browser/extensions/launch_util.h" 15 #include "chrome/browser/extensions/launch_util.h"
16 #include "chrome/browser/extensions/tab_helper.h" 16 #include "chrome/browser/extensions/tab_helper.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/app_list/app_list_service.h" 18 #include "chrome/browser/ui/app_list/app_list_service.h"
19 #include "chrome/browser/ui/app_list/app_list_util.h" 19 #include "chrome/browser/ui/app_list/app_list_util.h"
20 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
22 #include "chrome/browser/ui/host_desktop.h" 22 #include "chrome/browser/ui/host_desktop.h"
23 #include "chrome/browser/web_applications/web_app.h"
23 #include "chrome/common/extensions/extension_constants.h" 24 #include "chrome/common/extensions/extension_constants.h"
24 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 25 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
25 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
26 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/notification_source.h" 28 #include "content/public/browser/notification_source.h"
28 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
29 #include "extensions/browser/extension_system.h" 30 #include "extensions/browser/extension_system.h"
30 #include "extensions/browser/image_loader.h" 31 #include "extensions/browser/image_loader.h"
31 #include "extensions/browser/notification_types.h" 32 #include "extensions/browser/notification_types.h"
32 #include "extensions/browser/pref_names.h" 33 #include "extensions/browser/pref_names.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 return; 413 return;
413 } 414 }
414 415
415 Browser* browser = chrome::FindBrowserWithWebContents(contents_); 416 Browser* browser = chrome::FindBrowserWithWebContents(contents_);
416 if (!browser) { 417 if (!browser) {
417 // The browser can be null in tests. 418 // The browser can be null in tests.
418 callback_.Run(extension, web_app_info_); 419 callback_.Run(extension, web_app_info_);
419 return; 420 return;
420 } 421 }
421 422
422 // Pin the app to the shelf on Ash. 423 // Pin the app to the shelf on Ash, or the taskbar / dock on Windows /
424 // Mac.
sashab 2015/02/06 15:35:44 nit: "Pin the app to the shelf/taskbar/dock on Ash
benwells 2015/02/06 15:52:17 Done.
425 Profile* current_profile = profile_->GetOriginalProfile();
423 chrome::HostDesktopType desktop = browser->host_desktop_type(); 426 chrome::HostDesktopType desktop = browser->host_desktop_type();
427 if (desktop != chrome::HOST_DESKTOP_TYPE_ASH) {
428 web_app::ShortcutLocations creation_locations;
429 #if defined(OS_LINUX)
430 creation_locations.on_desktop = true;
431 #else
432 creation_locations.on_desktop = false;
433 #endif
434 creation_locations.applications_menu_location =
435 web_app::APP_MENU_LOCATION_HIDDEN;
436 creation_locations.in_quick_launch_bar = true;
437 web_app::CreateShortcuts(web_app::SHORTCUT_CREATION_BY_USER,
438 creation_locations, current_profile, extension);
424 #if defined(USE_ASH) 439 #if defined(USE_ASH)
425 if (desktop == chrome::HOST_DESKTOP_TYPE_ASH) 440 } else {
426 ChromeLauncherController::instance()->PinAppWithID(extension->id()); 441 ChromeLauncherController::instance()->PinAppWithID(extension->id());
427 #endif 442 #endif
443 }
428 444
429 // Show the newly installed app in the app launcher, in finder (on Mac) or 445 // Show the newly installed app in the app launcher, in finder (on Mac) or
430 // chrome://apps. 446 // chrome://apps.
431 Profile* current_profile = profile_->GetOriginalProfile();
432 if (IsAppLauncherEnabled()) { 447 if (IsAppLauncherEnabled()) {
433 AppListService::Get(desktop) 448 AppListService::Get(desktop)
434 ->ShowForAppInstall(current_profile, extension->id(), false); 449 ->ShowForAppInstall(current_profile, extension->id(), false);
435 #if defined(OS_MACOSX) 450 #if defined(OS_MACOSX)
436 } else if (base::CommandLine::ForCurrentProcess()->HasSwitch( 451 } else if (base::CommandLine::ForCurrentProcess()->HasSwitch(
437 switches::kEnableHostedAppShimCreation)) { 452 switches::kEnableHostedAppShimCreation)) {
438 web_app::RevealAppShimInFinderForApp(profile_, extension); 453 web_app::RevealAppShimInFinderForApp(profile_, extension);
439 #endif 454 #endif
440 } else { 455 } else {
441 chrome::NavigateParams params(current_profile, 456 chrome::NavigateParams params(current_profile,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); 538 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback));
524 } 539 }
525 540
526 bool IsValidBookmarkAppUrl(const GURL& url) { 541 bool IsValidBookmarkAppUrl(const GURL& url) {
527 URLPattern origin_only_pattern(Extension::kValidWebExtentSchemes); 542 URLPattern origin_only_pattern(Extension::kValidWebExtentSchemes);
528 origin_only_pattern.SetMatchAllURLs(true); 543 origin_only_pattern.SetMatchAllURLs(true);
529 return url.is_valid() && origin_only_pattern.MatchesURL(url); 544 return url.is_valid() && origin_only_pattern.MatchesURL(url);
530 } 545 }
531 546
532 } // namespace extensions 547 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698