Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1379)

Side by Side Diff: chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc

Issue 2800263002: Revert of mash: Remove ChromeLauncherController's |id_to_item_controller_map_|. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h"
6 6
7 #include "ash/common/shelf/shelf_model.h"
8 #include "ash/shell.h"
9 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
11 #include "chrome/browser/chromeos/arc/arc_util.h" 9 #include "chrome/browser/chromeos/arc/arc_util.h"
12 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
14 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_item_controll er.h" 12 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_item_controll er.h"
15 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" 13 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" 14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
17 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
18 #include "ui/gfx/image/canvas_image_source.h" 16 #include "ui/gfx/image/canvas_image_source.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 104 }
107 105
108 void ArcAppDeferredLauncherController::Close(const std::string& app_id) { 106 void ArcAppDeferredLauncherController::Close(const std::string& app_id) {
109 const std::string shelf_app_id = 107 const std::string shelf_app_id =
110 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); 108 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
111 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); 109 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id);
112 if (it == app_controller_map_.end()) 110 if (it == app_controller_map_.end())
113 return; 111 return;
114 112
115 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); 113 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id);
116 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model();
117 const bool need_close_item = 114 const bool need_close_item =
118 it->second == shelf_model->GetShelfItemDelegate(shelf_id); 115 it->second == owner_->GetShelfItemDelegate(shelf_id);
119 app_controller_map_.erase(it); 116 app_controller_map_.erase(it);
120 if (need_close_item) 117 if (need_close_item)
121 owner_->CloseLauncherItem(shelf_id); 118 owner_->CloseLauncherItem(shelf_id);
122 owner_->OnAppUpdated(owner_->profile(), shelf_app_id); 119 owner_->OnAppUpdated(owner_->profile(), shelf_app_id);
123 } 120 }
124 121
125 void ArcAppDeferredLauncherController::OnAppReadyChanged( 122 void ArcAppDeferredLauncherController::OnAppReadyChanged(
126 const std::string& app_id, 123 const std::string& app_id,
127 bool ready) { 124 bool ready) {
128 if (!ready || app_controller_map_.empty()) 125 if (!ready || app_controller_map_.empty())
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (item && item->status != ash::STATUS_CLOSED) 203 if (item && item->status != ash::STATUS_CLOSED)
207 return; 204 return;
208 205
209 std::unique_ptr<ArcAppDeferredLauncherItemController> controller = 206 std::unique_ptr<ArcAppDeferredLauncherItemController> controller =
210 base::MakeUnique<ArcAppDeferredLauncherItemController>( 207 base::MakeUnique<ArcAppDeferredLauncherItemController>(
211 shelf_app_id, event_flags, weak_ptr_factory_.GetWeakPtr()); 208 shelf_app_id, event_flags, weak_ptr_factory_.GetWeakPtr());
212 ArcAppDeferredLauncherItemController* item_controller = controller.get(); 209 ArcAppDeferredLauncherItemController* item_controller = controller.get();
213 if (shelf_id == 0) { 210 if (shelf_id == 0) {
214 owner_->CreateAppLauncherItem(std::move(controller), ash::STATUS_RUNNING); 211 owner_->CreateAppLauncherItem(std::move(controller), ash::STATUS_RUNNING);
215 } else { 212 } else {
216 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model(); 213 owner_->SetShelfItemDelegate(shelf_id, std::move(controller));
217 shelf_model->SetShelfItemDelegate(shelf_id, std::move(controller));
218 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 214 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
219 } 215 }
220 216
221 if (app_controller_map_.empty()) 217 if (app_controller_map_.empty())
222 RegisterNextUpdate(); 218 RegisterNextUpdate();
223 219
224 app_controller_map_[shelf_app_id] = item_controller; 220 app_controller_map_[shelf_app_id] = item_controller;
225 } 221 }
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_view.cc ('k') | chrome/browser/ui/ash/launcher/arc_app_launcher_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698