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

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

Issue 2290603002: Enhance chrome.app.window API for shelf integration with pinning support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 app_controller_map_.erase(shelf_app_id); 92 app_controller_map_.erase(shelf_app_id);
93 } 93 }
94 94
95 void ArcAppDeferredLauncherController::Close(const std::string& app_id) { 95 void ArcAppDeferredLauncherController::Close(const std::string& app_id) {
96 const std::string shelf_app_id = 96 const std::string shelf_app_id =
97 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); 97 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
98 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); 98 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id);
99 if (it == app_controller_map_.end()) 99 if (it == app_controller_map_.end())
100 return; 100 return;
101 101
102 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); 102 const ash::ShelfID shelf_id =
103 owner_->GetShelfIDForAppID(shelf_app_id, shelf_app_id);
103 const bool need_close_item = 104 const bool need_close_item =
104 it->second == owner_->GetLauncherItemController(shelf_id); 105 it->second == owner_->GetLauncherItemController(shelf_id);
105 app_controller_map_.erase(it); 106 app_controller_map_.erase(it);
106 if (need_close_item) 107 if (need_close_item)
107 owner_->CloseLauncherItem(shelf_id); 108 owner_->CloseLauncherItem(shelf_id);
108 owner_->OnAppUpdated(owner_->GetProfile(), shelf_app_id); 109 owner_->OnAppUpdated(owner_->GetProfile(), shelf_app_id);
109 } 110 }
110 111
111 void ArcAppDeferredLauncherController::OnAppReadyChanged( 112 void ArcAppDeferredLauncherController::OnAppReadyChanged(
112 const std::string& app_id, 113 const std::string& app_id,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 152 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
152 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps, 153 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps,
153 weak_ptr_factory_.GetWeakPtr()), 154 weak_ptr_factory_.GetWeakPtr()),
154 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs)); 155 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs));
155 } 156 }
156 157
157 void ArcAppDeferredLauncherController::RegisterDeferredLaunch( 158 void ArcAppDeferredLauncherController::RegisterDeferredLaunch(
158 const std::string& app_id) { 159 const std::string& app_id) {
159 const std::string shelf_app_id = 160 const std::string shelf_app_id =
160 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); 161 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
161 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); 162 const ash::ShelfID shelf_id =
163 owner_->GetShelfIDForAppID(shelf_app_id, shelf_app_id);
162 164
163 if (shelf_id) { 165 if (shelf_id) {
164 LauncherItemController* controller = 166 LauncherItemController* controller =
165 owner_->GetLauncherItemController(shelf_id); 167 owner_->GetLauncherItemController(shelf_id);
166 if (controller && 168 if (controller &&
167 controller->type() != LauncherItemController::TYPE_SHORTCUT) { 169 controller->type() != LauncherItemController::TYPE_SHORTCUT) {
168 // We are allowed to apply new deferred controller only over shortcut. 170 // We are allowed to apply new deferred controller only over shortcut.
169 return; 171 return;
170 } 172 }
171 } 173 }
172 174
173 ArcAppDeferredLauncherItemController* controller = 175 ArcAppDeferredLauncherItemController* controller =
174 new ArcAppDeferredLauncherItemController(shelf_app_id, owner_, 176 new ArcAppDeferredLauncherItemController(shelf_app_id, owner_,
175 weak_ptr_factory_.GetWeakPtr()); 177 weak_ptr_factory_.GetWeakPtr());
176 if (shelf_id == 0) { 178 if (shelf_id == 0) {
177 owner_->CreateAppLauncherItem(controller, shelf_app_id, 179 owner_->CreateAppLauncherItem(controller, shelf_app_id,
178 ash::STATUS_RUNNING); 180 ash::STATUS_RUNNING);
179 } else { 181 } else {
180 owner_->SetItemController(shelf_id, controller); 182 owner_->SetItemController(shelf_id, controller);
181 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 183 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
182 } 184 }
183 185
184 if (app_controller_map_.empty()) 186 if (app_controller_map_.empty())
185 RegisterNextUpdate(); 187 RegisterNextUpdate();
186 188
187 app_controller_map_[shelf_app_id] = controller; 189 app_controller_map_[shelf_app_id] = controller;
188 } 190 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698