| Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.cc
|
| diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.cc
|
| index a9e86d55f628d782a2baaa97bf1d23b8212f13b7..2cad3570852388d49010d072ed1b1245e22a4d3f 100644
|
| --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.cc
|
| +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.cc
|
| @@ -4,23 +4,58 @@
|
|
|
| #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.h"
|
|
|
| -#include "chrome/browser/profiles/profile_manager.h"
|
| -#include "chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.h"
|
| -
|
| -// static
|
| -ChromeLauncherController* ChromeLauncherControllerMus::CreateInstance() {
|
| - DCHECK(!ChromeLauncherController::instance());
|
| - ChromeLauncherControllerMus* instance = new ChromeLauncherControllerMus();
|
| - ChromeLauncherController::set_instance(instance);
|
| - return instance;
|
| -}
|
| -
|
| -ChromeLauncherControllerMus::ChromeLauncherControllerMus()
|
| - : shelf_controller_(new ChromeMashShelfController) {}
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
|
| +#include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
|
| +#include "extensions/grit/extensions_browser_resources.h"
|
| +#include "mojo/common/common_type_converters.h"
|
| +#include "ui/base/resource/resource_bundle.h"
|
| +
|
| +class ChromeShelfItemDelegate : public ash::mojom::ShelfItemDelegate {
|
| + public:
|
| + explicit ChromeShelfItemDelegate(const std::string& app_id,
|
| + ChromeLauncherController* controller)
|
| + : app_id_(app_id),
|
| + item_delegate_binding_(this),
|
| + controller_(controller) {}
|
| + ~ChromeShelfItemDelegate() override {}
|
| +
|
| + ash::mojom::ShelfItemDelegateAssociatedPtrInfo CreateInterfacePtrInfoAndBind(
|
| + mojo::AssociatedGroup* associated_group) {
|
| + DCHECK(!item_delegate_binding_.is_bound());
|
| + ash::mojom::ShelfItemDelegateAssociatedPtrInfo ptr_info;
|
| + item_delegate_binding_.Bind(&ptr_info, associated_group);
|
| + return ptr_info;
|
| + }
|
| +
|
| + private:
|
| + // ash::mojom::ShelfItemDelegate:
|
| + void LaunchItem() override {
|
| + controller_->LaunchApp(app_id_, ash::LAUNCH_FROM_UNKNOWN, ui::EF_NONE);
|
| + }
|
| + void ExecuteCommand(uint32_t command_id, int32_t event_flags) override {
|
| + NOTIMPLEMENTED();
|
| + }
|
| + void ItemPinned() override { NOTIMPLEMENTED(); }
|
| + void ItemUnpinned() override { NOTIMPLEMENTED(); }
|
| + void ItemReordered(uint32_t order) override { NOTIMPLEMENTED(); }
|
| +
|
| + std::string app_id_;
|
| + mojo::AssociatedBinding<ash::mojom::ShelfItemDelegate> item_delegate_binding_;
|
| +
|
| + // Not owned.
|
| + ChromeLauncherController* controller_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ChromeShelfItemDelegate);
|
| +};
|
| +
|
| +ChromeLauncherControllerMus::ChromeLauncherControllerMus() {}
|
|
|
| ChromeLauncherControllerMus::~ChromeLauncherControllerMus() {}
|
|
|
| -void ChromeLauncherControllerMus::Init() {}
|
| +void ChromeLauncherControllerMus::Init() {
|
| + NOTIMPLEMENTED();
|
| +}
|
|
|
| ash::ShelfID ChromeLauncherControllerMus::CreateAppLauncherItem(
|
| LauncherItemController* controller,
|
| @@ -93,12 +128,6 @@ bool ChromeLauncherControllerMus::IsPlatformApp(ash::ShelfID id) {
|
| return false;
|
| }
|
|
|
| -void ChromeLauncherControllerMus::LaunchApp(const std::string& app_id,
|
| - ash::LaunchSource source,
|
| - int event_flags) {
|
| - shelf_controller_->LaunchItem(app_id);
|
| -}
|
| -
|
| void ChromeLauncherControllerMus::ActivateApp(const std::string& app_id,
|
| ash::LaunchSource source,
|
| int event_flags) {
|
| @@ -129,10 +158,6 @@ void ChromeLauncherControllerMus::SetLaunchType(
|
| NOTIMPLEMENTED();
|
| }
|
|
|
| -Profile* ChromeLauncherControllerMus::GetProfile() {
|
| - return ProfileManager::GetActiveUserProfile();
|
| -}
|
| -
|
| void ChromeLauncherControllerMus::UpdateAppState(content::WebContents* contents,
|
| AppState app_state) {
|
| NOTIMPLEMENTED();
|
| @@ -239,3 +264,43 @@ ChromeLauncherControllerMus::GetArcDeferredLauncher() {
|
| NOTIMPLEMENTED();
|
| return nullptr;
|
| }
|
| +
|
| +void ChromeLauncherControllerMus::OnAppImageUpdated(
|
| + const std::string& app_id,
|
| + const gfx::ImageSkia& image) {
|
| + if (ConnectToShelfController())
|
| + shelf_controller()->SetItemImage(app_id, *image.bitmap());
|
| +}
|
| +
|
| +void ChromeLauncherControllerMus::PinAppsFromPrefs() {
|
| + if (!ConnectToShelfController())
|
| + return;
|
| +
|
| + std::vector<std::string> pinned_apps = ash::launcher::GetPinnedAppsFromPrefs(
|
| + profile()->GetPrefs(), launcher_controller_helper());
|
| +
|
| + for (const auto& app : pinned_apps) {
|
| + if (app == ash::launcher::kPinnedAppsPlaceholder)
|
| + continue;
|
| +
|
| + ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New());
|
| + item->app_id = app;
|
| + item->app_title = mojo::String::From(
|
| + launcher_controller_helper()->GetAppTitle(profile(), app));
|
| + ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| + const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON);
|
| + item->image = *image.ToSkBitmap();
|
| + std::unique_ptr<ChromeShelfItemDelegate> delegate(
|
| + new ChromeShelfItemDelegate(app, this));
|
| + shelf_controller()->PinItem(std::move(item),
|
| + delegate->CreateInterfacePtrInfoAndBind(
|
| + shelf_controller().associated_group()));
|
| + app_id_to_item_delegate_.insert(std::make_pair(app, std::move(delegate)));
|
| +
|
| + AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app);
|
| + if (app_icon_loader) {
|
| + app_icon_loader->FetchImage(app);
|
| + app_icon_loader->UpdateImage(app);
|
| + }
|
| + }
|
| +}
|
|
|