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

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

Issue 2052013002: Adding ChromeLauncherController interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome_launcher_smaller_api
Patch Set: Rebase Created 4 years, 6 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 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" 4 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
5 5
6 #include "ash/common/wm/window_state.h" 6 #include "ash/common/wm/window_state.h"
7 #include "ash/shelf/shelf_delegate.h"
7 #include "ash/shelf/shelf_util.h" 8 #include "ash/shelf/shelf_util.h"
8 #include "ash/wm/window_state_aura.h" 9 #include "ash/wm/window_state_aura.h"
9 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "chrome/browser/chromeos/arc/arc_auth_service.h" 12 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
12 #include "chrome/browser/chromeos/arc/arc_support_host.h" 13 #include "chrome/browser/chromeos/arc/arc_support_host.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 15 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
15 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller .h" 16 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller .h"
16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // Unowned pointers 180 // Unowned pointers
180 ArcAppWindowLauncherController* owner_; 181 ArcAppWindowLauncherController* owner_;
181 ArcAppWindowLauncherItemController* controller_ = nullptr; 182 ArcAppWindowLauncherItemController* controller_ = nullptr;
182 // Unowned pointer, represents host Arc window. 183 // Unowned pointer, represents host Arc window.
183 views::Widget* widget_ = nullptr; 184 views::Widget* widget_ = nullptr;
184 185
185 DISALLOW_COPY_AND_ASSIGN(AppWindow); 186 DISALLOW_COPY_AND_ASSIGN(AppWindow);
186 }; 187 };
187 188
188 ArcAppWindowLauncherController::ArcAppWindowLauncherController( 189 ArcAppWindowLauncherController::ArcAppWindowLauncherController(
189 ChromeLauncherController* owner) 190 ChromeLauncherController* owner,
190 : AppWindowLauncherController(owner) { 191 ash::ShelfDelegate* shelf_delegate)
191 if (arc::ArcAuthService::IsAllowedForProfile(owner->profile())) { 192 : AppWindowLauncherController(owner), shelf_delegate_(shelf_delegate) {
192 observed_profile_ = owner->profile(); 193 if (arc::ArcAuthService::IsAllowedForProfile(owner->GetProfile())) {
194 observed_profile_ = owner->GetProfile();
193 StartObserving(observed_profile_); 195 StartObserving(observed_profile_);
194 } 196 }
195 } 197 }
196 198
197 ArcAppWindowLauncherController::~ArcAppWindowLauncherController() { 199 ArcAppWindowLauncherController::~ArcAppWindowLauncherController() {
198 if (observed_profile_) 200 if (observed_profile_)
199 StopObserving(observed_profile_); 201 StopObserving(observed_profile_);
200 } 202 }
201 203
202 void ArcAppWindowLauncherController::ActiveUserChanged( 204 void ArcAppWindowLauncherController::ActiveUserChanged(
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 if (it == task_id_to_app_window_.end()) 329 if (it == task_id_to_app_window_.end())
328 return; 330 return;
329 331
330 AppWindow* app_window = it->second.get(); 332 AppWindow* app_window = it->second.get();
331 UnregisterApp(app_window); 333 UnregisterApp(app_window);
332 334
333 task_id_to_app_window_.erase(it); 335 task_id_to_app_window_.erase(it);
334 } 336 }
335 337
336 void ArcAppWindowLauncherController::OnTaskSetActive(int32_t task_id) { 338 void ArcAppWindowLauncherController::OnTaskSetActive(int32_t task_id) {
337 if (observed_profile_ != owner()->profile()) 339 if (observed_profile_ != owner()->GetProfile())
338 return; 340 return;
339 341
340 TaskIdToAppWindow::iterator previous_active_app_it = 342 TaskIdToAppWindow::iterator previous_active_app_it =
341 task_id_to_app_window_.find(active_task_id_); 343 task_id_to_app_window_.find(active_task_id_);
342 if (previous_active_app_it != task_id_to_app_window_.end()) { 344 if (previous_active_app_it != task_id_to_app_window_.end()) {
343 owner()->SetItemStatus(previous_active_app_it->second->shelf_id(), 345 owner()->SetItemStatus(previous_active_app_it->second->shelf_id(),
344 ash::STATUS_RUNNING); 346 ash::STATUS_RUNNING);
345 previous_active_app_it->second->SetFullscreenMode( 347 previous_active_app_it->second->SetFullscreenMode(
346 previous_active_app_it->second->widget() && 348 previous_active_app_it->second->widget() &&
347 previous_active_app_it->second->widget()->IsFullscreen() 349 previous_active_app_it->second->widget()->IsFullscreen()
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 420
419 ArcAppWindowLauncherItemController* controller; 421 ArcAppWindowLauncherItemController* controller;
420 AppControllerMap::iterator it = app_controller_map_.find(app_id); 422 AppControllerMap::iterator it = app_controller_map_.find(app_id);
421 ash::ShelfID shelf_id = 0; 423 ash::ShelfID shelf_id = 0;
422 if (it != app_controller_map_.end()) { 424 if (it != app_controller_map_.end()) {
423 controller = it->second; 425 controller = it->second;
424 DCHECK_EQ(controller->app_id(), app_id); 426 DCHECK_EQ(controller->app_id(), app_id);
425 shelf_id = controller->shelf_id(); 427 shelf_id = controller->shelf_id();
426 } else { 428 } else {
427 controller = new ArcAppWindowLauncherItemController(app_id, owner()); 429 controller = new ArcAppWindowLauncherItemController(app_id, owner());
428 shelf_id = owner()->GetShelfIDForAppID(app_id); 430 shelf_id = shelf_delegate_->GetShelfIDForAppID(app_id);
429 if (shelf_id == 0) { 431 if (shelf_id == 0) {
430 // Map Play Store shelf icon to Arc Support host, to share one entry. 432 // Map Play Store shelf icon to Arc Support host, to share one entry.
431 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, 433 shelf_id = owner()->CreateAppLauncherItem(controller, app_id,
432 ash::STATUS_RUNNING); 434 ash::STATUS_RUNNING);
433 } else { 435 } else {
434 owner()->SetItemController(shelf_id, controller); 436 owner()->SetItemController(shelf_id, controller);
435 } 437 }
436 app_controller_map_[app_id] = controller; 438 app_controller_map_[app_id] = controller;
437 } 439 }
438 controller->AddWindow(app_window); 440 controller->AddWindow(app_window);
439 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 441 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
440 app_window->SetController(controller); 442 app_window->SetController(controller);
441 app_window->set_shelf_id(shelf_id); 443 app_window->set_shelf_id(shelf_id);
442 } 444 }
443 445
444 void ArcAppWindowLauncherController::UnregisterApp(AppWindow* app_window) { 446 void ArcAppWindowLauncherController::UnregisterApp(AppWindow* app_window) {
445 const std::string app_id = app_window->app_id(); 447 const std::string app_id = app_window->app_id();
446 DCHECK(!app_id.empty()); 448 DCHECK(!app_id.empty());
447 AppControllerMap::iterator it = app_controller_map_.find(app_id); 449 AppControllerMap::iterator it = app_controller_map_.find(app_id);
448 DCHECK(it != app_controller_map_.end()); 450 DCHECK(it != app_controller_map_.end());
449 451
450 ArcAppWindowLauncherItemController* controller = it->second; 452 ArcAppWindowLauncherItemController* controller = it->second;
451 controller->RemoveWindow(app_window); 453 controller->RemoveWindow(app_window);
452 if (!controller->window_count()) { 454 if (!controller->window_count()) {
453 ash::ShelfID shelf_id = app_window->shelf_id(); 455 ash::ShelfID shelf_id = app_window->shelf_id();
454 owner()->CloseLauncherItem(shelf_id); 456 owner()->CloseLauncherItem(shelf_id);
455 app_controller_map_.erase(it); 457 app_controller_map_.erase(it);
456 } 458 }
457 } 459 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698