OLD | NEW |
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 "chrome/browser/chromeos/arc/arc_support_host.h" | 7 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 9 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
10 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_item_controll
er.h" | 10 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_item_controll
er.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 const std::string shelf_app_id_; | 52 const std::string shelf_app_id_; |
53 const gfx::ImageSkia image_; | 53 const gfx::ImageSkia image_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(SpinningEffectSource); | 55 DISALLOW_COPY_AND_ASSIGN(SpinningEffectSource); |
56 }; | 56 }; |
57 } // namespace | 57 } // namespace |
58 | 58 |
59 ArcAppDeferredLauncherController::ArcAppDeferredLauncherController( | 59 ArcAppDeferredLauncherController::ArcAppDeferredLauncherController( |
60 ChromeLauncherControllerImpl* owner) | 60 ChromeLauncherControllerImpl* owner) |
61 : owner_(owner), weak_ptr_factory_(this) { | 61 : owner_(owner), weak_ptr_factory_(this) { |
62 if (arc::ArcAuthService::IsAllowedForProfile(owner->GetProfile())) { | 62 if (arc::ArcAuthService::IsAllowedForProfile(owner->profile())) { |
63 observed_profile_ = owner->GetProfile(); | 63 observed_profile_ = owner->profile(); |
64 ArcAppListPrefs::Get(observed_profile_)->AddObserver(this); | 64 ArcAppListPrefs::Get(observed_profile_)->AddObserver(this); |
65 } | 65 } |
66 arc::ArcAuthService* auth_service = arc::ArcAuthService::Get(); | 66 arc::ArcAuthService* auth_service = arc::ArcAuthService::Get(); |
67 // arc::ArcAuthService might not be set in tests. | 67 // arc::ArcAuthService might not be set in tests. |
68 if (auth_service) | 68 if (auth_service) |
69 auth_service->AddObserver(this); | 69 auth_service->AddObserver(this); |
70 } | 70 } |
71 | 71 |
72 ArcAppDeferredLauncherController::~ArcAppDeferredLauncherController() { | 72 ArcAppDeferredLauncherController::~ArcAppDeferredLauncherController() { |
73 arc::ArcAuthService* auth_service = arc::ArcAuthService::Get(); | 73 arc::ArcAuthService* auth_service = arc::ArcAuthService::Get(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); | 107 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); |
108 if (it == app_controller_map_.end()) | 108 if (it == app_controller_map_.end()) |
109 return; | 109 return; |
110 | 110 |
111 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); | 111 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); |
112 const bool need_close_item = | 112 const bool need_close_item = |
113 it->second == owner_->GetLauncherItemController(shelf_id); | 113 it->second == owner_->GetLauncherItemController(shelf_id); |
114 app_controller_map_.erase(it); | 114 app_controller_map_.erase(it); |
115 if (need_close_item) | 115 if (need_close_item) |
116 owner_->CloseLauncherItem(shelf_id); | 116 owner_->CloseLauncherItem(shelf_id); |
117 owner_->OnAppUpdated(owner_->GetProfile(), shelf_app_id); | 117 owner_->OnAppUpdated(owner_->profile(), shelf_app_id); |
118 } | 118 } |
119 | 119 |
120 void ArcAppDeferredLauncherController::OnAppReadyChanged( | 120 void ArcAppDeferredLauncherController::OnAppReadyChanged( |
121 const std::string& app_id, | 121 const std::string& app_id, |
122 bool ready) { | 122 bool ready) { |
123 if (!ready || app_controller_map_.empty()) | 123 if (!ready || app_controller_map_.empty()) |
124 return; | 124 return; |
125 | 125 |
126 const std::string shelf_app_id = | 126 const std::string shelf_app_id = |
127 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | 127 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 return it->second->GetActiveTime(); | 162 return it->second->GetActiveTime(); |
163 } | 163 } |
164 | 164 |
165 void ArcAppDeferredLauncherController::UpdateApps() { | 165 void ArcAppDeferredLauncherController::UpdateApps() { |
166 if (app_controller_map_.empty()) | 166 if (app_controller_map_.empty()) |
167 return; | 167 return; |
168 | 168 |
169 RegisterNextUpdate(); | 169 RegisterNextUpdate(); |
170 for (const auto pair : app_controller_map_) | 170 for (const auto pair : app_controller_map_) |
171 owner_->OnAppUpdated(owner_->GetProfile(), pair.first); | 171 owner_->OnAppUpdated(owner_->profile(), pair.first); |
172 } | 172 } |
173 | 173 |
174 void ArcAppDeferredLauncherController::RegisterNextUpdate() { | 174 void ArcAppDeferredLauncherController::RegisterNextUpdate() { |
175 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 175 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
176 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps, | 176 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps, |
177 weak_ptr_factory_.GetWeakPtr()), | 177 weak_ptr_factory_.GetWeakPtr()), |
178 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs)); | 178 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs)); |
179 } | 179 } |
180 | 180 |
181 void ArcAppDeferredLauncherController::RegisterDeferredLaunch( | 181 void ArcAppDeferredLauncherController::RegisterDeferredLaunch( |
(...skipping 26 matching lines...) Expand all Loading... |
208 } else { | 208 } else { |
209 owner_->SetItemController(shelf_id, controller); | 209 owner_->SetItemController(shelf_id, controller); |
210 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); | 210 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
211 } | 211 } |
212 | 212 |
213 if (app_controller_map_.empty()) | 213 if (app_controller_map_.empty()) |
214 RegisterNextUpdate(); | 214 RegisterNextUpdate(); |
215 | 215 |
216 app_controller_map_[shelf_app_id] = controller; | 216 app_controller_map_[shelf_app_id] = controller; |
217 } | 217 } |
OLD | NEW |