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

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

Issue 2819413003: Refactor extension app icon. (Closed)
Patch Set: nits 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/shelf/shelf_model.h" 7 #include "ash/shelf/shelf_model.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (it == app_controller_map_.end()) 112 if (it == app_controller_map_.end())
113 return; 113 return;
114 114
115 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); 115 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id);
116 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model(); 116 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model();
117 const bool need_close_item = 117 const bool need_close_item =
118 it->second == shelf_model->GetShelfItemDelegate(shelf_id); 118 it->second == shelf_model->GetShelfItemDelegate(shelf_id);
119 app_controller_map_.erase(it); 119 app_controller_map_.erase(it);
120 if (need_close_item) 120 if (need_close_item)
121 owner_->CloseLauncherItem(shelf_id); 121 owner_->CloseLauncherItem(shelf_id);
122 owner_->OnAppUpdated(owner_->profile(), shelf_app_id); 122 UpdateApp(shelf_app_id);
123 } 123 }
124 124
125 void ArcAppDeferredLauncherController::OnAppReadyChanged( 125 void ArcAppDeferredLauncherController::OnAppReadyChanged(
126 const std::string& app_id, 126 const std::string& app_id,
127 bool ready) { 127 bool ready) {
128 if (!ready || app_controller_map_.empty()) 128 if (!ready || app_controller_map_.empty())
129 return; 129 return;
130 130
131 const std::string shelf_app_id = 131 const std::string shelf_app_id =
132 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); 132 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
(...skipping 30 matching lines...) Expand all
163 163
164 base::TimeDelta ArcAppDeferredLauncherController::GetActiveTime( 164 base::TimeDelta ArcAppDeferredLauncherController::GetActiveTime(
165 const std::string& shelf_app_id) const { 165 const std::string& shelf_app_id) const {
166 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); 166 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id);
167 if (it == app_controller_map_.end()) 167 if (it == app_controller_map_.end())
168 return base::TimeDelta(); 168 return base::TimeDelta();
169 169
170 return it->second->GetActiveTime(); 170 return it->second->GetActiveTime();
171 } 171 }
172 172
173 void ArcAppDeferredLauncherController::UpdateApp(const std::string& app_id) {
174 AppIconLoader* acon_loader = owner_->GetAppIconLoaderForApp(app_id);
Devlin 2017/04/26 22:41:57 typo: s/acon/icon
khmel 2017/04/27 00:18:12 Done.
175 if (acon_loader)
176 acon_loader->UpdateImage(app_id);
177 }
178
173 void ArcAppDeferredLauncherController::UpdateApps() { 179 void ArcAppDeferredLauncherController::UpdateApps() {
174 if (app_controller_map_.empty()) 180 if (app_controller_map_.empty())
175 return; 181 return;
176 182
177 RegisterNextUpdate(); 183 RegisterNextUpdate();
178 for (const auto pair : app_controller_map_) 184 for (const auto pair : app_controller_map_)
179 owner_->OnAppUpdated(owner_->profile(), pair.first); 185 UpdateApp(pair.first);
180 } 186 }
181 187
182 void ArcAppDeferredLauncherController::RegisterNextUpdate() { 188 void ArcAppDeferredLauncherController::RegisterNextUpdate() {
183 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 189 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
184 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps, 190 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps,
185 weak_ptr_factory_.GetWeakPtr()), 191 weak_ptr_factory_.GetWeakPtr()),
186 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs)); 192 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs));
187 } 193 }
188 194
189 void ArcAppDeferredLauncherController::RegisterDeferredLaunch( 195 void ArcAppDeferredLauncherController::RegisterDeferredLaunch(
(...skipping 26 matching lines...) Expand all
216 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model(); 222 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model();
217 shelf_model->SetShelfItemDelegate(shelf_id, std::move(controller)); 223 shelf_model->SetShelfItemDelegate(shelf_id, std::move(controller));
218 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 224 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
219 } 225 }
220 226
221 if (app_controller_map_.empty()) 227 if (app_controller_map_.empty())
222 RegisterNextUpdate(); 228 RegisterNextUpdate();
223 229
224 app_controller_map_[shelf_app_id] = item_controller; 230 app_controller_map_[shelf_app_id] = item_controller;
225 } 231 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698