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

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

Issue 2819413003: Refactor extension app icon. (Closed)
Patch Set: nit Created 3 years, 7 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); 110 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id);
111 if (it == app_controller_map_.end()) 111 if (it == app_controller_map_.end())
112 return; 112 return;
113 113
114 const ash::ShelfID shelf_id(shelf_app_id); 114 const ash::ShelfID shelf_id(shelf_app_id);
115 const bool need_close_item = 115 const bool need_close_item =
116 it->second == owner_->shelf_model()->GetShelfItemDelegate(shelf_id); 116 it->second == owner_->shelf_model()->GetShelfItemDelegate(shelf_id);
117 app_controller_map_.erase(it); 117 app_controller_map_.erase(it);
118 if (need_close_item) 118 if (need_close_item)
119 owner_->CloseLauncherItem(shelf_id); 119 owner_->CloseLauncherItem(shelf_id);
120 owner_->OnAppUpdated(owner_->profile(), shelf_app_id); 120 UpdateApp(shelf_app_id);
121 } 121 }
122 122
123 void ArcAppDeferredLauncherController::OnAppReadyChanged( 123 void ArcAppDeferredLauncherController::OnAppReadyChanged(
124 const std::string& app_id, 124 const std::string& app_id,
125 bool ready) { 125 bool ready) {
126 if (!ready || app_controller_map_.empty()) 126 if (!ready || app_controller_map_.empty())
127 return; 127 return;
128 128
129 const std::string shelf_app_id = 129 const std::string shelf_app_id =
130 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); 130 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
(...skipping 30 matching lines...) Expand all
161 161
162 base::TimeDelta ArcAppDeferredLauncherController::GetActiveTime( 162 base::TimeDelta ArcAppDeferredLauncherController::GetActiveTime(
163 const std::string& shelf_app_id) const { 163 const std::string& shelf_app_id) const {
164 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); 164 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id);
165 if (it == app_controller_map_.end()) 165 if (it == app_controller_map_.end())
166 return base::TimeDelta(); 166 return base::TimeDelta();
167 167
168 return it->second->GetActiveTime(); 168 return it->second->GetActiveTime();
169 } 169 }
170 170
171 void ArcAppDeferredLauncherController::UpdateApp(const std::string& app_id) {
172 AppIconLoader* icon_loader = owner_->GetAppIconLoaderForApp(app_id);
173 if (icon_loader)
174 icon_loader->UpdateImage(app_id);
175 }
176
171 void ArcAppDeferredLauncherController::UpdateApps() { 177 void ArcAppDeferredLauncherController::UpdateApps() {
172 if (app_controller_map_.empty()) 178 if (app_controller_map_.empty())
173 return; 179 return;
174 180
175 RegisterNextUpdate(); 181 RegisterNextUpdate();
176 for (const auto pair : app_controller_map_) 182 for (const auto pair : app_controller_map_)
177 owner_->OnAppUpdated(owner_->profile(), pair.first); 183 UpdateApp(pair.first);
178 } 184 }
179 185
180 void ArcAppDeferredLauncherController::RegisterNextUpdate() { 186 void ArcAppDeferredLauncherController::RegisterNextUpdate() {
181 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 187 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
182 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps, 188 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps,
183 weak_ptr_factory_.GetWeakPtr()), 189 weak_ptr_factory_.GetWeakPtr()),
184 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs)); 190 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs));
185 } 191 }
186 192
187 void ArcAppDeferredLauncherController::RegisterDeferredLaunch( 193 void ArcAppDeferredLauncherController::RegisterDeferredLaunch(
(...skipping 26 matching lines...) Expand all
214 owner_->shelf_model()->SetShelfItemDelegate(shelf_id, 220 owner_->shelf_model()->SetShelfItemDelegate(shelf_id,
215 std::move(controller)); 221 std::move(controller));
216 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 222 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
217 } 223 }
218 224
219 if (app_controller_map_.empty()) 225 if (app_controller_map_.empty())
220 RegisterNextUpdate(); 226 RegisterNextUpdate();
221 227
222 app_controller_map_[shelf_app_id] = item_controller; 228 app_controller_map_[shelf_app_id] = item_controller;
223 } 229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698