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

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

Issue 2540433002: Reland "Propagate information about how ARC apps are launched" (Closed)
Patch Set: Rebase to ToT Created 4 years 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
128 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); 128 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id);
129 if (it == app_controller_map_.end()) 129 if (it == app_controller_map_.end())
130 return; 130 return;
131 131
132 Close(app_id); 132 Close(app_id);
133 133
134 arc::LaunchApp(observed_profile_, app_id); 134 arc::LaunchApp(observed_profile_, app_id, it->second->event_flags());
135 } 135 }
136 136
137 void ArcAppDeferredLauncherController::OnAppRemoved(const std::string& app_id) { 137 void ArcAppDeferredLauncherController::OnAppRemoved(const std::string& app_id) {
138 Close(app_id); 138 Close(app_id);
139 } 139 }
140 140
141 void ArcAppDeferredLauncherController::OnOptInEnabled(bool enabled) { 141 void ArcAppDeferredLauncherController::OnOptInEnabled(bool enabled) {
142 if (enabled) 142 if (enabled)
143 return; 143 return;
144 144
(...skipping 27 matching lines...) Expand all
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(
182 const std::string& app_id) { 182 const std::string& app_id,
183 int event_flags) {
183 const arc::ArcSessionManager* arc_session_manager = 184 const arc::ArcSessionManager* arc_session_manager =
184 arc::ArcSessionManager::Get(); 185 arc::ArcSessionManager::Get();
185 DCHECK(arc_session_manager); 186 DCHECK(arc_session_manager);
186 DCHECK(arc_session_manager->state() != 187 DCHECK(arc_session_manager->state() !=
187 arc::ArcSessionManager::State::STOPPED); 188 arc::ArcSessionManager::State::STOPPED);
188 DCHECK(arc_session_manager->state() != 189 DCHECK(arc_session_manager->state() !=
189 arc::ArcSessionManager::State::NOT_INITIALIZED); 190 arc::ArcSessionManager::State::NOT_INITIALIZED);
190 191
191 const std::string shelf_app_id = 192 const std::string shelf_app_id =
192 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); 193 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
193 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); 194 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id);
194 195
195 if (shelf_id) { 196 if (shelf_id) {
196 LauncherItemController* controller = 197 LauncherItemController* controller =
197 owner_->GetLauncherItemController(shelf_id); 198 owner_->GetLauncherItemController(shelf_id);
198 if (controller && 199 if (controller &&
199 controller->type() != LauncherItemController::TYPE_SHORTCUT) { 200 controller->type() != LauncherItemController::TYPE_SHORTCUT) {
200 // We are allowed to apply new deferred controller only over shortcut. 201 // We are allowed to apply new deferred controller only over shortcut.
201 return; 202 return;
202 } 203 }
203 } 204 }
204 205
205 ArcAppDeferredLauncherItemController* controller = 206 ArcAppDeferredLauncherItemController* controller =
206 new ArcAppDeferredLauncherItemController(shelf_app_id, owner_, 207 new ArcAppDeferredLauncherItemController(
207 weak_ptr_factory_.GetWeakPtr()); 208 shelf_app_id, owner_, event_flags, weak_ptr_factory_.GetWeakPtr());
208 if (shelf_id == 0) { 209 if (shelf_id == 0) {
209 owner_->CreateAppLauncherItem(controller, shelf_app_id, 210 owner_->CreateAppLauncherItem(controller, shelf_app_id,
210 ash::STATUS_RUNNING); 211 ash::STATUS_RUNNING);
211 } else { 212 } else {
212 owner_->SetItemController(shelf_id, controller); 213 owner_->SetItemController(shelf_id, controller);
213 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 214 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
214 } 215 }
215 216
216 if (app_controller_map_.empty()) 217 if (app_controller_map_.empty())
217 RegisterNextUpdate(); 218 RegisterNextUpdate();
218 219
219 app_controller_map_[shelf_app_id] = controller; 220 app_controller_map_[shelf_app_id] = controller;
220 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698