| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/ash/launcher/chrome_launcher_controller_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "chrome/browser/extensions/extension_util.h" | 34 #include "chrome/browser/extensions/extension_util.h" |
| 35 #include "chrome/browser/extensions/launch_util.h" | 35 #include "chrome/browser/extensions/launch_util.h" |
| 36 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 36 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 37 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
| 38 #include "chrome/browser/profiles/profile_manager.h" | 38 #include "chrome/browser/profiles/profile_manager.h" |
| 39 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" | 39 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
| 40 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h" | 40 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h" |
| 41 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 41 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 42 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 42 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 43 #include "chrome/browser/ui/ash/app_sync_ui_state.h" | 43 #include "chrome/browser/ui/ash/app_sync_ui_state.h" |
| 44 |
| 44 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 45 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| 45 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 46 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
| 46 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" | 47 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" |
| 47 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" | 48 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" |
| 48 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" | 49 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" |
| 49 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" | 50 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
| 50 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" | 51 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
| 51 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" | 52 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" |
| 52 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" | 53 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" |
| 53 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 54 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
| 54 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h
" | 55 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h
" |
| 55 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" | 56 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" |
| 57 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" |
| 56 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" | 58 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" |
| 57 #include "chrome/browser/ui/ash/launcher/launcher_arc_app_updater.h" | 59 #include "chrome/browser/ui/ash/launcher/launcher_arc_app_updater.h" |
| 58 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 60 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
| 59 #include "chrome/browser/ui/ash/launcher/launcher_extension_app_updater.h" | 61 #include "chrome/browser/ui/ash/launcher/launcher_extension_app_updater.h" |
| 60 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 62 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 61 #include "chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_contr
oller.h" | 63 #include "chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_contr
oller.h" |
| 62 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h" | 64 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h" |
| 63 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 65 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 64 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 66 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 65 #include "chrome/browser/ui/browser.h" | 67 #include "chrome/browser/ui/browser.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 if (!controller) | 481 if (!controller) |
| 480 return false; | 482 return false; |
| 481 return controller->IsOpen(); | 483 return controller->IsOpen(); |
| 482 } | 484 } |
| 483 | 485 |
| 484 bool ChromeLauncherControllerImpl::IsPlatformApp(ash::ShelfID id) { | 486 bool ChromeLauncherControllerImpl::IsPlatformApp(ash::ShelfID id) { |
| 485 if (!HasShelfIDToAppIDMapping(id)) | 487 if (!HasShelfIDToAppIDMapping(id)) |
| 486 return false; | 488 return false; |
| 487 | 489 |
| 488 std::string app_id = GetAppIDForShelfID(id); | 490 std::string app_id = GetAppIDForShelfID(id); |
| 489 const Extension* extension = GetExtensionForAppID(app_id); | 491 const Extension* extension = |
| 492 chrome::util::GetExtensionForAppID(profile_, app_id); |
| 490 // An extension can be synced / updated at any time and therefore not be | 493 // An extension can be synced / updated at any time and therefore not be |
| 491 // available. | 494 // available. |
| 492 return extension ? extension->is_platform_app() : false; | 495 return extension ? extension->is_platform_app() : false; |
| 493 } | 496 } |
| 494 | 497 |
| 495 void ChromeLauncherControllerImpl::LaunchApp(const std::string& app_id, | 498 void ChromeLauncherControllerImpl::LaunchApp(const std::string& app_id, |
| 496 ash::LaunchSource source, | 499 ash::LaunchSource source, |
| 497 int event_flags) { | 500 int event_flags) { |
| 498 launcher_controller_helper_->LaunchApp(app_id, source, event_flags); | 501 launcher_controller_helper_->LaunchApp(app_id, source, event_flags); |
| 499 } | 502 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 514 std::unique_ptr<AppShortcutLauncherItemController> app_controller( | 517 std::unique_ptr<AppShortcutLauncherItemController> app_controller( |
| 515 AppShortcutLauncherItemController::Create(app_id, this)); | 518 AppShortcutLauncherItemController::Create(app_id, this)); |
| 516 if (!app_controller->GetRunningApplications().empty()) | 519 if (!app_controller->GetRunningApplications().empty()) |
| 517 app_controller->Activate(source); | 520 app_controller->Activate(source); |
| 518 else | 521 else |
| 519 LaunchApp(app_id, source, event_flags); | 522 LaunchApp(app_id, source, event_flags); |
| 520 } | 523 } |
| 521 | 524 |
| 522 extensions::LaunchType ChromeLauncherControllerImpl::GetLaunchType( | 525 extensions::LaunchType ChromeLauncherControllerImpl::GetLaunchType( |
| 523 ash::ShelfID id) { | 526 ash::ShelfID id) { |
| 524 const Extension* extension = GetExtensionForAppID(GetAppIDForShelfID(id)); | 527 const Extension* extension = |
| 528 chrome::util::GetExtensionForAppID(profile_, GetAppIDForShelfID(id)); |
| 525 | 529 |
| 526 // An extension can be unloaded/updated/unavailable at any time. | 530 // An extension can be unloaded/updated/unavailable at any time. |
| 527 if (!extension) | 531 if (!extension) |
| 528 return extensions::LAUNCH_TYPE_DEFAULT; | 532 return extensions::LAUNCH_TYPE_DEFAULT; |
| 529 | 533 |
| 530 return extensions::GetLaunchType(extensions::ExtensionPrefs::Get(profile_), | 534 return extensions::GetLaunchType(extensions::ExtensionPrefs::Get(profile_), |
| 531 extension); | 535 extension); |
| 532 } | 536 } |
| 533 | 537 |
| 534 void ChromeLauncherControllerImpl::SetLauncherItemImage( | 538 void ChromeLauncherControllerImpl::SetLauncherItemImage( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 ash::ShelfItemType type = model_->items()[index].type; | 643 ash::ShelfItemType type = model_->items()[index].type; |
| 640 if (type == ash::TYPE_APP_SHORTCUT || type == ash::TYPE_WINDOWED_APP) { | 644 if (type == ash::TYPE_APP_SHORTCUT || type == ash::TYPE_WINDOWED_APP) { |
| 641 AppShortcutLauncherItemController* app_controller = | 645 AppShortcutLauncherItemController* app_controller = |
| 642 static_cast<AppShortcutLauncherItemController*>(controller); | 646 static_cast<AppShortcutLauncherItemController*>(controller); |
| 643 app_controller->set_refocus_url(url); | 647 app_controller->set_refocus_url(url); |
| 644 } else { | 648 } else { |
| 645 NOTREACHED() << "Invalid launcher type"; | 649 NOTREACHED() << "Invalid launcher type"; |
| 646 } | 650 } |
| 647 } | 651 } |
| 648 | 652 |
| 649 const Extension* ChromeLauncherControllerImpl::GetExtensionForAppID( | |
| 650 const std::string& app_id) const { | |
| 651 return extensions::ExtensionRegistry::Get(profile_)->GetExtensionById( | |
| 652 app_id, extensions::ExtensionRegistry::EVERYTHING); | |
| 653 } | |
| 654 | |
| 655 ash::ShelfItemDelegate::PerformedAction | 653 ash::ShelfItemDelegate::PerformedAction |
| 656 ChromeLauncherControllerImpl::ActivateWindowOrMinimizeIfActive( | 654 ChromeLauncherControllerImpl::ActivateWindowOrMinimizeIfActive( |
| 657 ui::BaseWindow* window, | 655 ui::BaseWindow* window, |
| 658 bool allow_minimize) { | 656 bool allow_minimize) { |
| 659 // In separated desktop mode we might have to teleport a window back to the | 657 // In separated desktop mode we might have to teleport a window back to the |
| 660 // current user. | 658 // current user. |
| 661 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == | 659 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == |
| 662 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { | 660 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { |
| 663 aura::Window* native_window = window->GetNativeWindow(); | 661 aura::Window* native_window = window->GetNativeWindow(); |
| 664 const AccountId& current_account_id = | 662 const AccountId& current_account_id = |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 bool ChromeLauncherControllerImpl::ContentCanBeHandledByGmailApp( | 772 bool ChromeLauncherControllerImpl::ContentCanBeHandledByGmailApp( |
| 775 content::WebContents* web_contents) { | 773 content::WebContents* web_contents) { |
| 776 ash::ShelfID id = GetShelfIDForAppID(kGmailAppId); | 774 ash::ShelfID id = GetShelfIDForAppID(kGmailAppId); |
| 777 if (id) { | 775 if (id) { |
| 778 const GURL url = web_contents->GetURL(); | 776 const GURL url = web_contents->GetURL(); |
| 779 // We need to extend the application matching for the gMail app beyond the | 777 // We need to extend the application matching for the gMail app beyond the |
| 780 // manifest file's specification. This is required because of the namespace | 778 // manifest file's specification. This is required because of the namespace |
| 781 // overlap with the offline app ("/mail/mu/"). | 779 // overlap with the offline app ("/mail/mu/"). |
| 782 if (!base::MatchPattern(url.path(), "/mail/mu/*") && | 780 if (!base::MatchPattern(url.path(), "/mail/mu/*") && |
| 783 base::MatchPattern(url.path(), "/mail/*") && | 781 base::MatchPattern(url.path(), "/mail/*") && |
| 784 GetExtensionForAppID(kGmailAppId) && | 782 chrome::util::GetExtensionForAppID(profile_, kGmailAppId) && |
| 785 GetExtensionForAppID(kGmailAppId)->OverlapsWithOrigin(url)) | 783 chrome::util::GetExtensionForAppID(profile_, kGmailAppId) |
| 784 ->OverlapsWithOrigin(url)) |
| 786 return true; | 785 return true; |
| 787 } | 786 } |
| 788 return false; | 787 return false; |
| 789 } | 788 } |
| 790 | 789 |
| 791 gfx::Image ChromeLauncherControllerImpl::GetAppListIcon( | 790 gfx::Image ChromeLauncherControllerImpl::GetAppListIcon( |
| 792 content::WebContents* web_contents) const { | 791 content::WebContents* web_contents) const { |
| 793 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 792 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 794 if (IsIncognito(web_contents)) | 793 if (IsIncognito(web_contents)) |
| 795 return rb.GetImageNamed(IDR_ASH_SHELF_LIST_INCOGNITO_BROWSER); | 794 return rb.GetImageNamed(IDR_ASH_SHELF_LIST_INCOGNITO_BROWSER); |
| 796 favicon::FaviconDriver* favicon_driver = | 795 favicon::FaviconDriver* favicon_driver = |
| 797 favicon::ContentFaviconDriver::FromWebContents(web_contents); | 796 favicon::ContentFaviconDriver::FromWebContents(web_contents); |
| 798 gfx::Image result = favicon_driver->GetFavicon(); | 797 gfx::Image result = favicon_driver->GetFavicon(); |
| 799 if (result.IsEmpty()) | 798 if (result.IsEmpty()) |
| 800 return rb.GetImageNamed(IDR_DEFAULT_FAVICON); | 799 return rb.GetImageNamed(IDR_DEFAULT_FAVICON); |
| 801 return result; | 800 return result; |
| 802 } | 801 } |
| 803 | 802 |
| 804 base::string16 ChromeLauncherControllerImpl::GetAppListTitle( | 803 base::string16 ChromeLauncherControllerImpl::GetAppListTitle( |
| 805 content::WebContents* web_contents) const { | 804 content::WebContents* web_contents) const { |
| 806 base::string16 title = web_contents->GetTitle(); | 805 base::string16 title = web_contents->GetTitle(); |
| 807 if (!title.empty()) | 806 if (!title.empty()) |
| 808 return title; | 807 return title; |
| 809 WebContentsToAppIDMap::const_iterator iter = | 808 WebContentsToAppIDMap::const_iterator iter = |
| 810 web_contents_to_app_id_.find(web_contents); | 809 web_contents_to_app_id_.find(web_contents); |
| 811 if (iter != web_contents_to_app_id_.end()) { | 810 if (iter != web_contents_to_app_id_.end()) { |
| 812 std::string app_id = iter->second; | 811 std::string app_id = iter->second; |
| 813 const extensions::Extension* extension = GetExtensionForAppID(app_id); | 812 const extensions::Extension* extension = |
| 813 chrome::util::GetExtensionForAppID(profile_, app_id); |
| 814 if (extension) | 814 if (extension) |
| 815 return base::UTF8ToUTF16(extension->name()); | 815 return base::UTF8ToUTF16(extension->name()); |
| 816 } | 816 } |
| 817 return l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); | 817 return l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); |
| 818 } | 818 } |
| 819 | 819 |
| 820 BrowserShortcutLauncherItemController* | 820 BrowserShortcutLauncherItemController* |
| 821 ChromeLauncherControllerImpl::GetBrowserShortcutLauncherItemController() { | 821 ChromeLauncherControllerImpl::GetBrowserShortcutLauncherItemController() { |
| 822 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin(); | 822 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin(); |
| 823 i != id_to_item_controller_map_.end(); ++i) { | 823 i != id_to_item_controller_map_.end(); ++i) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 845 } | 845 } |
| 846 } | 846 } |
| 847 | 847 |
| 848 LauncherItemController* ChromeLauncherControllerImpl::GetLauncherItemController( | 848 LauncherItemController* ChromeLauncherControllerImpl::GetLauncherItemController( |
| 849 const ash::ShelfID id) { | 849 const ash::ShelfID id) { |
| 850 if (!HasShelfIDToAppIDMapping(id)) | 850 if (!HasShelfIDToAppIDMapping(id)) |
| 851 return NULL; | 851 return NULL; |
| 852 return id_to_item_controller_map_[id]; | 852 return id_to_item_controller_map_[id]; |
| 853 } | 853 } |
| 854 | 854 |
| 855 bool ChromeLauncherControllerImpl::IsBrowserFromActiveUser(Browser* browser) { | |
| 856 // If running multi user mode with separate desktops, we have to check if the | |
| 857 // browser is from the active user. | |
| 858 if (chrome::MultiUserWindowManager::GetMultiProfileMode() != | |
| 859 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) | |
| 860 return true; | |
| 861 return multi_user_util::IsProfileFromActiveUser(browser->profile()); | |
| 862 } | |
| 863 | |
| 864 bool ChromeLauncherControllerImpl::ShelfBoundsChangesProbablyWithUser( | 855 bool ChromeLauncherControllerImpl::ShelfBoundsChangesProbablyWithUser( |
| 865 ash::Shelf* shelf, | 856 ash::Shelf* shelf, |
| 866 const std::string& user_id) const { | 857 const std::string& user_id) const { |
| 867 Profile* other_profile = multi_user_util::GetProfileFromAccountId( | 858 Profile* other_profile = multi_user_util::GetProfileFromAccountId( |
| 868 AccountId::FromUserEmail(user_id)); | 859 AccountId::FromUserEmail(user_id)); |
| 869 if (other_profile == profile_) | 860 if (other_profile == profile_) |
| 870 return false; | 861 return false; |
| 871 | 862 |
| 872 // Note: The Auto hide state from preferences is not the same as the actual | 863 // Note: The Auto hide state from preferences is not the same as the actual |
| 873 // visibility of the shelf. Depending on all the various states (full screen, | 864 // visibility of the shelf. Depending on all the various states (full screen, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 886 ash::launcher::GetShelfAlignmentPref(prefs, display) != | 877 ash::launcher::GetShelfAlignmentPref(prefs, display) != |
| 887 ash::launcher::GetShelfAlignmentPref(other_prefs, display); | 878 ash::launcher::GetShelfAlignmentPref(other_prefs, display); |
| 888 } | 879 } |
| 889 | 880 |
| 890 void ChromeLauncherControllerImpl::OnUserProfileReadyToSwitch( | 881 void ChromeLauncherControllerImpl::OnUserProfileReadyToSwitch( |
| 891 Profile* profile) { | 882 Profile* profile) { |
| 892 if (user_switch_observer_.get()) | 883 if (user_switch_observer_.get()) |
| 893 user_switch_observer_->OnUserProfileReadyToSwitch(profile); | 884 user_switch_observer_->OnUserProfileReadyToSwitch(profile); |
| 894 } | 885 } |
| 895 | 886 |
| 896 AppListControllerDelegate::Pinnable ChromeLauncherControllerImpl::GetPinnable( | |
| 897 const std::string& app_id) { | |
| 898 const base::ListValue* pref = | |
| 899 profile_->GetPrefs()->GetList(prefs::kPolicyPinnedLauncherApps); | |
| 900 if (!pref) | |
| 901 return AppListControllerDelegate::PIN_EDITABLE; | |
| 902 | |
| 903 // Pinned ARC apps policy defines the package name of the apps, that must | |
| 904 // be pinned. All the launch activities of any package in policy are pinned. | |
| 905 // In turn the input parameter to this function is app_id, which | |
| 906 // is 32 chars hash. In case of ARC app this is a hash of | |
| 907 // (package name + activity). This means that we must identify the package | |
| 908 // from the hash, and check if this package is pinned by policy. | |
| 909 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(GetProfile()); | |
| 910 std::string arc_app_packege_name; | |
| 911 if (arc_prefs) { | |
| 912 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = | |
| 913 arc_prefs->GetApp(app_id); | |
| 914 if (app_info) | |
| 915 arc_app_packege_name = app_info->package_name; | |
| 916 } | |
| 917 | |
| 918 for (size_t index = 0; index < pref->GetSize(); ++index) { | |
| 919 const base::DictionaryValue* app = nullptr; | |
| 920 std::string app_id_or_package; | |
| 921 if (pref->GetDictionary(index, &app) && | |
| 922 app->GetString(ash::launcher::kPinnedAppsPrefAppIDPath, | |
| 923 &app_id_or_package) && | |
| 924 (app_id == app_id_or_package || | |
| 925 arc_app_packege_name == app_id_or_package)) { | |
| 926 return AppListControllerDelegate::PIN_FIXED; | |
| 927 } | |
| 928 } | |
| 929 return AppListControllerDelegate::PIN_EDITABLE; | |
| 930 } | |
| 931 | |
| 932 ArcAppDeferredLauncherController* | 887 ArcAppDeferredLauncherController* |
| 933 ChromeLauncherControllerImpl::GetArcDeferredLauncher() { | 888 ChromeLauncherControllerImpl::GetArcDeferredLauncher() { |
| 934 return arc_deferred_launcher_.get(); | 889 return arc_deferred_launcher_.get(); |
| 935 } | 890 } |
| 936 | 891 |
| 937 /////////////////////////////////////////////////////////////////////////////// | 892 /////////////////////////////////////////////////////////////////////////////// |
| 938 // ash::ShelfDelegate: | 893 // ash::ShelfDelegate: |
| 939 | 894 |
| 940 void ChromeLauncherControllerImpl::OnShelfCreated(ash::Shelf* shelf) { | 895 void ChromeLauncherControllerImpl::OnShelfCreated(ash::Shelf* shelf) { |
| 941 PrefService* prefs = profile_->GetPrefs(); | 896 PrefService* prefs = profile_->GetPrefs(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 id_to_item_controller_map_.end(); | 942 id_to_item_controller_map_.end(); |
| 988 } | 943 } |
| 989 | 944 |
| 990 const std::string& ChromeLauncherControllerImpl::GetAppIDForShelfID( | 945 const std::string& ChromeLauncherControllerImpl::GetAppIDForShelfID( |
| 991 ash::ShelfID id) { | 946 ash::ShelfID id) { |
| 992 LauncherItemController* controller = GetLauncherItemController(id); | 947 LauncherItemController* controller = GetLauncherItemController(id); |
| 993 return controller ? controller->app_id() : base::EmptyString(); | 948 return controller ? controller->app_id() : base::EmptyString(); |
| 994 } | 949 } |
| 995 | 950 |
| 996 void ChromeLauncherControllerImpl::PinAppWithID(const std::string& app_id) { | 951 void ChromeLauncherControllerImpl::PinAppWithID(const std::string& app_id) { |
| 997 if (GetPinnable(app_id) == AppListControllerDelegate::PIN_EDITABLE) | 952 if (chrome::util::GetPinnable(profile_, app_id) == |
| 953 AppListControllerDelegate::PIN_EDITABLE) |
| 998 DoPinAppWithID(app_id); | 954 DoPinAppWithID(app_id); |
| 999 else | 955 else |
| 1000 NOTREACHED(); | 956 NOTREACHED(); |
| 1001 } | 957 } |
| 1002 | 958 |
| 1003 bool ChromeLauncherControllerImpl::IsAppPinned(const std::string& app_id) { | 959 bool ChromeLauncherControllerImpl::IsAppPinned(const std::string& app_id) { |
| 1004 for (IDToItemControllerMap::const_iterator i = | 960 for (IDToItemControllerMap::const_iterator i = |
| 1005 id_to_item_controller_map_.begin(); | 961 id_to_item_controller_map_.begin(); |
| 1006 i != id_to_item_controller_map_.end(); ++i) { | 962 i != id_to_item_controller_map_.end(); ++i) { |
| 1007 if (IsPinned(i->first) && i->second->app_id() == app_id) | 963 if (IsPinned(i->first) && i->second->app_id() == app_id) |
| 1008 return true; | 964 return true; |
| 1009 } | 965 } |
| 1010 return false; | 966 return false; |
| 1011 } | 967 } |
| 1012 | 968 |
| 1013 void ChromeLauncherControllerImpl::UnpinAppWithID(const std::string& app_id) { | 969 void ChromeLauncherControllerImpl::UnpinAppWithID(const std::string& app_id) { |
| 1014 if (GetPinnable(app_id) == AppListControllerDelegate::PIN_EDITABLE) | 970 if (chrome::util::GetPinnable(profile_, app_id) == |
| 971 AppListControllerDelegate::PIN_EDITABLE) |
| 1015 DoUnpinAppWithID(app_id); | 972 DoUnpinAppWithID(app_id); |
| 1016 else | 973 else |
| 1017 NOTREACHED(); | 974 NOTREACHED(); |
| 1018 } | 975 } |
| 1019 | 976 |
| 1020 /////////////////////////////////////////////////////////////////////////////// | 977 /////////////////////////////////////////////////////////////////////////////// |
| 1021 // LauncherAppUpdater::Delegate: | 978 // LauncherAppUpdater::Delegate: |
| 1022 | 979 |
| 1023 void ChromeLauncherControllerImpl::OnAppInstalled( | 980 void ChromeLauncherControllerImpl::OnAppInstalled( |
| 1024 content::BrowserContext* browser_context, | 981 content::BrowserContext* browser_context, |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1752 if (index == -1) | 1709 if (index == -1) |
| 1753 continue; | 1710 continue; |
| 1754 ash::ShelfItem item = model_->items()[index]; | 1711 ash::ShelfItem item = model_->items()[index]; |
| 1755 item.image = image; | 1712 item.image = image; |
| 1756 if (arc_deferred_launcher_) | 1713 if (arc_deferred_launcher_) |
| 1757 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1714 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
| 1758 model_->Set(index, item); | 1715 model_->Set(index, item); |
| 1759 // It's possible we're waiting on more than one item, so don't break. | 1716 // It's possible we're waiting on more than one item, so don't break. |
| 1760 } | 1717 } |
| 1761 } | 1718 } |
| OLD | NEW |