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

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

Issue 2860503002: mash: Replace int ShelfIDs with AppLaunchID strings. (Closed)
Patch Set: Restore AppLaunchId class via using ShelfID = AppLaunchId; cleanup. Created 3 years, 7 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 <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/shared/app_types.h" 10 #include "ash/shared/app_types.h"
10 #include "ash/shelf/shelf_model.h" 11 #include "ash/shelf/shelf_model.h"
11 #include "ash/shell.h" 12 #include "ash/shell.h"
12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 13 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
13 #include "ash/wm/window_properties.h"
14 #include "ash/wm/window_state.h" 14 #include "ash/wm/window_state.h"
15 #include "ash/wm/window_state_aura.h" 15 #include "ash/wm/window_state_aura.h"
16 #include "ash/wm/window_util.h" 16 #include "ash/wm/window_util.h"
17 #include "ash/wm_window.h" 17 #include "ash/wm_window.h"
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/memory/ptr_util.h" 19 #include "base/memory/ptr_util.h"
20 #include "chrome/browser/chromeos/arc/arc_support_host.h" 20 #include "chrome/browser/chromeos/arc/arc_support_host.h"
21 #include "chrome/browser/chromeos/arc/arc_util.h" 21 #include "chrome/browser/chromeos/arc/arc_util.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 23 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 DCHECK(mode != FullScreenMode::NOT_DEFINED); 150 DCHECK(mode != FullScreenMode::NOT_DEFINED);
151 fullscreen_mode_ = mode; 151 fullscreen_mode_ = mode;
152 } 152 }
153 153
154 FullScreenMode fullscreen_mode() const { return fullscreen_mode_; } 154 FullScreenMode fullscreen_mode() const { return fullscreen_mode_; }
155 155
156 int task_id() const { return task_id_; } 156 int task_id() const { return task_id_; }
157 157
158 const arc::ArcAppShelfId& app_shelf_id() const { return app_shelf_id_; } 158 const arc::ArcAppShelfId& app_shelf_id() const { return app_shelf_id_; }
159 159
160 ash::ShelfID shelf_id() const { return shelf_id_; } 160 const ash::ShelfID& shelf_id() const { return shelf_id_; }
161 161
162 void set_shelf_id(ash::ShelfID shelf_id) { shelf_id_ = shelf_id; } 162 void set_shelf_id(const ash::ShelfID& shelf_id) { shelf_id_ = shelf_id; }
163 163
164 views::Widget* widget() const { return widget_; } 164 views::Widget* widget() const { return widget_; }
165 165
166 ArcAppWindowLauncherItemController* controller() { return controller_; } 166 ArcAppWindowLauncherItemController* controller() { return controller_; }
167 167
168 // ui::BaseWindow: 168 // ui::BaseWindow:
169 bool IsActive() const override { 169 bool IsActive() const override {
170 return widget_->IsActive() && owner_->active_task_id_ == task_id_; 170 return widget_->IsActive() && owner_->active_task_id_ == task_id_;
171 } 171 }
172 172
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 bool IsAlwaysOnTop() const override { 229 bool IsAlwaysOnTop() const override {
230 NOTREACHED(); 230 NOTREACHED();
231 return false; 231 return false;
232 } 232 }
233 233
234 void SetAlwaysOnTop(bool always_on_top) override { NOTREACHED(); } 234 void SetAlwaysOnTop(bool always_on_top) override { NOTREACHED(); }
235 235
236 private: 236 private:
237 const int task_id_; 237 const int task_id_;
238 const arc::ArcAppShelfId app_shelf_id_; 238 const arc::ArcAppShelfId app_shelf_id_;
239 ash::ShelfID shelf_id_ = 0; 239 ash::ShelfID shelf_id_;
240 FullScreenMode fullscreen_mode_ = FullScreenMode::NOT_DEFINED; 240 FullScreenMode fullscreen_mode_ = FullScreenMode::NOT_DEFINED;
241 // Unowned pointers 241 // Unowned pointers
242 views::Widget* const widget_; 242 views::Widget* const widget_;
243 ArcAppWindowLauncherController* owner_; 243 ArcAppWindowLauncherController* owner_;
244 ArcAppWindowLauncherItemController* controller_ = nullptr; 244 ArcAppWindowLauncherItemController* controller_ = nullptr;
245 // Unowned pointer, represents host ARC window. 245 // Unowned pointer, represents host ARC window.
246 246
247 DISALLOW_COPY_AND_ASSIGN(AppWindow); 247 DISALLOW_COPY_AND_ASSIGN(AppWindow);
248 }; 248 };
249 249
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 return; 411 return;
412 } 412 }
413 413
414 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); 414 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
415 DCHECK(widget); 415 DCHECK(widget);
416 DCHECK(!info->app_window()); 416 DCHECK(!info->app_window());
417 info->set_app_window( 417 info->set_app_window(
418 base::MakeUnique<AppWindow>(task_id, info->app_shelf_id(), widget, this)); 418 base::MakeUnique<AppWindow>(task_id, info->app_shelf_id(), widget, this));
419 RegisterApp(info); 419 RegisterApp(info);
420 DCHECK(info->app_window()->controller()); 420 DCHECK(info->app_window()->controller());
421 window->SetProperty(ash::kShelfIDKey, info->app_window()->shelf_id()); 421 window->SetProperty(ash::kShelfIDKey,
422 new ash::ShelfID(info->app_window()->shelf_id()));
422 if (ash::Shell::Get() 423 if (ash::Shell::Get()
423 ->maximize_mode_controller() 424 ->maximize_mode_controller()
424 ->IsMaximizeModeWindowManagerEnabled()) { 425 ->IsMaximizeModeWindowManagerEnabled()) {
425 SetOrientationLockForAppWindow(info->app_window()); 426 SetOrientationLockForAppWindow(info->app_window());
426 } 427 }
427 } 428 }
428 429
429 void ArcAppWindowLauncherController::OnAppReadyChanged( 430 void ArcAppWindowLauncherController::OnAppReadyChanged(
430 const std::string& arc_app_id, 431 const std::string& arc_app_id,
431 bool ready) { 432 bool ready) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 return it->second; 650 return it->second;
650 } 651 }
651 652
652 std::unique_ptr<ArcAppWindowLauncherItemController> controller = 653 std::unique_ptr<ArcAppWindowLauncherItemController> controller =
653 base::MakeUnique<ArcAppWindowLauncherItemController>( 654 base::MakeUnique<ArcAppWindowLauncherItemController>(
654 app_shelf_id.ToString()); 655 app_shelf_id.ToString());
655 ArcAppWindowLauncherItemController* item_controller = controller.get(); 656 ArcAppWindowLauncherItemController* item_controller = controller.get();
656 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model(); 657 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model();
657 const ash::ShelfID shelf_id = 658 const ash::ShelfID shelf_id =
658 shelf_model->GetShelfIDForAppID(app_shelf_id.ToString()); 659 shelf_model->GetShelfIDForAppID(app_shelf_id.ToString());
659 if (shelf_id == ash::kInvalidShelfID) { 660 if (shelf_id.IsEmpty()) {
660 owner()->CreateAppLauncherItem(std::move(controller), ash::STATUS_RUNNING); 661 owner()->CreateAppLauncherItem(std::move(controller), ash::STATUS_RUNNING);
661 } else { 662 } else {
662 shelf_model->SetShelfItemDelegate(shelf_id, std::move(controller)); 663 shelf_model->SetShelfItemDelegate(shelf_id, std::move(controller));
663 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 664 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
664 } 665 }
665 item_controller->AddTaskId(task_id); 666 item_controller->AddTaskId(task_id);
666 app_shelf_group_to_controller_map_[app_shelf_id] = item_controller; 667 app_shelf_group_to_controller_map_[app_shelf_id] = item_controller;
667 return item_controller; 668 return item_controller;
668 } 669 }
669 670
670 void ArcAppWindowLauncherController::RegisterApp( 671 void ArcAppWindowLauncherController::RegisterApp(
671 AppWindowInfo* app_window_info) { 672 AppWindowInfo* app_window_info) {
672 AppWindow* app_window = app_window_info->app_window(); 673 AppWindow* app_window = app_window_info->app_window();
673 ArcAppWindowLauncherItemController* controller = 674 ArcAppWindowLauncherItemController* controller =
674 AttachControllerToTask(app_window->task_id(), *app_window_info); 675 AttachControllerToTask(app_window->task_id(), *app_window_info);
675 DCHECK(controller); 676 DCHECK(controller);
676 677
677 const ash::ShelfID shelf_id = 678 const ash::ShelfID shelf_id =
678 ash::Shell::Get()->shelf_model()->GetShelfIDForAppID( 679 ash::Shell::Get()->shelf_model()->GetShelfIDForAppID(
679 controller->app_id()); 680 controller->app_id());
680 DCHECK_NE(shelf_id, ash::kInvalidShelfID); 681 DCHECK(!shelf_id.IsEmpty());
681 682
682 controller->AddWindow(app_window); 683 controller->AddWindow(app_window);
683 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 684 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
684 app_window->SetController(controller); 685 app_window->SetController(controller);
685 app_window->set_shelf_id(shelf_id); 686 app_window->set_shelf_id(shelf_id);
686 } 687 }
687 688
688 void ArcAppWindowLauncherController::UnregisterApp( 689 void ArcAppWindowLauncherController::UnregisterApp(
689 AppWindowInfo* app_window_info) { 690 AppWindowInfo* app_window_info) {
690 AppWindow* app_window = app_window_info->app_window(); 691 AppWindow* app_window = app_window_info->app_window();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 const std::string arc_app_id = exo::ShellSurface::GetApplicationId(window); 737 const std::string arc_app_id = exo::ShellSurface::GetApplicationId(window);
737 if (arc_app_id.empty()) 738 if (arc_app_id.empty())
738 return -1; 739 return -1;
739 740
740 int task_id = -1; 741 int task_id = -1;
741 if (sscanf(arc_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1) 742 if (sscanf(arc_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1)
742 return -1; 743 return -1;
743 744
744 return task_id; 745 return task_id;
745 } 746 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698