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

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

Issue 2900783003: Handle app custom icon via aura::Window property. (Closed)
Patch Set: fix mac compile Created 3 years, 6 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/shelf/shelf_model.h" 7 #include "ash/shelf/shelf_model.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "chrome/browser/chromeos/arc/arc_util.h" 10 #include "chrome/browser/chromeos/arc/arc_util.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 AppControllerMap::const_iterator it = app_controller_map_.find(safe_app_id); 109 AppControllerMap::const_iterator it = app_controller_map_.find(safe_app_id);
110 if (it == app_controller_map_.end()) 110 if (it == app_controller_map_.end())
111 return; 111 return;
112 112
113 const ash::ShelfID shelf_id(safe_app_id); 113 const ash::ShelfID shelf_id(safe_app_id);
114 const bool need_close_item = 114 const bool need_close_item =
115 it->second == owner_->shelf_model()->GetShelfItemDelegate(shelf_id); 115 it->second == owner_->shelf_model()->GetShelfItemDelegate(shelf_id);
116 app_controller_map_.erase(it); 116 app_controller_map_.erase(it);
117 if (need_close_item) 117 if (need_close_item)
118 owner_->CloseLauncherItem(shelf_id); 118 owner_->CloseLauncherItem(shelf_id);
119 UpdateApp(safe_app_id); 119 UpdateShelfItemIcon(safe_app_id);
120 } 120 }
121 121
122 void ArcAppDeferredLauncherController::OnAppReadyChanged( 122 void ArcAppDeferredLauncherController::OnAppReadyChanged(
123 const std::string& app_id, 123 const std::string& app_id,
124 bool ready) { 124 bool ready) {
125 if (!ready || app_controller_map_.empty()) 125 if (!ready || app_controller_map_.empty())
126 return; 126 return;
127 127
128 AppControllerMap::const_iterator it = app_controller_map_.find(app_id); 128 AppControllerMap::const_iterator it = app_controller_map_.find(app_id);
129 if (it == app_controller_map_.end()) 129 if (it == app_controller_map_.end())
(...skipping 26 matching lines...) Expand all
156 156
157 base::TimeDelta ArcAppDeferredLauncherController::GetActiveTime( 157 base::TimeDelta ArcAppDeferredLauncherController::GetActiveTime(
158 const std::string& app_id) const { 158 const std::string& app_id) const {
159 AppControllerMap::const_iterator it = app_controller_map_.find(app_id); 159 AppControllerMap::const_iterator it = app_controller_map_.find(app_id);
160 if (it == app_controller_map_.end()) 160 if (it == app_controller_map_.end())
161 return base::TimeDelta(); 161 return base::TimeDelta();
162 162
163 return it->second->GetActiveTime(); 163 return it->second->GetActiveTime();
164 } 164 }
165 165
166 void ArcAppDeferredLauncherController::UpdateApp(const std::string& app_id) { 166 void ArcAppDeferredLauncherController::UpdateShelfItemIcon(
167 AppIconLoader* icon_loader = owner_->GetAppIconLoaderForApp(app_id); 167 const std::string& app_id) {
168 if (icon_loader) 168 owner_->UpdateLauncherItemImage(app_id);
169 icon_loader->UpdateImage(app_id);
170 } 169 }
171 170
172 void ArcAppDeferredLauncherController::UpdateApps() { 171 void ArcAppDeferredLauncherController::UpdateApps() {
173 if (app_controller_map_.empty()) 172 if (app_controller_map_.empty())
174 return; 173 return;
175 174
176 RegisterNextUpdate(); 175 RegisterNextUpdate();
177 for (const auto pair : app_controller_map_) 176 for (const auto pair : app_controller_map_)
178 UpdateApp(pair.first); 177 UpdateShelfItemIcon(pair.first);
179 } 178 }
180 179
181 void ArcAppDeferredLauncherController::RegisterNextUpdate() { 180 void ArcAppDeferredLauncherController::RegisterNextUpdate() {
182 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 181 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
183 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps, 182 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps,
184 weak_ptr_factory_.GetWeakPtr()), 183 weak_ptr_factory_.GetWeakPtr()),
185 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs)); 184 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs));
186 } 185 }
187 186
188 void ArcAppDeferredLauncherController::RegisterDeferredLaunch( 187 void ArcAppDeferredLauncherController::RegisterDeferredLaunch(
(...skipping 24 matching lines...) Expand all
213 owner_->shelf_model()->SetShelfItemDelegate(shelf_id, 212 owner_->shelf_model()->SetShelfItemDelegate(shelf_id,
214 std::move(controller)); 213 std::move(controller));
215 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 214 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
216 } 215 }
217 216
218 if (app_controller_map_.empty()) 217 if (app_controller_map_.empty())
219 RegisterNextUpdate(); 218 RegisterNextUpdate();
220 219
221 app_controller_map_[app_id] = item_controller; 220 app_controller_map_[app_id] = item_controller;
222 } 221 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h ('k') | chrome/browser/ui/ash/launcher/arc_app_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698