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.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 9c034830bbd6210bb132226767c4617f35e505a4..730f2e0993e8ce4d994f71f9ce552fa04e3d9c51 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> |
| @@ -104,9 +104,6 @@ using extensions::UnloadedExtensionInfo; |
| using extension_misc::kGmailAppId; |
| using content::WebContents; |
| -// static |
| -ChromeLauncherController* ChromeLauncherController::instance_ = NULL; |
| - |
| namespace { |
| int64_t GetDisplayIDForShelf(ash::Shelf* shelf) { |
| @@ -180,7 +177,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); |
| @@ -199,8 +196,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. |
| @@ -227,10 +224,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()); |
| @@ -240,13 +236,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), |
| @@ -282,7 +279,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)); |
| } |
| @@ -291,7 +288,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)); |
| @@ -307,7 +304,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. |
| @@ -324,7 +322,7 @@ ChromeLauncherController::ChromeLauncherController(Profile* profile, |
| } |
| } |
| -ChromeLauncherController::~ChromeLauncherController() { |
| +ChromeLauncherControllerImpl::~ChromeLauncherControllerImpl() { |
| if (item_delegate_manager_) |
| item_delegate_manager_->RemoveObserver(this); |
| @@ -349,25 +347,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::SetInstance(instance); |
| + return instance; |
| } |
| -void ChromeLauncherController::Init() { |
| +void ChromeLauncherControllerImpl::Init() { |
| CreateBrowserShortcutLauncherItem(); |
| UpdateAppLaunchersFromPref(); |
| @@ -379,7 +377,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) { |
| @@ -388,15 +386,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 |
| @@ -408,7 +403,7 @@ void ChromeLauncherController::SetItemStatus(ash::ShelfID id, |
| } |
| } |
| -void ChromeLauncherController::SetItemController( |
| +void ChromeLauncherControllerImpl::SetItemController( |
| ash::ShelfID id, |
| LauncherItemController* controller) { |
| CHECK(controller); |
| @@ -420,7 +415,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. |
| @@ -437,7 +432,7 @@ void ChromeLauncherController::CloseLauncherItem(ash::ShelfID id) { |
| } |
| } |
| -AppListControllerDelegate::Pinnable ChromeLauncherController::GetPinnable( |
| +AppListControllerDelegate::Pinnable ChromeLauncherControllerImpl::GetPinnable( |
|
msw
2016/06/10 22:44:38
nit: the order of definitions should match the ord
mfomitchev
2016/06/10 23:29:09
Yeah, I also didn't want to move code around in th
msw
2016/06/10 23:42:51
Acknowledged.
|
| const std::string& app_id) { |
| for (size_t i = 0; i < kPinProhibitedExtensionIdsLength; ++i) { |
| if (kPinProhibitedExtensionIds[i] == app_id) |
| @@ -455,7 +450,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 = |
| @@ -477,7 +472,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); |
| @@ -497,7 +492,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(); |
| @@ -512,7 +507,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; |
| @@ -520,7 +515,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. |
| @@ -530,7 +525,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; |
| @@ -542,11 +537,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); |
| } |
| @@ -554,7 +548,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)); |
| @@ -564,28 +559,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; |
| @@ -596,15 +591,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) { |
| @@ -623,7 +618,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)); |
| @@ -635,7 +630,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(); |
| @@ -648,19 +643,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(); |
| @@ -680,7 +677,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); |
| @@ -691,7 +688,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) { |
| @@ -701,7 +698,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) |
| @@ -711,14 +708,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); |
| @@ -728,14 +725,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 |
| @@ -747,7 +744,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 |
| @@ -777,8 +774,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(), |
| @@ -799,16 +796,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. |
| @@ -839,12 +837,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); |
| @@ -863,8 +862,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); |
| @@ -884,23 +884,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)) { |
| @@ -922,7 +922,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); |
| @@ -932,26 +937,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. |
| @@ -959,7 +965,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); |
| @@ -971,8 +978,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. |
| @@ -981,11 +988,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(); |
| @@ -1015,13 +1022,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)) { |
| @@ -1036,7 +1044,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); |
| @@ -1044,7 +1052,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 |
| @@ -1062,18 +1070,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 |
| @@ -1086,7 +1094,7 @@ ChromeLauncherAppMenuItems ChromeLauncherController::GetApplicationList( |
| } |
| std::vector<content::WebContents*> |
| -ChromeLauncherController::GetV1ApplicationsFromAppId( |
| +ChromeLauncherControllerImpl::GetV1ApplicationsFromAppId( |
| const std::string& app_id) { |
| ash::ShelfID id = GetShelfIDForAppID(app_id); |
| @@ -1100,8 +1108,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); |
| @@ -1113,7 +1121,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) != |
| @@ -1123,7 +1131,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) { |
| @@ -1140,7 +1148,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)) |
| @@ -1153,7 +1161,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()) |
| @@ -1169,32 +1177,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); |
| @@ -1206,7 +1213,7 @@ bool ChromeLauncherController::GetAppIDForShelfIDConst( |
| } |
| } |
| -void ChromeLauncherController::SetShelfItemDelegateManagerForTest( |
| +void ChromeLauncherControllerImpl::SetShelfItemDelegateManagerForTest( |
| ash::ShelfItemDelegateManager* manager) { |
| if (item_delegate_manager_) |
| item_delegate_manager_->RemoveObserver(this); |
| @@ -1217,7 +1224,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; |
| @@ -1229,7 +1236,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); |
| @@ -1254,7 +1261,8 @@ void ChromeLauncherController::RestoreUnpinnedRunningApplicationOrder( |
| } |
| } |
| -ash::ShelfID ChromeLauncherController::CreateAppShortcutLauncherItemWithType( |
| +ash::ShelfID |
| +ChromeLauncherControllerImpl::CreateAppShortcutLauncherItemWithType( |
| const std::string& app_id, |
| int index, |
| ash::ShelfItemType shelf_item_type) { |
| @@ -1265,23 +1273,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( |
| @@ -1305,12 +1313,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); |
| @@ -1326,7 +1335,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; |
| @@ -1343,14 +1352,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 || |
| @@ -1367,7 +1376,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); |
| @@ -1380,7 +1389,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. |
| @@ -1420,8 +1429,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 { |
| @@ -1440,8 +1449,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|). |
| @@ -1521,13 +1529,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) { |
| @@ -1537,7 +1545,7 @@ void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() { |
| } |
| } |
| -void ChromeLauncherController::SetShelfAlignmentFromPrefs() { |
| +void ChromeLauncherControllerImpl::SetShelfAlignmentFromPrefs() { |
| if (!ash::ShelfWidget::ShelfAlignmentAllowed()) |
| return; |
| @@ -1550,22 +1558,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) |
| @@ -1574,12 +1582,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_| |
| @@ -1588,8 +1595,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; |
| } |
| @@ -1598,7 +1606,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, |
| @@ -1634,7 +1642,7 @@ ash::ShelfID ChromeLauncherController::InsertAppLauncherItem( |
| } |
| std::vector<content::WebContents*> |
| -ChromeLauncherController::GetV1ApplicationsFromController( |
| +ChromeLauncherControllerImpl::GetV1ApplicationsFromController( |
| LauncherItemController* controller) { |
| DCHECK(controller->type() == LauncherItemController::TYPE_SHORTCUT); |
| AppShortcutLauncherItemController* app_controller = |
| @@ -1643,9 +1651,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) |
| @@ -1656,7 +1664,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(); |
| @@ -1672,11 +1680,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, |
| @@ -1684,22 +1692,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 |
| @@ -1718,15 +1724,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(); |
| @@ -1739,7 +1744,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()); |
| @@ -1747,7 +1752,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 |
| @@ -1773,7 +1778,7 @@ void ChromeLauncherController::CloseWindowedAppsFromRemovedExtension( |
| } |
| } |
| -void ChromeLauncherController::SetShelfItemDelegate( |
| +void ChromeLauncherControllerImpl::SetShelfItemDelegate( |
| ash::ShelfID id, |
| ash::ShelfItemDelegate* item_delegate) { |
| DCHECK_GT(id, 0); |
| @@ -1783,7 +1788,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. |
| @@ -1802,39 +1807,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_)); |
| @@ -1847,7 +1853,7 @@ void ChromeLauncherController::AttachProfile(Profile* profile) { |
| } |
| } |
| -void ChromeLauncherController::ReleaseProfile() { |
| +void ChromeLauncherControllerImpl::ReleaseProfile() { |
| if (app_sync_ui_state_) |
| app_sync_ui_state_->RemoveObserver(this); |
| @@ -1858,7 +1864,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)) |