| Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
|
| diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
|
| similarity index 85%
|
| copy from chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
|
| copy to chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
|
| index 2c242238c3361af122a34588b0f2a8b9d8ecb3c2..468e7dfc5f7094ebe2546718044e231e1a8078c7 100644
|
| --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
|
| +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
|
| +#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
|
|
|
| #include <stddef.h>
|
|
|
| @@ -105,9 +105,6 @@ using extensions::UnloadedExtensionInfo;
|
| using extension_misc::kGmailAppId;
|
| using content::WebContents;
|
|
|
| -// static
|
| -ChromeLauncherController* ChromeLauncherController::instance_ = NULL;
|
| -
|
| namespace {
|
|
|
| int64_t GetDisplayIDForShelf(ash::Shelf* shelf) {
|
| @@ -181,7 +178,7 @@ class ChromeLauncherControllerUserSwitchObserver
|
| : public user_manager::UserManager::UserSessionStateObserver {
|
| public:
|
| ChromeLauncherControllerUserSwitchObserver(
|
| - ChromeLauncherController* controller)
|
| + ChromeLauncherControllerImpl* controller)
|
| : controller_(controller) {
|
| DCHECK(user_manager::UserManager::IsInitialized());
|
| user_manager::UserManager::Get()->AddSessionStateObserver(this);
|
| @@ -200,8 +197,8 @@ class ChromeLauncherControllerUserSwitchObserver
|
| // Add a user to the session.
|
| void AddUser(Profile* profile);
|
|
|
| - // The owning ChromeLauncherController.
|
| - ChromeLauncherController* controller_;
|
| + // The owning ChromeLauncherControllerImpl.
|
| + ChromeLauncherControllerImpl* controller_;
|
|
|
| // Users which were just added to the system, but which profiles were not yet
|
| // (fully) loaded.
|
| @@ -228,10 +225,9 @@ void ChromeLauncherControllerUserSwitchObserver::OnUserProfileReadyToSwitch(
|
| // Check if the profile is from a user which was on the waiting list.
|
| std::string user_id =
|
| multi_user_util::GetAccountIdFromProfile(profile).GetUserEmail();
|
| - std::set<std::string>::iterator it = std::find(
|
| - added_user_ids_waiting_for_profiles_.begin(),
|
| - added_user_ids_waiting_for_profiles_.end(),
|
| - user_id);
|
| + std::set<std::string>::iterator it =
|
| + std::find(added_user_ids_waiting_for_profiles_.begin(),
|
| + added_user_ids_waiting_for_profiles_.end(), user_id);
|
| if (it != added_user_ids_waiting_for_profiles_.end()) {
|
| added_user_ids_waiting_for_profiles_.erase(it);
|
| AddUser(profile->GetOriginalProfile());
|
| @@ -241,13 +237,14 @@ void ChromeLauncherControllerUserSwitchObserver::OnUserProfileReadyToSwitch(
|
|
|
| void ChromeLauncherControllerUserSwitchObserver::AddUser(Profile* profile) {
|
| if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
|
| - chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED)
|
| + chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED)
|
| chrome::MultiUserWindowManager::GetInstance()->AddUser(profile);
|
| controller_->AdditionalUserAddedToSession(profile->GetOriginalProfile());
|
| }
|
|
|
| -ChromeLauncherController::ChromeLauncherController(Profile* profile,
|
| - ash::ShelfModel* model)
|
| +ChromeLauncherControllerImpl::ChromeLauncherControllerImpl(
|
| + Profile* profile,
|
| + ash::ShelfModel* model)
|
| : model_(model),
|
| item_delegate_manager_(NULL),
|
| profile_(profile),
|
| @@ -283,7 +280,7 @@ ChromeLauncherController::ChromeLauncherController(Profile* profile,
|
| // On Chrome OS using multi profile we want to switch the content of the shelf
|
| // with a user change. Note that for unit tests the instance can be NULL.
|
| if (chrome::MultiUserWindowManager::GetMultiProfileMode() !=
|
| - chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_OFF) {
|
| + chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_OFF) {
|
| user_switch_observer_.reset(
|
| new ChromeLauncherControllerUserSwitchObserver(this));
|
| }
|
| @@ -292,7 +289,7 @@ ChromeLauncherController::ChromeLauncherController(Profile* profile,
|
| // Create our v1/v2 application / browser monitors which will inform the
|
| // launcher of status changes.
|
| if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
|
| - chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) {
|
| + chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) {
|
| // If running in separated destkop mode, we create the multi profile version
|
| // of status monitor.
|
| browser_status_monitor_.reset(new MultiProfileBrowserStatusMonitor(this));
|
| @@ -308,7 +305,8 @@ ChromeLauncherController::ChromeLauncherController(Profile* profile,
|
| app_window_controllers_.push_back(std::move(extension_app_window_controller));
|
|
|
| std::unique_ptr<AppWindowLauncherController> arc_app_window_controller;
|
| - arc_app_window_controller.reset(new ArcAppWindowLauncherController(this));
|
| + arc_app_window_controller.reset(
|
| + new ArcAppWindowLauncherController(this, this));
|
| app_window_controllers_.push_back(std::move(arc_app_window_controller));
|
|
|
| // Right now ash::Shell isn't created for tests.
|
| @@ -325,7 +323,7 @@ ChromeLauncherController::ChromeLauncherController(Profile* profile,
|
| }
|
| }
|
|
|
| -ChromeLauncherController::~ChromeLauncherController() {
|
| +ChromeLauncherControllerImpl::~ChromeLauncherControllerImpl() {
|
| if (item_delegate_manager_)
|
| item_delegate_manager_->RemoveObserver(this);
|
|
|
| @@ -350,25 +348,25 @@ ChromeLauncherController::~ChromeLauncherController() {
|
|
|
| // Release all profile dependent resources.
|
| ReleaseProfile();
|
| - if (instance_ == this)
|
| - instance_ = NULL;
|
|
|
| // Get rid of the multi user window manager instance.
|
| chrome::MultiUserWindowManager::DeleteInstance();
|
| }
|
|
|
| // static
|
| -ChromeLauncherController* ChromeLauncherController::CreateInstance(
|
| +ChromeLauncherControllerImpl* ChromeLauncherControllerImpl::CreateInstance(
|
| Profile* profile,
|
| ash::ShelfModel* model) {
|
| - // We do not check here for re-creation of the ChromeLauncherController since
|
| - // it appears that it might be intentional that the ChromeLauncherController
|
| - // can be re-created.
|
| - instance_ = new ChromeLauncherController(profile, model);
|
| - return instance_;
|
| + // We do not check here for re-creation of the ChromeLauncherControllerImpl
|
| + // since it appears that it might be intentional that
|
| + // ChromeLauncherControllerImpl can be re-created.
|
| + ChromeLauncherControllerImpl* instance =
|
| + new ChromeLauncherControllerImpl(profile, model);
|
| + ChromeLauncherController::set_instance(instance);
|
| + return instance;
|
| }
|
|
|
| -void ChromeLauncherController::Init() {
|
| +void ChromeLauncherControllerImpl::Init() {
|
| CreateBrowserShortcutLauncherItem();
|
| UpdateAppLaunchersFromPref();
|
|
|
| @@ -380,7 +378,7 @@ void ChromeLauncherController::Init() {
|
| ash::ChromeLauncherPrefsObserver::CreateIfNecessary(profile_);
|
| }
|
|
|
| -ash::ShelfID ChromeLauncherController::CreateAppLauncherItem(
|
| +ash::ShelfID ChromeLauncherControllerImpl::CreateAppLauncherItem(
|
| LauncherItemController* controller,
|
| const std::string& app_id,
|
| ash::ShelfItemStatus status) {
|
| @@ -389,15 +387,12 @@ ash::ShelfID ChromeLauncherController::CreateAppLauncherItem(
|
| // Panels are inserted on the left so as not to push all existing panels over.
|
| if (controller->GetShelfItemType() != ash::TYPE_APP_PANEL)
|
| index = model_->item_count();
|
| - return InsertAppLauncherItem(controller,
|
| - app_id,
|
| - status,
|
| - index,
|
| + return InsertAppLauncherItem(controller, app_id, status, index,
|
| controller->GetShelfItemType());
|
| }
|
|
|
| -void ChromeLauncherController::SetItemStatus(ash::ShelfID id,
|
| - ash::ShelfItemStatus status) {
|
| +void ChromeLauncherControllerImpl::SetItemStatus(ash::ShelfID id,
|
| + ash::ShelfItemStatus status) {
|
| int index = model_->ItemIndexByID(id);
|
| ash::ShelfItemStatus old_status = model_->items()[index].status;
|
| // Since ordinary browser windows are not registered, we might get a negative
|
| @@ -409,7 +404,7 @@ void ChromeLauncherController::SetItemStatus(ash::ShelfID id,
|
| }
|
| }
|
|
|
| -void ChromeLauncherController::SetItemController(
|
| +void ChromeLauncherControllerImpl::SetItemController(
|
| ash::ShelfID id,
|
| LauncherItemController* controller) {
|
| CHECK(controller);
|
| @@ -421,7 +416,7 @@ void ChromeLauncherController::SetItemController(
|
| SetShelfItemDelegate(id, controller);
|
| }
|
|
|
| -void ChromeLauncherController::CloseLauncherItem(ash::ShelfID id) {
|
| +void ChromeLauncherControllerImpl::CloseLauncherItem(ash::ShelfID id) {
|
| CHECK(id);
|
| if (IsPinned(id)) {
|
| // Create a new shortcut controller.
|
| @@ -438,7 +433,7 @@ void ChromeLauncherController::CloseLauncherItem(ash::ShelfID id) {
|
| }
|
| }
|
|
|
| -AppListControllerDelegate::Pinnable ChromeLauncherController::GetPinnable(
|
| +AppListControllerDelegate::Pinnable ChromeLauncherControllerImpl::GetPinnable(
|
| const std::string& app_id) {
|
| for (size_t i = 0; i < kPinProhibitedExtensionIdsLength; ++i) {
|
| if (kPinProhibitedExtensionIds[i] == app_id)
|
| @@ -456,7 +451,7 @@ AppListControllerDelegate::Pinnable ChromeLauncherController::GetPinnable(
|
| // 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(profile());
|
| + const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(GetProfile());
|
| std::string arc_app_packege_name;
|
| if (arc_prefs) {
|
| std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
|
| @@ -478,7 +473,7 @@ AppListControllerDelegate::Pinnable ChromeLauncherController::GetPinnable(
|
| return AppListControllerDelegate::PIN_EDITABLE;
|
| }
|
|
|
| -void ChromeLauncherController::Pin(ash::ShelfID id) {
|
| +void ChromeLauncherControllerImpl::Pin(ash::ShelfID id) {
|
| DCHECK(HasShelfIDToAppIDMapping(id));
|
|
|
| int index = model_->ItemIndexByID(id);
|
| @@ -498,7 +493,7 @@ void ChromeLauncherController::Pin(ash::ShelfID id) {
|
| PersistPinnedState();
|
| }
|
|
|
| -void ChromeLauncherController::Unpin(ash::ShelfID id) {
|
| +void ChromeLauncherControllerImpl::Unpin(ash::ShelfID id) {
|
| LauncherItemController* controller = GetLauncherItemController(id);
|
| CHECK(controller);
|
| const bool can_pin = controller->CanPin();
|
| @@ -513,7 +508,7 @@ void ChromeLauncherController::Unpin(ash::ShelfID id) {
|
| PersistPinnedState();
|
| }
|
|
|
| -bool ChromeLauncherController::IsPinned(ash::ShelfID id) {
|
| +bool ChromeLauncherControllerImpl::IsPinned(ash::ShelfID id) {
|
| int index = model_->ItemIndexByID(id);
|
| if (index < 0)
|
| return false;
|
| @@ -521,7 +516,7 @@ bool ChromeLauncherController::IsPinned(ash::ShelfID id) {
|
| return (type == ash::TYPE_APP_SHORTCUT || type == ash::TYPE_BROWSER_SHORTCUT);
|
| }
|
|
|
| -void ChromeLauncherController::TogglePinned(ash::ShelfID id) {
|
| +void ChromeLauncherControllerImpl::TogglePinned(ash::ShelfID id) {
|
| if (!HasShelfIDToAppIDMapping(id))
|
| return; // May happen if item closed with menu open.
|
|
|
| @@ -531,7 +526,7 @@ void ChromeLauncherController::TogglePinned(ash::ShelfID id) {
|
| Pin(id);
|
| }
|
|
|
| -bool ChromeLauncherController::IsPinnable(ash::ShelfID id) const {
|
| +bool ChromeLauncherControllerImpl::IsPinnable(ash::ShelfID id) const {
|
| int index = model_->ItemIndexByID(id);
|
| if (index == -1)
|
| return false;
|
| @@ -543,11 +538,10 @@ bool ChromeLauncherController::IsPinnable(ash::ShelfID id) const {
|
| item_delegate_manager_->GetShelfItemDelegate(id)->CanPin());
|
| }
|
|
|
| -void ChromeLauncherController::LockV1AppWithID(const std::string& app_id) {
|
| +void ChromeLauncherControllerImpl::LockV1AppWithID(const std::string& app_id) {
|
| ash::ShelfID id = GetShelfIDForAppID(app_id);
|
| if (!IsPinned(id) && !IsWindowedAppInLauncher(app_id)) {
|
| - CreateAppShortcutLauncherItemWithType(app_id,
|
| - model_->item_count(),
|
| + CreateAppShortcutLauncherItemWithType(app_id, model_->item_count(),
|
| ash::TYPE_WINDOWED_APP);
|
| id = GetShelfIDForAppID(app_id);
|
| }
|
| @@ -555,7 +549,8 @@ void ChromeLauncherController::LockV1AppWithID(const std::string& app_id) {
|
| id_to_item_controller_map_[id]->lock();
|
| }
|
|
|
| -void ChromeLauncherController::UnlockV1AppWithID(const std::string& app_id) {
|
| +void ChromeLauncherControllerImpl::UnlockV1AppWithID(
|
| + const std::string& app_id) {
|
| ash::ShelfID id = GetShelfIDForAppID(app_id);
|
| CHECK(id);
|
| CHECK(IsPinned(id) || IsWindowedAppInLauncher(app_id));
|
| @@ -565,28 +560,28 @@ void ChromeLauncherController::UnlockV1AppWithID(const std::string& app_id) {
|
| CloseLauncherItem(id);
|
| }
|
|
|
| -void ChromeLauncherController::Launch(ash::ShelfID id, int event_flags) {
|
| +void ChromeLauncherControllerImpl::Launch(ash::ShelfID id, int event_flags) {
|
| LauncherItemController* controller = GetLauncherItemController(id);
|
| if (!controller)
|
| return; // In case invoked from menu and item closed while menu up.
|
| controller->Launch(ash::LAUNCH_FROM_UNKNOWN, event_flags);
|
| }
|
|
|
| -void ChromeLauncherController::Close(ash::ShelfID id) {
|
| +void ChromeLauncherControllerImpl::Close(ash::ShelfID id) {
|
| LauncherItemController* controller = GetLauncherItemController(id);
|
| if (!controller)
|
| return; // May happen if menu closed.
|
| controller->Close();
|
| }
|
|
|
| -bool ChromeLauncherController::IsOpen(ash::ShelfID id) {
|
| +bool ChromeLauncherControllerImpl::IsOpen(ash::ShelfID id) {
|
| LauncherItemController* controller = GetLauncherItemController(id);
|
| if (!controller)
|
| return false;
|
| return controller->IsOpen();
|
| }
|
|
|
| -bool ChromeLauncherController::IsPlatformApp(ash::ShelfID id) {
|
| +bool ChromeLauncherControllerImpl::IsPlatformApp(ash::ShelfID id) {
|
| if (!HasShelfIDToAppIDMapping(id))
|
| return false;
|
|
|
| @@ -597,15 +592,15 @@ bool ChromeLauncherController::IsPlatformApp(ash::ShelfID id) {
|
| return extension ? extension->is_platform_app() : false;
|
| }
|
|
|
| -void ChromeLauncherController::LaunchApp(const std::string& app_id,
|
| - ash::LaunchSource source,
|
| - int event_flags) {
|
| +void ChromeLauncherControllerImpl::LaunchApp(const std::string& app_id,
|
| + ash::LaunchSource source,
|
| + int event_flags) {
|
| launcher_controller_helper_->LaunchApp(app_id, source, event_flags);
|
| }
|
|
|
| -void ChromeLauncherController::ActivateApp(const std::string& app_id,
|
| - ash::LaunchSource source,
|
| - int event_flags) {
|
| +void ChromeLauncherControllerImpl::ActivateApp(const std::string& app_id,
|
| + ash::LaunchSource source,
|
| + int event_flags) {
|
| // If there is an existing non-shortcut controller for this app, open it.
|
| ash::ShelfID id = GetShelfIDForAppID(app_id);
|
| if (id) {
|
| @@ -624,7 +619,7 @@ void ChromeLauncherController::ActivateApp(const std::string& app_id,
|
| LaunchApp(app_id, source, event_flags);
|
| }
|
|
|
| -extensions::LaunchType ChromeLauncherController::GetLaunchType(
|
| +extensions::LaunchType ChromeLauncherControllerImpl::GetLaunchType(
|
| ash::ShelfID id) {
|
| const Extension* extension = GetExtensionForAppID(GetAppIDForShelfID(id));
|
|
|
| @@ -636,7 +631,7 @@ extensions::LaunchType ChromeLauncherController::GetLaunchType(
|
| extension);
|
| }
|
|
|
| -ash::ShelfID ChromeLauncherController::GetShelfIDForAppID(
|
| +ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID(
|
| const std::string& app_id) {
|
| for (IDToItemControllerMap::const_iterator i =
|
| id_to_item_controller_map_.begin();
|
| @@ -649,19 +644,21 @@ ash::ShelfID ChromeLauncherController::GetShelfIDForAppID(
|
| return 0;
|
| }
|
|
|
| -bool ChromeLauncherController::HasShelfIDToAppIDMapping(ash::ShelfID id) const {
|
| +bool ChromeLauncherControllerImpl::HasShelfIDToAppIDMapping(
|
| + ash::ShelfID id) const {
|
| return id_to_item_controller_map_.find(id) !=
|
| id_to_item_controller_map_.end();
|
| }
|
|
|
| -const std::string& ChromeLauncherController::GetAppIDForShelfID(
|
| +const std::string& ChromeLauncherControllerImpl::GetAppIDForShelfID(
|
| ash::ShelfID id) {
|
| LauncherItemController* controller = GetLauncherItemController(id);
|
| return controller ? controller->app_id() : base::EmptyString();
|
| }
|
|
|
| -void ChromeLauncherController::OnAppImageUpdated(const std::string& id,
|
| - const gfx::ImageSkia& image) {
|
| +void ChromeLauncherControllerImpl::OnAppImageUpdated(
|
| + const std::string& id,
|
| + const gfx::ImageSkia& image) {
|
| // TODO: need to get this working for shortcuts.
|
| for (IDToItemControllerMap::const_iterator i =
|
| id_to_item_controller_map_.begin();
|
| @@ -681,7 +678,7 @@ void ChromeLauncherController::OnAppImageUpdated(const std::string& id,
|
| }
|
| }
|
|
|
| -void ChromeLauncherController::SetLauncherItemImage(
|
| +void ChromeLauncherControllerImpl::SetLauncherItemImage(
|
| ash::ShelfID shelf_id,
|
| const gfx::ImageSkia& image) {
|
| int index = model_->ItemIndexByID(shelf_id);
|
| @@ -692,7 +689,7 @@ void ChromeLauncherController::SetLauncherItemImage(
|
| model_->Set(index, item);
|
| }
|
|
|
| -bool ChromeLauncherController::IsAppPinned(const std::string& app_id) {
|
| +bool ChromeLauncherControllerImpl::IsAppPinned(const std::string& app_id) {
|
| for (IDToItemControllerMap::const_iterator i =
|
| id_to_item_controller_map_.begin();
|
| i != id_to_item_controller_map_.end(); ++i) {
|
| @@ -702,7 +699,7 @@ bool ChromeLauncherController::IsAppPinned(const std::string& app_id) {
|
| return false;
|
| }
|
|
|
| -bool ChromeLauncherController::IsWindowedAppInLauncher(
|
| +bool ChromeLauncherControllerImpl::IsWindowedAppInLauncher(
|
| const std::string& app_id) {
|
| int index = model_->ItemIndexByID(GetShelfIDForAppID(app_id));
|
| if (index < 0)
|
| @@ -712,14 +709,14 @@ bool ChromeLauncherController::IsWindowedAppInLauncher(
|
| return type == ash::TYPE_WINDOWED_APP;
|
| }
|
|
|
| -void ChromeLauncherController::PinAppWithID(const std::string& app_id) {
|
| +void ChromeLauncherControllerImpl::PinAppWithID(const std::string& app_id) {
|
| if (GetPinnable(app_id) == AppListControllerDelegate::PIN_EDITABLE)
|
| DoPinAppWithID(app_id);
|
| else
|
| NOTREACHED();
|
| }
|
|
|
| -void ChromeLauncherController::SetLaunchType(
|
| +void ChromeLauncherControllerImpl::SetLaunchType(
|
| ash::ShelfID id,
|
| extensions::LaunchType launch_type) {
|
| LauncherItemController* controller = GetLauncherItemController(id);
|
| @@ -729,14 +726,14 @@ void ChromeLauncherController::SetLaunchType(
|
| extensions::SetLaunchType(profile_, controller->app_id(), launch_type);
|
| }
|
|
|
| -void ChromeLauncherController::UnpinAppWithID(const std::string& app_id) {
|
| +void ChromeLauncherControllerImpl::UnpinAppWithID(const std::string& app_id) {
|
| if (GetPinnable(app_id) == AppListControllerDelegate::PIN_EDITABLE)
|
| DoUnpinAppWithID(app_id);
|
| else
|
| NOTREACHED();
|
| }
|
|
|
| -void ChromeLauncherController::OnSetShelfItemDelegate(
|
| +void ChromeLauncherControllerImpl::OnSetShelfItemDelegate(
|
| ash::ShelfID id,
|
| ash::ShelfItemDelegate* item_delegate) {
|
| // TODO(skuhne): This fixes crbug.com/429870, but it does not answer why we
|
| @@ -748,7 +745,7 @@ void ChromeLauncherController::OnSetShelfItemDelegate(
|
| id_to_item_controller_map_.erase(iter);
|
| }
|
|
|
| -void ChromeLauncherController::PersistPinnedState() {
|
| +void ChromeLauncherControllerImpl::PersistPinnedState() {
|
| if (ignore_persist_pinned_state_change_)
|
| return;
|
| // It is a coding error to call PersistPinnedState() if the pinned apps are
|
| @@ -778,8 +775,8 @@ void ChromeLauncherController::PersistPinnedState() {
|
| if (controller && IsPinned(id) &&
|
| GetPinnable(controller->app_id()) !=
|
| AppListControllerDelegate::NO_PIN) {
|
| - base::DictionaryValue* app_value = ash::CreateAppDict(
|
| - controller->app_id());
|
| + base::DictionaryValue* app_value =
|
| + ash::CreateAppDict(controller->app_id());
|
| if (app_value) {
|
| if (!IsAppForUserPinned(controller->app_id(),
|
| pinned_apps_pref.get(),
|
| @@ -800,16 +797,17 @@ void ChromeLauncherController::PersistPinnedState() {
|
| }
|
| pref_change_registrar_.Add(
|
| prefs::kPinnedLauncherApps,
|
| - base::Bind(&ChromeLauncherController::UpdateAppLaunchersFromPref,
|
| + base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref,
|
| base::Unretained(this)));
|
| }
|
|
|
| -Profile* ChromeLauncherController::profile() {
|
| +Profile* ChromeLauncherControllerImpl::GetProfile() {
|
| return profile_;
|
| }
|
|
|
| -void ChromeLauncherController::UpdateAppState(content::WebContents* contents,
|
| - AppState app_state) {
|
| +void ChromeLauncherControllerImpl::UpdateAppState(
|
| + content::WebContents* contents,
|
| + AppState app_state) {
|
| std::string app_id = launcher_controller_helper_->GetAppID(contents);
|
|
|
| // Check if the gMail app is loaded and it matches the given content.
|
| @@ -840,12 +838,13 @@ void ChromeLauncherController::UpdateAppState(content::WebContents* contents,
|
| ash::ShelfID id = GetShelfIDForAppID(app_id);
|
| if (id) {
|
| SetItemStatus(id, (app_state == APP_STATE_WINDOW_ACTIVE ||
|
| - app_state == APP_STATE_ACTIVE) ? ash::STATUS_ACTIVE :
|
| - GetAppState(app_id));
|
| + app_state == APP_STATE_ACTIVE)
|
| + ? ash::STATUS_ACTIVE
|
| + : GetAppState(app_id));
|
| }
|
| }
|
|
|
| -ash::ShelfID ChromeLauncherController::GetShelfIDForWebContents(
|
| +ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForWebContents(
|
| content::WebContents* contents) {
|
| DCHECK(contents);
|
|
|
| @@ -864,8 +863,9 @@ ash::ShelfID ChromeLauncherController::GetShelfIDForWebContents(
|
| return id;
|
| }
|
|
|
| -void ChromeLauncherController::SetRefocusURLPatternForTest(ash::ShelfID id,
|
| - const GURL& url) {
|
| +void ChromeLauncherControllerImpl::SetRefocusURLPatternForTest(
|
| + ash::ShelfID id,
|
| + const GURL& url) {
|
| LauncherItemController* controller = GetLauncherItemController(id);
|
| DCHECK(controller);
|
|
|
| @@ -885,23 +885,23 @@ void ChromeLauncherController::SetRefocusURLPatternForTest(ash::ShelfID id,
|
| }
|
| }
|
|
|
| -const Extension* ChromeLauncherController::GetExtensionForAppID(
|
| +const Extension* ChromeLauncherControllerImpl::GetExtensionForAppID(
|
| const std::string& app_id) const {
|
| return extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
|
| app_id, extensions::ExtensionRegistry::EVERYTHING);
|
| }
|
|
|
| ash::ShelfItemDelegate::PerformedAction
|
| -ChromeLauncherController::ActivateWindowOrMinimizeIfActive(
|
| +ChromeLauncherControllerImpl::ActivateWindowOrMinimizeIfActive(
|
| ui::BaseWindow* window,
|
| bool allow_minimize) {
|
| // In separated desktop mode we might have to teleport a window back to the
|
| // current user.
|
| if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
|
| - chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) {
|
| + chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) {
|
| aura::Window* native_window = window->GetNativeWindow();
|
| const AccountId& current_account_id =
|
| - multi_user_util::GetAccountIdFromProfile(profile());
|
| + multi_user_util::GetAccountIdFromProfile(GetProfile());
|
| chrome::MultiUserWindowManager* manager =
|
| chrome::MultiUserWindowManager::GetInstance();
|
| if (!manager->IsWindowOnDesktopOfUser(native_window, current_account_id)) {
|
| @@ -923,7 +923,12 @@ ChromeLauncherController::ActivateWindowOrMinimizeIfActive(
|
| return ash::ShelfItemDelegate::kExistingWindowActivated;
|
| }
|
|
|
| -void ChromeLauncherController::OnShelfCreated(ash::Shelf* shelf) {
|
| +ArcAppDeferredLauncherController*
|
| +ChromeLauncherControllerImpl::GetArcDeferredLauncher() {
|
| + return arc_deferred_launcher_.get();
|
| +}
|
| +
|
| +void ChromeLauncherControllerImpl::OnShelfCreated(ash::Shelf* shelf) {
|
| PrefService* prefs = profile_->GetPrefs();
|
| const int64_t display = GetDisplayIDForShelf(shelf);
|
|
|
| @@ -933,26 +938,27 @@ void ChromeLauncherController::OnShelfCreated(ash::Shelf* shelf) {
|
| shelf->SetAlignment(ash::GetShelfAlignmentPref(prefs, display));
|
| }
|
|
|
| -void ChromeLauncherController::OnShelfDestroyed(ash::Shelf* shelf) {}
|
| +void ChromeLauncherControllerImpl::OnShelfDestroyed(ash::Shelf* shelf) {}
|
|
|
| -void ChromeLauncherController::OnShelfAlignmentChanged(ash::Shelf* shelf) {
|
| +void ChromeLauncherControllerImpl::OnShelfAlignmentChanged(ash::Shelf* shelf) {
|
| ash::SetShelfAlignmentPref(profile_->GetPrefs(), GetDisplayIDForShelf(shelf),
|
| shelf->alignment());
|
| }
|
|
|
| -void ChromeLauncherController::OnShelfAutoHideBehaviorChanged(
|
| +void ChromeLauncherControllerImpl::OnShelfAutoHideBehaviorChanged(
|
| ash::Shelf* shelf) {
|
| ash::SetShelfAutoHideBehaviorPref(profile_->GetPrefs(),
|
| GetDisplayIDForShelf(shelf),
|
| shelf->auto_hide_behavior());
|
| }
|
|
|
| -void ChromeLauncherController::OnShelfAutoHideStateChanged(ash::Shelf* shelf) {}
|
| +void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged(
|
| + ash::Shelf* shelf) {}
|
|
|
| -void ChromeLauncherController::OnShelfVisibilityStateChanged(
|
| +void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged(
|
| ash::Shelf* shelf) {}
|
|
|
| -void ChromeLauncherController::ShelfItemAdded(int index) {
|
| +void ChromeLauncherControllerImpl::ShelfItemAdded(int index) {
|
| // The app list launcher can get added to the shelf after we applied the
|
| // preferences. In that case the item might be at the wrong spot. As such we
|
| // call the function again.
|
| @@ -960,7 +966,8 @@ void ChromeLauncherController::ShelfItemAdded(int index) {
|
| UpdateAppLaunchersFromPref();
|
| }
|
|
|
| -void ChromeLauncherController::ShelfItemRemoved(int index, ash::ShelfID id) {
|
| +void ChromeLauncherControllerImpl::ShelfItemRemoved(int index,
|
| + ash::ShelfID id) {
|
| // TODO(skuhne): This fixes crbug.com/429870, but it does not answer why we
|
| // get into this state in the first place.
|
| IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id);
|
| @@ -972,8 +979,8 @@ void ChromeLauncherController::ShelfItemRemoved(int index, ash::ShelfID id) {
|
| id_to_item_controller_map_.erase(iter);
|
| }
|
|
|
| -void ChromeLauncherController::ShelfItemMoved(int start_index,
|
| - int target_index) {
|
| +void ChromeLauncherControllerImpl::ShelfItemMoved(int start_index,
|
| + int target_index) {
|
| const ash::ShelfItem& item = model_->items()[target_index];
|
| // We remember the moved item position if it is either pinnable or
|
| // it is the app list with the alternate shelf layout.
|
| @@ -982,11 +989,11 @@ void ChromeLauncherController::ShelfItemMoved(int start_index,
|
| PersistPinnedState();
|
| }
|
|
|
| -void ChromeLauncherController::ShelfItemChanged(
|
| +void ChromeLauncherControllerImpl::ShelfItemChanged(
|
| int index,
|
| const ash::ShelfItem& old_item) {}
|
|
|
| -void ChromeLauncherController::ActiveUserChanged(
|
| +void ChromeLauncherControllerImpl::ActiveUserChanged(
|
| const std::string& user_email) {
|
| // Store the order of running applications for the user which gets inactive.
|
| RememberUnpinnedRunningApplicationOrder();
|
| @@ -1016,13 +1023,14 @@ void ChromeLauncherController::ActiveUserChanged(
|
| ash::Shell::GetInstance()->CreateKeyboard();
|
| }
|
|
|
| -void ChromeLauncherController::AdditionalUserAddedToSession(Profile* profile) {
|
| +void ChromeLauncherControllerImpl::AdditionalUserAddedToSession(
|
| + Profile* profile) {
|
| // Switch the running applications to the new user.
|
| for (auto& controller : app_window_controllers_)
|
| controller->AdditionalUserAddedToSession(profile);
|
| }
|
|
|
| -void ChromeLauncherController::OnAppInstalled(
|
| +void ChromeLauncherControllerImpl::OnAppInstalled(
|
| content::BrowserContext* browser_context,
|
| const std::string& app_id) {
|
| if (IsAppPinned(app_id)) {
|
| @@ -1037,7 +1045,7 @@ void ChromeLauncherController::OnAppInstalled(
|
| UpdateAppLaunchersFromPref();
|
| }
|
|
|
| -void ChromeLauncherController::OnAppUpdated(
|
| +void ChromeLauncherControllerImpl::OnAppUpdated(
|
| content::BrowserContext* browser_context,
|
| const std::string& app_id) {
|
| AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
|
| @@ -1045,7 +1053,7 @@ void ChromeLauncherController::OnAppUpdated(
|
| app_icon_loader->UpdateImage(app_id);
|
| }
|
|
|
| -void ChromeLauncherController::OnAppUninstalled(
|
| +void ChromeLauncherControllerImpl::OnAppUninstalled(
|
| content::BrowserContext* browser_context,
|
| const std::string& app_id) {
|
| // Since we might have windowed apps of this type which might have
|
| @@ -1063,18 +1071,18 @@ void ChromeLauncherController::OnAppUninstalled(
|
| }
|
| }
|
|
|
| -void ChromeLauncherController::OnDisplayConfigurationChanged() {
|
| +void ChromeLauncherControllerImpl::OnDisplayConfigurationChanged() {
|
| SetShelfBehaviorsFromPrefs();
|
| }
|
|
|
| -void ChromeLauncherController::OnAppSyncUIStatusChanged() {
|
| +void ChromeLauncherControllerImpl::OnAppSyncUIStatusChanged() {
|
| if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING)
|
| model_->set_status(ash::ShelfModel::STATUS_LOADING);
|
| else
|
| model_->set_status(ash::ShelfModel::STATUS_NORMAL);
|
| }
|
|
|
| -ChromeLauncherAppMenuItems ChromeLauncherController::GetApplicationList(
|
| +ChromeLauncherAppMenuItems ChromeLauncherControllerImpl::GetApplicationList(
|
| const ash::ShelfItem& item,
|
| int event_flags) {
|
| // Make sure that there is a controller associated with the id and that the
|
| @@ -1087,7 +1095,7 @@ ChromeLauncherAppMenuItems ChromeLauncherController::GetApplicationList(
|
| }
|
|
|
| std::vector<content::WebContents*>
|
| -ChromeLauncherController::GetV1ApplicationsFromAppId(
|
| +ChromeLauncherControllerImpl::GetV1ApplicationsFromAppId(
|
| const std::string& app_id) {
|
| ash::ShelfID id = GetShelfIDForAppID(app_id);
|
|
|
| @@ -1101,8 +1109,8 @@ ChromeLauncherController::GetV1ApplicationsFromAppId(
|
| return std::vector<content::WebContents*>();
|
| }
|
|
|
| -void ChromeLauncherController::ActivateShellApp(const std::string& app_id,
|
| - int index) {
|
| +void ChromeLauncherControllerImpl::ActivateShellApp(const std::string& app_id,
|
| + int index) {
|
| ash::ShelfID id = GetShelfIDForAppID(app_id);
|
| if (id) {
|
| LauncherItemController* controller = GetLauncherItemController(id);
|
| @@ -1114,7 +1122,7 @@ void ChromeLauncherController::ActivateShellApp(const std::string& app_id,
|
| }
|
| }
|
|
|
| -bool ChromeLauncherController::IsWebContentHandledByApplication(
|
| +bool ChromeLauncherControllerImpl::IsWebContentHandledByApplication(
|
| content::WebContents* web_contents,
|
| const std::string& app_id) {
|
| if ((web_contents_to_app_id_.find(web_contents) !=
|
| @@ -1124,7 +1132,7 @@ bool ChromeLauncherController::IsWebContentHandledByApplication(
|
| return (app_id == kGmailAppId && ContentCanBeHandledByGmailApp(web_contents));
|
| }
|
|
|
| -bool ChromeLauncherController::ContentCanBeHandledByGmailApp(
|
| +bool ChromeLauncherControllerImpl::ContentCanBeHandledByGmailApp(
|
| content::WebContents* web_contents) {
|
| ash::ShelfID id = GetShelfIDForAppID(kGmailAppId);
|
| if (id) {
|
| @@ -1141,7 +1149,7 @@ bool ChromeLauncherController::ContentCanBeHandledByGmailApp(
|
| return false;
|
| }
|
|
|
| -gfx::Image ChromeLauncherController::GetAppListIcon(
|
| +gfx::Image ChromeLauncherControllerImpl::GetAppListIcon(
|
| content::WebContents* web_contents) const {
|
| ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| if (IsIncognito(web_contents))
|
| @@ -1154,7 +1162,7 @@ gfx::Image ChromeLauncherController::GetAppListIcon(
|
| return result;
|
| }
|
|
|
| -base::string16 ChromeLauncherController::GetAppListTitle(
|
| +base::string16 ChromeLauncherControllerImpl::GetAppListTitle(
|
| content::WebContents* web_contents) const {
|
| base::string16 title = web_contents->GetTitle();
|
| if (!title.empty())
|
| @@ -1170,32 +1178,31 @@ base::string16 ChromeLauncherController::GetAppListTitle(
|
| return l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE);
|
| }
|
|
|
| -ash::ShelfID ChromeLauncherController::CreateAppShortcutLauncherItem(
|
| +ash::ShelfID ChromeLauncherControllerImpl::CreateAppShortcutLauncherItem(
|
| const std::string& app_id,
|
| int index) {
|
| - return CreateAppShortcutLauncherItemWithType(app_id,
|
| - index,
|
| + return CreateAppShortcutLauncherItemWithType(app_id, index,
|
| ash::TYPE_APP_SHORTCUT);
|
| }
|
|
|
| -void ChromeLauncherController::SetLauncherControllerHelperForTest(
|
| +void ChromeLauncherControllerImpl::SetLauncherControllerHelperForTest(
|
| LauncherControllerHelper* helper) {
|
| launcher_controller_helper_.reset(helper);
|
| }
|
|
|
| -void ChromeLauncherController::SetAppIconLoadersForTest(
|
| +void ChromeLauncherControllerImpl::SetAppIconLoadersForTest(
|
| std::vector<std::unique_ptr<AppIconLoader>>& loaders) {
|
| app_icon_loaders_.clear();
|
| for (auto& loader : loaders)
|
| app_icon_loaders_.push_back(std::move(loader));
|
| }
|
|
|
| -const std::string& ChromeLauncherController::GetAppIdFromShelfIdForTest(
|
| +const std::string& ChromeLauncherControllerImpl::GetAppIdFromShelfIdForTest(
|
| ash::ShelfID id) {
|
| return id_to_item_controller_map_[id]->app_id();
|
| }
|
|
|
| -bool ChromeLauncherController::GetAppIDForShelfIDConst(
|
| +bool ChromeLauncherControllerImpl::GetAppIDForShelfIDConst(
|
| ash::ShelfID id,
|
| std::string* app_id) const {
|
| auto app = id_to_item_controller_map_.find(id);
|
| @@ -1207,7 +1214,7 @@ bool ChromeLauncherController::GetAppIDForShelfIDConst(
|
| }
|
| }
|
|
|
| -void ChromeLauncherController::SetShelfItemDelegateManagerForTest(
|
| +void ChromeLauncherControllerImpl::SetShelfItemDelegateManagerForTest(
|
| ash::ShelfItemDelegateManager* manager) {
|
| if (item_delegate_manager_)
|
| item_delegate_manager_->RemoveObserver(this);
|
| @@ -1218,7 +1225,7 @@ void ChromeLauncherController::SetShelfItemDelegateManagerForTest(
|
| item_delegate_manager_->AddObserver(this);
|
| }
|
|
|
| -void ChromeLauncherController::RememberUnpinnedRunningApplicationOrder() {
|
| +void ChromeLauncherControllerImpl::RememberUnpinnedRunningApplicationOrder() {
|
| RunningAppListIds list;
|
| for (int i = 0; i < model_->item_count(); i++) {
|
| ash::ShelfItemType type = model_->items()[i].type;
|
| @@ -1230,7 +1237,7 @@ void ChromeLauncherController::RememberUnpinnedRunningApplicationOrder() {
|
| last_used_running_application_order_[user_email] = list;
|
| }
|
|
|
| -void ChromeLauncherController::RestoreUnpinnedRunningApplicationOrder(
|
| +void ChromeLauncherControllerImpl::RestoreUnpinnedRunningApplicationOrder(
|
| const std::string& user_id) {
|
| const RunningAppListIdMap::iterator app_id_list =
|
| last_used_running_application_order_.find(user_id);
|
| @@ -1255,7 +1262,8 @@ void ChromeLauncherController::RestoreUnpinnedRunningApplicationOrder(
|
| }
|
| }
|
|
|
| -ash::ShelfID ChromeLauncherController::CreateAppShortcutLauncherItemWithType(
|
| +ash::ShelfID
|
| +ChromeLauncherControllerImpl::CreateAppShortcutLauncherItemWithType(
|
| const std::string& app_id,
|
| int index,
|
| ash::ShelfItemType shelf_item_type) {
|
| @@ -1266,23 +1274,23 @@ ash::ShelfID ChromeLauncherController::CreateAppShortcutLauncherItemWithType(
|
| return shelf_id;
|
| }
|
|
|
| -LauncherItemController* ChromeLauncherController::GetLauncherItemController(
|
| +LauncherItemController* ChromeLauncherControllerImpl::GetLauncherItemController(
|
| const ash::ShelfID id) {
|
| if (!HasShelfIDToAppIDMapping(id))
|
| return NULL;
|
| return id_to_item_controller_map_[id];
|
| }
|
|
|
| -bool ChromeLauncherController::IsBrowserFromActiveUser(Browser* browser) {
|
| +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)
|
| + chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED)
|
| return true;
|
| return multi_user_util::IsProfileFromActiveUser(browser->profile());
|
| }
|
|
|
| -bool ChromeLauncherController::ShelfBoundsChangesProbablyWithUser(
|
| +bool ChromeLauncherControllerImpl::ShelfBoundsChangesProbablyWithUser(
|
| ash::Shelf* shelf,
|
| const std::string& user_id) const {
|
| Profile* other_profile = multi_user_util::GetProfileFromAccountId(
|
| @@ -1306,12 +1314,13 @@ bool ChromeLauncherController::ShelfBoundsChangesProbablyWithUser(
|
| ash::GetShelfAlignmentPref(other_prefs, display);
|
| }
|
|
|
| -void ChromeLauncherController::OnUserProfileReadyToSwitch(Profile* profile) {
|
| +void ChromeLauncherControllerImpl::OnUserProfileReadyToSwitch(
|
| + Profile* profile) {
|
| if (user_switch_observer_.get())
|
| user_switch_observer_->OnUserProfileReadyToSwitch(profile);
|
| }
|
|
|
| -void ChromeLauncherController::LauncherItemClosed(ash::ShelfID id) {
|
| +void ChromeLauncherControllerImpl::LauncherItemClosed(ash::ShelfID id) {
|
| IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id);
|
| CHECK(iter != id_to_item_controller_map_.end());
|
| CHECK(iter->second);
|
| @@ -1327,7 +1336,7 @@ void ChromeLauncherController::LauncherItemClosed(ash::ShelfID id) {
|
| model_->RemoveItemAt(index);
|
| }
|
|
|
| -void ChromeLauncherController::DoPinAppWithID(const std::string& app_id) {
|
| +void ChromeLauncherControllerImpl::DoPinAppWithID(const std::string& app_id) {
|
| // If there is an item, do nothing and return.
|
| if (IsAppPinned(app_id))
|
| return;
|
| @@ -1344,14 +1353,14 @@ void ChromeLauncherController::DoPinAppWithID(const std::string& app_id) {
|
| }
|
| }
|
|
|
| -void ChromeLauncherController::DoUnpinAppWithID(const std::string& app_id) {
|
| +void ChromeLauncherControllerImpl::DoUnpinAppWithID(const std::string& app_id) {
|
| ash::ShelfID shelf_id = GetShelfIDForAppID(app_id);
|
| if (shelf_id && IsPinned(shelf_id))
|
| Unpin(shelf_id);
|
| }
|
|
|
| -int ChromeLauncherController::PinRunningAppInternal(int index,
|
| - ash::ShelfID shelf_id) {
|
| +int ChromeLauncherControllerImpl::PinRunningAppInternal(int index,
|
| + ash::ShelfID shelf_id) {
|
| int running_index = model_->ItemIndexByID(shelf_id);
|
| ash::ShelfItem item = model_->items()[running_index];
|
| DCHECK(item.type == ash::TYPE_WINDOWED_APP ||
|
| @@ -1368,7 +1377,7 @@ int ChromeLauncherController::PinRunningAppInternal(int index,
|
| return index;
|
| }
|
|
|
| -void ChromeLauncherController::UnpinRunningAppInternal(int index) {
|
| +void ChromeLauncherControllerImpl::UnpinRunningAppInternal(int index) {
|
| DCHECK_GE(index, 0);
|
| ash::ShelfItem item = model_->items()[index];
|
| DCHECK_EQ(item.type, ash::TYPE_APP_SHORTCUT);
|
| @@ -1381,7 +1390,7 @@ void ChromeLauncherController::UnpinRunningAppInternal(int index) {
|
| model_->Set(index, item);
|
| }
|
|
|
| -void ChromeLauncherController::UpdateAppLaunchersFromPref() {
|
| +void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() {
|
| // There are various functions which will trigger a |PersistPinnedState| call
|
| // like a direct call to |DoPinAppWithID|, or an indirect call to the menu
|
| // model which will use weights to re-arrange the icons to new positions.
|
| @@ -1421,8 +1430,8 @@ void ChromeLauncherController::UpdateAppLaunchersFromPref() {
|
| (extension_misc::kChromeAppId == *pref_app_id && is_chrome) ||
|
| (controller && controller->app_id() == *pref_app_id)) {
|
| // Check if an item needs to be moved here.
|
| - MoveChromeOrApplistToFinalPosition(
|
| - is_chrome, is_app_list, index, &chrome_index, &app_list_index);
|
| + MoveChromeOrApplistToFinalPosition(is_chrome, is_app_list, index,
|
| + &chrome_index, &app_list_index);
|
| ++pref_app_id;
|
| break;
|
| } else {
|
| @@ -1441,8 +1450,7 @@ void ChromeLauncherController::UpdateAppLaunchersFromPref() {
|
| ++index;
|
| } else {
|
| // Check if this is a platform or a windowed app.
|
| - if (item.type == ash::TYPE_APP_SHORTCUT &&
|
| - controller &&
|
| + if (item.type == ash::TYPE_APP_SHORTCUT && controller &&
|
| (controller->locked() ||
|
| controller->type() == LauncherItemController::TYPE_APP)) {
|
| // Note: This will not change the amount of items (|max_index|).
|
| @@ -1522,13 +1530,13 @@ void ChromeLauncherController::UpdateAppLaunchersFromPref() {
|
| ++app_list_index;
|
| } else {
|
| int target_index = FindInsertionPoint(is_app_list);
|
| - MoveChromeOrApplistToFinalPosition(
|
| - is_chrome, is_app_list, target_index, &chrome_index, &app_list_index);
|
| + MoveChromeOrApplistToFinalPosition(is_chrome, is_app_list, target_index,
|
| + &chrome_index, &app_list_index);
|
| }
|
| }
|
| }
|
|
|
| -void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() {
|
| +void ChromeLauncherControllerImpl::SetShelfAutoHideBehaviorFromPrefs() {
|
| for (auto* window : ash::Shell::GetAllRootWindows()) {
|
| ash::Shelf* shelf = ash::Shelf::ForWindow(window);
|
| if (shelf) {
|
| @@ -1538,7 +1546,7 @@ void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() {
|
| }
|
| }
|
|
|
| -void ChromeLauncherController::SetShelfAlignmentFromPrefs() {
|
| +void ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs() {
|
| if (!ash::ShelfWidget::ShelfAlignmentAllowed())
|
| return;
|
|
|
| @@ -1551,22 +1559,22 @@ void ChromeLauncherController::SetShelfAlignmentFromPrefs() {
|
| }
|
| }
|
|
|
| -void ChromeLauncherController::SetShelfBehaviorsFromPrefs() {
|
| +void ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs() {
|
| SetShelfAutoHideBehaviorFromPrefs();
|
| SetShelfAlignmentFromPrefs();
|
| }
|
|
|
| -void ChromeLauncherController::SetVirtualKeyboardBehaviorFromPrefs() {
|
| +void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() {
|
| const PrefService* service = profile_->GetPrefs();
|
| const bool was_enabled = keyboard::IsKeyboardEnabled();
|
| if (!service->HasPrefPath(prefs::kTouchVirtualKeyboardEnabled)) {
|
| keyboard::SetKeyboardShowOverride(keyboard::KEYBOARD_SHOW_OVERRIDE_NONE);
|
| } else {
|
| - const bool enable = service->GetBoolean(
|
| - prefs::kTouchVirtualKeyboardEnabled);
|
| + const bool enable =
|
| + service->GetBoolean(prefs::kTouchVirtualKeyboardEnabled);
|
| keyboard::SetKeyboardShowOverride(
|
| enable ? keyboard::KEYBOARD_SHOW_OVERRIDE_ENABLED
|
| - : keyboard::KEYBOARD_SHOW_OVERRIDE_DISABLED);
|
| + : keyboard::KEYBOARD_SHOW_OVERRIDE_DISABLED);
|
| }
|
| const bool is_enabled = keyboard::IsKeyboardEnabled();
|
| if (was_enabled && !is_enabled)
|
| @@ -1575,12 +1583,11 @@ void ChromeLauncherController::SetVirtualKeyboardBehaviorFromPrefs() {
|
| ash::Shell::GetInstance()->CreateKeyboard();
|
| }
|
|
|
| -ash::ShelfItemStatus ChromeLauncherController::GetAppState(
|
| +ash::ShelfItemStatus ChromeLauncherControllerImpl::GetAppState(
|
| const std::string& app_id) {
|
| ash::ShelfItemStatus status = ash::STATUS_CLOSED;
|
| for (WebContentsToAppIDMap::iterator it = web_contents_to_app_id_.begin();
|
| - it != web_contents_to_app_id_.end();
|
| - ++it) {
|
| + it != web_contents_to_app_id_.end(); ++it) {
|
| if (it->second == app_id) {
|
| Browser* browser = chrome::FindBrowserWithWebContents(it->first);
|
| // Usually there should never be an item in our |web_contents_to_app_id_|
|
| @@ -1589,8 +1596,9 @@ ash::ShelfItemStatus ChromeLauncherController::GetAppState(
|
| if (!browser)
|
| continue;
|
| if (browser->window()->IsActive()) {
|
| - return browser->tab_strip_model()->GetActiveWebContents() == it->first ?
|
| - ash::STATUS_ACTIVE : ash::STATUS_RUNNING;
|
| + return browser->tab_strip_model()->GetActiveWebContents() == it->first
|
| + ? ash::STATUS_ACTIVE
|
| + : ash::STATUS_RUNNING;
|
| } else {
|
| status = ash::STATUS_RUNNING;
|
| }
|
| @@ -1599,7 +1607,7 @@ ash::ShelfItemStatus ChromeLauncherController::GetAppState(
|
| return status;
|
| }
|
|
|
| -ash::ShelfID ChromeLauncherController::InsertAppLauncherItem(
|
| +ash::ShelfID ChromeLauncherControllerImpl::InsertAppLauncherItem(
|
| LauncherItemController* controller,
|
| const std::string& app_id,
|
| ash::ShelfItemStatus status,
|
| @@ -1635,7 +1643,7 @@ ash::ShelfID ChromeLauncherController::InsertAppLauncherItem(
|
| }
|
|
|
| std::vector<content::WebContents*>
|
| -ChromeLauncherController::GetV1ApplicationsFromController(
|
| +ChromeLauncherControllerImpl::GetV1ApplicationsFromController(
|
| LauncherItemController* controller) {
|
| DCHECK(controller->type() == LauncherItemController::TYPE_SHORTCUT);
|
| AppShortcutLauncherItemController* app_controller =
|
| @@ -1644,9 +1652,9 @@ ChromeLauncherController::GetV1ApplicationsFromController(
|
| }
|
|
|
| BrowserShortcutLauncherItemController*
|
| -ChromeLauncherController::GetBrowserShortcutLauncherItemController() {
|
| +ChromeLauncherControllerImpl::GetBrowserShortcutLauncherItemController() {
|
| for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin();
|
| - i != id_to_item_controller_map_.end(); ++i) {
|
| + i != id_to_item_controller_map_.end(); ++i) {
|
| int index = model_->ItemIndexByID(i->first);
|
| const ash::ShelfItem& item = model_->items()[index];
|
| if (item.type == ash::TYPE_BROWSER_SHORTCUT)
|
| @@ -1657,7 +1665,7 @@ ChromeLauncherController::GetBrowserShortcutLauncherItemController() {
|
| return nullptr;
|
| }
|
|
|
| -ash::ShelfID ChromeLauncherController::CreateBrowserShortcutLauncherItem() {
|
| +ash::ShelfID ChromeLauncherControllerImpl::CreateBrowserShortcutLauncherItem() {
|
| ash::ShelfItem browser_shortcut;
|
| browser_shortcut.type = ash::TYPE_BROWSER_SHORTCUT;
|
| ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| @@ -1673,11 +1681,11 @@ ash::ShelfID ChromeLauncherController::CreateBrowserShortcutLauncherItem() {
|
| return id;
|
| }
|
|
|
| -void ChromeLauncherController::PersistChromeItemIndex(int index) {
|
| +void ChromeLauncherControllerImpl::PersistChromeItemIndex(int index) {
|
| profile_->GetPrefs()->SetInteger(prefs::kShelfChromeIconIndex, index);
|
| }
|
|
|
| -void ChromeLauncherController::MoveChromeOrApplistToFinalPosition(
|
| +void ChromeLauncherControllerImpl::MoveChromeOrApplistToFinalPosition(
|
| bool is_chrome,
|
| bool is_app_list,
|
| int target_index,
|
| @@ -1685,22 +1693,20 @@ void ChromeLauncherController::MoveChromeOrApplistToFinalPosition(
|
| int* app_list_index) {
|
| if (is_chrome && *chrome_index != -1) {
|
| model_->Move(*chrome_index, target_index);
|
| - if (*app_list_index != -1 &&
|
| - *chrome_index < *app_list_index &&
|
| + if (*app_list_index != -1 && *chrome_index < *app_list_index &&
|
| target_index > *app_list_index)
|
| --(*app_list_index);
|
| *chrome_index = -1;
|
| } else if (is_app_list && *app_list_index != -1) {
|
| model_->Move(*app_list_index, target_index);
|
| - if (*chrome_index != -1 &&
|
| - *app_list_index < *chrome_index &&
|
| + if (*chrome_index != -1 && *app_list_index < *chrome_index &&
|
| target_index > *chrome_index)
|
| --(*chrome_index);
|
| *app_list_index = -1;
|
| }
|
| }
|
|
|
| -int ChromeLauncherController::FindInsertionPoint(bool is_app_list) {
|
| +int ChromeLauncherControllerImpl::FindInsertionPoint(bool is_app_list) {
|
| // Keeping this change small to backport to M33&32 (see crbug.com/329597).
|
| // TODO(skuhne): With the removal of the legacy shelf layout we should remove
|
| // the ability to move the app list item since this was never used. We should
|
| @@ -1719,15 +1725,14 @@ int ChromeLauncherController::FindInsertionPoint(bool is_app_list) {
|
| return 0;
|
| }
|
|
|
| -int ChromeLauncherController::GetChromeIconIndexForCreation() {
|
| +int ChromeLauncherControllerImpl::GetChromeIconIndexForCreation() {
|
| // We get the list of pinned apps as they currently would get pinned.
|
| // Within this list the chrome icon will be the correct location.
|
| std::vector<std::string> pinned_apps = ash::GetPinnedAppsFromPrefs(
|
| profile_->GetPrefs(), launcher_controller_helper_.get());
|
|
|
| std::vector<std::string>::iterator it =
|
| - std::find(pinned_apps.begin(),
|
| - pinned_apps.end(),
|
| + std::find(pinned_apps.begin(), pinned_apps.end(),
|
| std::string(extension_misc::kChromeAppId));
|
| DCHECK(it != pinned_apps.end());
|
| int index = it - pinned_apps.begin();
|
| @@ -1740,7 +1745,7 @@ int ChromeLauncherController::GetChromeIconIndexForCreation() {
|
| return std::min(model_->item_count(), index);
|
| }
|
|
|
| -bool ChromeLauncherController::IsIncognito(
|
| +bool ChromeLauncherControllerImpl::IsIncognito(
|
| const content::WebContents* web_contents) const {
|
| const Profile* profile =
|
| Profile::FromBrowserContext(web_contents->GetBrowserContext());
|
| @@ -1748,7 +1753,7 @@ bool ChromeLauncherController::IsIncognito(
|
| !profile->IsSystemProfile();
|
| }
|
|
|
| -void ChromeLauncherController::CloseWindowedAppsFromRemovedExtension(
|
| +void ChromeLauncherControllerImpl::CloseWindowedAppsFromRemovedExtension(
|
| const std::string& app_id,
|
| const Profile* profile) {
|
| // This function cannot rely on the controller's enumeration functionality
|
| @@ -1774,7 +1779,7 @@ void ChromeLauncherController::CloseWindowedAppsFromRemovedExtension(
|
| }
|
| }
|
|
|
| -void ChromeLauncherController::SetShelfItemDelegate(
|
| +void ChromeLauncherControllerImpl::SetShelfItemDelegate(
|
| ash::ShelfID id,
|
| ash::ShelfItemDelegate* item_delegate) {
|
| DCHECK_GT(id, 0);
|
| @@ -1784,7 +1789,7 @@ void ChromeLauncherController::SetShelfItemDelegate(
|
| id, std::unique_ptr<ash::ShelfItemDelegate>(item_delegate));
|
| }
|
|
|
| -void ChromeLauncherController::AttachProfile(Profile* profile) {
|
| +void ChromeLauncherControllerImpl::AttachProfile(Profile* profile) {
|
| profile_ = profile;
|
| // Either add the profile to the list of known profiles and make it the active
|
| // one for some functions of LauncherControllerHelper or create a new one.
|
| @@ -1803,39 +1808,40 @@ void ChromeLauncherController::AttachProfile(Profile* profile) {
|
| app_icon_loaders_.push_back(std::move(extension_app_icon_loader));
|
|
|
| if (arc::ArcAuthService::IsAllowedForProfile(profile_)) {
|
| - DCHECK(arc_deferred_launcher());
|
| + DCHECK(arc_deferred_launcher_.get());
|
| std::unique_ptr<AppIconLoader> arc_app_icon_loader(
|
| new ArcAppIconLoader(profile_, extension_misc::EXTENSION_ICON_SMALL,
|
| - arc_deferred_launcher(), this));
|
| + arc_deferred_launcher_.get(), this));
|
| app_icon_loaders_.push_back(std::move(arc_app_icon_loader));
|
| }
|
|
|
| pref_change_registrar_.Init(profile_->GetPrefs());
|
| pref_change_registrar_.Add(
|
| prefs::kPinnedLauncherApps,
|
| - base::Bind(&ChromeLauncherController::UpdateAppLaunchersFromPref,
|
| + base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref,
|
| base::Unretained(this)));
|
| pref_change_registrar_.Add(
|
| prefs::kPolicyPinnedLauncherApps,
|
| - base::Bind(&ChromeLauncherController::UpdateAppLaunchersFromPref,
|
| + base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref,
|
| base::Unretained(this)));
|
| pref_change_registrar_.Add(
|
| prefs::kShelfAlignmentLocal,
|
| - base::Bind(&ChromeLauncherController::SetShelfAlignmentFromPrefs,
|
| + base::Bind(&ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs,
|
| base::Unretained(this)));
|
| pref_change_registrar_.Add(
|
| prefs::kShelfAutoHideBehaviorLocal,
|
| - base::Bind(&ChromeLauncherController::
|
| - SetShelfAutoHideBehaviorFromPrefs,
|
| - base::Unretained(this)));
|
| + base::Bind(
|
| + &ChromeLauncherControllerImpl::SetShelfAutoHideBehaviorFromPrefs,
|
| + base::Unretained(this)));
|
| pref_change_registrar_.Add(
|
| prefs::kShelfPreferences,
|
| - base::Bind(&ChromeLauncherController::SetShelfBehaviorsFromPrefs,
|
| + base::Bind(&ChromeLauncherControllerImpl::SetShelfBehaviorsFromPrefs,
|
| base::Unretained(this)));
|
| pref_change_registrar_.Add(
|
| prefs::kTouchVirtualKeyboardEnabled,
|
| - base::Bind(&ChromeLauncherController::SetVirtualKeyboardBehaviorFromPrefs,
|
| - base::Unretained(this)));
|
| + base::Bind(
|
| + &ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs,
|
| + base::Unretained(this)));
|
|
|
| std::unique_ptr<LauncherAppUpdater> extension_app_updater(
|
| new LauncherExtensionAppUpdater(this, profile_));
|
| @@ -1848,7 +1854,7 @@ void ChromeLauncherController::AttachProfile(Profile* profile) {
|
| }
|
| }
|
|
|
| -void ChromeLauncherController::ReleaseProfile() {
|
| +void ChromeLauncherControllerImpl::ReleaseProfile() {
|
| if (app_sync_ui_state_)
|
| app_sync_ui_state_->RemoveObserver(this);
|
|
|
| @@ -1859,7 +1865,7 @@ void ChromeLauncherController::ReleaseProfile() {
|
| pref_change_registrar_.RemoveAll();
|
| }
|
|
|
| -AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp(
|
| +AppIconLoader* ChromeLauncherControllerImpl::GetAppIconLoaderForApp(
|
| const std::string& app_id) {
|
| for (const auto& app_icon_loader : app_icon_loaders_) {
|
| if (app_icon_loader->CanLoadImageForApp(app_id))
|
|
|