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

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

Issue 2391253004: Use mojo Shelf interfaces for both mash and classic ash. (Closed)
Patch Set: Fix and workaround test issues. Created 4 years, 2 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 "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
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 26 matching lines...) Expand all
100 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); 100 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
101 app_controller_map_.erase(shelf_app_id); 101 app_controller_map_.erase(shelf_app_id);
102 } 102 }
103 103
104 void ArcAppDeferredLauncherController::Close(const std::string& app_id) { 104 void ArcAppDeferredLauncherController::Close(const std::string& app_id) {
105 const std::string shelf_app_id = 105 const std::string shelf_app_id =
106 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); 106 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
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
111 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); 110 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id);
112 const bool need_close_item = 111 const bool need_close_item =
113 it->second == owner_->GetLauncherItemController(shelf_id); 112 it->second == owner_->GetLauncherItemController(shelf_id);
114 app_controller_map_.erase(it); 113 app_controller_map_.erase(it);
115 if (need_close_item) 114 if (need_close_item)
116 owner_->CloseLauncherItem(shelf_id); 115 owner_->CloseLauncherItem(shelf_id);
117 owner_->OnAppUpdated(owner_->GetProfile(), shelf_app_id); 116 owner_->OnAppUpdated(owner_->profile(), shelf_app_id);
118 } 117 }
119 118
120 void ArcAppDeferredLauncherController::OnAppReadyChanged( 119 void ArcAppDeferredLauncherController::OnAppReadyChanged(
121 const std::string& app_id, 120 const std::string& app_id,
122 bool ready) { 121 bool ready) {
123 if (!ready || app_controller_map_.empty()) 122 if (!ready || app_controller_map_.empty())
124 return; 123 return;
125 124
126 const std::string shelf_app_id = 125 const std::string shelf_app_id =
127 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); 126 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 160
162 return it->second->GetActiveTime(); 161 return it->second->GetActiveTime();
163 } 162 }
164 163
165 void ArcAppDeferredLauncherController::UpdateApps() { 164 void ArcAppDeferredLauncherController::UpdateApps() {
166 if (app_controller_map_.empty()) 165 if (app_controller_map_.empty())
167 return; 166 return;
168 167
169 RegisterNextUpdate(); 168 RegisterNextUpdate();
170 for (const auto pair : app_controller_map_) 169 for (const auto pair : app_controller_map_)
171 owner_->OnAppUpdated(owner_->GetProfile(), pair.first); 170 owner_->OnAppUpdated(owner_->profile(), pair.first);
172 } 171 }
173 172
174 void ArcAppDeferredLauncherController::RegisterNextUpdate() { 173 void ArcAppDeferredLauncherController::RegisterNextUpdate() {
175 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 174 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
176 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps, 175 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps,
177 weak_ptr_factory_.GetWeakPtr()), 176 weak_ptr_factory_.GetWeakPtr()),
178 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs)); 177 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs));
179 } 178 }
180 179
181 void ArcAppDeferredLauncherController::RegisterDeferredLaunch( 180 void ArcAppDeferredLauncherController::RegisterDeferredLaunch(
(...skipping 26 matching lines...) Expand all
208 } else { 207 } else {
209 owner_->SetItemController(shelf_id, controller); 208 owner_->SetItemController(shelf_id, controller);
210 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 209 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
211 } 210 }
212 211
213 if (app_controller_map_.empty()) 212 if (app_controller_map_.empty())
214 RegisterNextUpdate(); 213 RegisterNextUpdate();
215 214
216 app_controller_map_[shelf_app_id] = controller; 215 app_controller_map_[shelf_app_id] = controller;
217 } 216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698