Chromium Code Reviews| Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc |
| diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc |
| index 6abf1534333ba31360b992c4dbf78c094993d6ad..bea8786e95d24137195919467dfb4562a835c62e 100644 |
| --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc |
| +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc |
| @@ -41,6 +41,7 @@ |
| #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| #include "chrome/browser/ui/ash/app_sync_ui_state.h" |
| + |
|
tapted
2016/06/23 23:47:30
remove blank line
StarAZ
2016/06/24 14:15:17
Done.
|
| #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
| #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h" |
| @@ -53,6 +54,7 @@ |
| #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
| #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h" |
| #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" |
| +#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" |
| #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" |
| #include "chrome/browser/ui/ash/launcher/launcher_arc_app_updater.h" |
| #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
| @@ -486,7 +488,7 @@ bool ChromeLauncherControllerImpl::IsPlatformApp(ash::ShelfID id) { |
| return false; |
| std::string app_id = GetAppIDForShelfID(id); |
| - const Extension* extension = GetExtensionForAppID(app_id); |
| + const Extension* extension = GetExtensionForAppID(app_id, profile_); |
| // An extension can be synced / updated at any time and therefore not be |
| // available. |
| return extension ? extension->is_platform_app() : false; |
| @@ -521,7 +523,8 @@ void ChromeLauncherControllerImpl::ActivateApp(const std::string& app_id, |
| extensions::LaunchType ChromeLauncherControllerImpl::GetLaunchType( |
| ash::ShelfID id) { |
| - const Extension* extension = GetExtensionForAppID(GetAppIDForShelfID(id)); |
| + const Extension* extension = |
| + GetExtensionForAppID(GetAppIDForShelfID(id), profile_); |
| // An extension can be unloaded/updated/unavailable at any time. |
| if (!extension) |
| @@ -646,12 +649,6 @@ void ChromeLauncherControllerImpl::SetRefocusURLPatternForTest( |
| } |
| } |
| -const Extension* ChromeLauncherControllerImpl::GetExtensionForAppID( |
| - const std::string& app_id) const { |
| - return extensions::ExtensionRegistry::Get(profile_)->GetExtensionById( |
| - app_id, extensions::ExtensionRegistry::EVERYTHING); |
| -} |
| - |
| ash::ShelfItemDelegate::PerformedAction |
| ChromeLauncherControllerImpl::ActivateWindowOrMinimizeIfActive( |
| ui::BaseWindow* window, |
| @@ -781,8 +778,8 @@ bool ChromeLauncherControllerImpl::ContentCanBeHandledByGmailApp( |
| // overlap with the offline app ("/mail/mu/"). |
| if (!base::MatchPattern(url.path(), "/mail/mu/*") && |
| base::MatchPattern(url.path(), "/mail/*") && |
| - GetExtensionForAppID(kGmailAppId) && |
| - GetExtensionForAppID(kGmailAppId)->OverlapsWithOrigin(url)) |
| + GetExtensionForAppID(kGmailAppId, profile_) && |
| + GetExtensionForAppID(kGmailAppId, profile_)->OverlapsWithOrigin(url)) |
| return true; |
| } |
| return false; |
| @@ -810,7 +807,8 @@ base::string16 ChromeLauncherControllerImpl::GetAppListTitle( |
| web_contents_to_app_id_.find(web_contents); |
| if (iter != web_contents_to_app_id_.end()) { |
| std::string app_id = iter->second; |
| - const extensions::Extension* extension = GetExtensionForAppID(app_id); |
| + const extensions::Extension* extension = |
| + GetExtensionForAppID(app_id, profile_); |
| if (extension) |
| return base::UTF8ToUTF16(extension->name()); |
| } |
| @@ -852,15 +850,6 @@ LauncherItemController* ChromeLauncherControllerImpl::GetLauncherItemController( |
| return id_to_item_controller_map_[id]; |
| } |
| -bool ChromeLauncherControllerImpl::IsBrowserFromActiveUser(Browser* browser) { |
| - // If running multi user mode with separate desktops, we have to check if the |
| - // browser is from the active user. |
| - if (chrome::MultiUserWindowManager::GetMultiProfileMode() != |
| - chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) |
| - return true; |
| - return multi_user_util::IsProfileFromActiveUser(browser->profile()); |
| -} |
| - |
| bool ChromeLauncherControllerImpl::ShelfBoundsChangesProbablyWithUser( |
| ash::Shelf* shelf, |
| const std::string& user_id) const { |
| @@ -893,42 +882,6 @@ void ChromeLauncherControllerImpl::OnUserProfileReadyToSwitch( |
| user_switch_observer_->OnUserProfileReadyToSwitch(profile); |
| } |
| -AppListControllerDelegate::Pinnable ChromeLauncherControllerImpl::GetPinnable( |
| - const std::string& app_id) { |
| - const base::ListValue* pref = |
| - profile_->GetPrefs()->GetList(prefs::kPolicyPinnedLauncherApps); |
| - if (!pref) |
| - return AppListControllerDelegate::PIN_EDITABLE; |
| - |
| - // Pinned ARC apps policy defines the package name of the apps, that must |
| - // be pinned. All the launch activities of any package in policy are pinned. |
| - // In turn the input parameter to this function is app_id, which |
| - // is 32 chars hash. In case of ARC app this is a hash of |
| - // (package name + activity). This means that we must identify the package |
| - // from the hash, and check if this package is pinned by policy. |
| - const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(GetProfile()); |
| - std::string arc_app_packege_name; |
| - if (arc_prefs) { |
| - std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = |
| - arc_prefs->GetApp(app_id); |
| - if (app_info) |
| - arc_app_packege_name = app_info->package_name; |
| - } |
| - |
| - for (size_t index = 0; index < pref->GetSize(); ++index) { |
| - const base::DictionaryValue* app = nullptr; |
| - std::string app_id_or_package; |
| - if (pref->GetDictionary(index, &app) && |
| - app->GetString(ash::launcher::kPinnedAppsPrefAppIDPath, |
| - &app_id_or_package) && |
| - (app_id == app_id_or_package || |
| - arc_app_packege_name == app_id_or_package)) { |
| - return AppListControllerDelegate::PIN_FIXED; |
| - } |
| - } |
| - return AppListControllerDelegate::PIN_EDITABLE; |
| -} |
| - |
| ArcAppDeferredLauncherController* |
| ChromeLauncherControllerImpl::GetArcDeferredLauncher() { |
| return arc_deferred_launcher_.get(); |
| @@ -994,7 +947,8 @@ const std::string& ChromeLauncherControllerImpl::GetAppIDForShelfID( |
| } |
| void ChromeLauncherControllerImpl::PinAppWithID(const std::string& app_id) { |
| - if (GetPinnable(app_id) == AppListControllerDelegate::PIN_EDITABLE) |
| + if (GetPinnableForAppID(app_id, profile_) == |
| + AppListControllerDelegate::PIN_EDITABLE) |
| DoPinAppWithID(app_id); |
| else |
| NOTREACHED(); |
| @@ -1011,7 +965,8 @@ bool ChromeLauncherControllerImpl::IsAppPinned(const std::string& app_id) { |
| } |
| void ChromeLauncherControllerImpl::UnpinAppWithID(const std::string& app_id) { |
| - if (GetPinnable(app_id) == AppListControllerDelegate::PIN_EDITABLE) |
| + if (GetPinnableForAppID(app_id, profile_) == |
| + AppListControllerDelegate::PIN_EDITABLE) |
| DoUnpinAppWithID(app_id); |
| else |
| NOTREACHED(); |