Chromium Code Reviews| 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 #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 <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "ash/display/screen_orientation_controller_chromeos.h" | 8 #include "ash/display/screen_orientation_controller_chromeos.h" |
| 9 #include "ash/public/cpp/window_properties.h" | 9 #include "ash/public/cpp/window_properties.h" |
| 10 #include "ash/shared/app_types.h" | 10 #include "ash/shared/app_types.h" |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 647 if (it != app_shelf_group_to_controller_map_.end()) { | 647 if (it != app_shelf_group_to_controller_map_.end()) { |
| 648 DCHECK_EQ(it->second->app_id(), app_shelf_id.ToString()); | 648 DCHECK_EQ(it->second->app_id(), app_shelf_id.ToString()); |
| 649 it->second->AddTaskId(task_id); | 649 it->second->AddTaskId(task_id); |
| 650 return it->second; | 650 return it->second; |
| 651 } | 651 } |
| 652 | 652 |
| 653 std::unique_ptr<ArcAppWindowLauncherItemController> controller = | 653 std::unique_ptr<ArcAppWindowLauncherItemController> controller = |
| 654 base::MakeUnique<ArcAppWindowLauncherItemController>( | 654 base::MakeUnique<ArcAppWindowLauncherItemController>( |
| 655 app_shelf_id.ToString()); | 655 app_shelf_id.ToString()); |
| 656 ArcAppWindowLauncherItemController* item_controller = controller.get(); | 656 ArcAppWindowLauncherItemController* item_controller = controller.get(); |
| 657 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model(); | 657 const ash::ShelfID shelf_id(app_shelf_id.ToString()); |
| 658 const ash::ShelfID shelf_id = | 658 if (owner()->GetItem(shelf_id) == nullptr) { |
|
James Cook
2017/05/10 02:51:18
Yeah, I think HasItem() would be easier to read.
msw
2017/05/10 18:21:53
I'm using TRUE/FALSE for test expectations, and I
James Cook
2017/05/10 19:29:35
Yeah, I think the TRUE/FALSE works well enough.
| |
| 659 shelf_model->GetShelfIDForAppID(app_shelf_id.ToString()); | |
| 660 if (shelf_id.IsNull()) { | |
| 661 owner()->CreateAppLauncherItem(std::move(controller), ash::STATUS_RUNNING); | 659 owner()->CreateAppLauncherItem(std::move(controller), ash::STATUS_RUNNING); |
| 662 } else { | 660 } else { |
| 663 shelf_model->SetShelfItemDelegate(shelf_id, std::move(controller)); | 661 owner()->shelf_model()->SetShelfItemDelegate(shelf_id, |
| 662 std::move(controller)); | |
| 664 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING); | 663 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
| 665 } | 664 } |
| 666 item_controller->AddTaskId(task_id); | 665 item_controller->AddTaskId(task_id); |
| 667 app_shelf_group_to_controller_map_[app_shelf_id] = item_controller; | 666 app_shelf_group_to_controller_map_[app_shelf_id] = item_controller; |
| 668 return item_controller; | 667 return item_controller; |
| 669 } | 668 } |
| 670 | 669 |
| 671 void ArcAppWindowLauncherController::RegisterApp( | 670 void ArcAppWindowLauncherController::RegisterApp( |
| 672 AppWindowInfo* app_window_info) { | 671 AppWindowInfo* app_window_info) { |
| 673 AppWindow* app_window = app_window_info->app_window(); | 672 AppWindow* app_window = app_window_info->app_window(); |
| 674 ArcAppWindowLauncherItemController* controller = | 673 ArcAppWindowLauncherItemController* controller = |
| 675 AttachControllerToTask(app_window->task_id(), *app_window_info); | 674 AttachControllerToTask(app_window->task_id(), *app_window_info); |
| 676 DCHECK(controller); | 675 DCHECK(!controller->app_id().empty()); |
| 677 | 676 const ash::ShelfID shelf_id(controller->app_id()); |
| 678 const ash::ShelfID shelf_id = | 677 DCHECK_NE(nullptr, owner()->GetItem(shelf_id)); |
| 679 ash::Shell::Get()->shelf_model()->GetShelfIDForAppID( | |
| 680 controller->app_id()); | |
| 681 DCHECK(!shelf_id.IsNull()); | |
| 682 | 678 |
| 683 controller->AddWindow(app_window); | 679 controller->AddWindow(app_window); |
| 684 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING); | 680 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
| 685 app_window->SetController(controller); | 681 app_window->SetController(controller); |
| 686 app_window->set_shelf_id(shelf_id); | 682 app_window->set_shelf_id(shelf_id); |
| 687 } | 683 } |
| 688 | 684 |
| 689 void ArcAppWindowLauncherController::UnregisterApp( | 685 void ArcAppWindowLauncherController::UnregisterApp( |
| 690 AppWindowInfo* app_window_info) { | 686 AppWindowInfo* app_window_info) { |
| 691 AppWindow* app_window = app_window_info->app_window(); | 687 AppWindow* app_window = app_window_info->app_window(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 737 const std::string arc_app_id = exo::ShellSurface::GetApplicationId(window); | 733 const std::string arc_app_id = exo::ShellSurface::GetApplicationId(window); |
| 738 if (arc_app_id.empty()) | 734 if (arc_app_id.empty()) |
| 739 return -1; | 735 return -1; |
| 740 | 736 |
| 741 int task_id = -1; | 737 int task_id = -1; |
| 742 if (sscanf(arc_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1) | 738 if (sscanf(arc_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1) |
| 743 return -1; | 739 return -1; |
| 744 | 740 |
| 745 return task_id; | 741 return task_id; |
| 746 } | 742 } |
| OLD | NEW |