Index: chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc |
diff --git a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc |
index a231ae53fbf328f69ff3a7715e63b2d0cf0bc90e..bafd886a24f3f253f3912958522278796f8d9b78 100644 |
--- a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc |
+++ b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc |
@@ -18,8 +18,10 @@ |
#include "base/bind.h" |
#include "base/memory/ptr_util.h" |
#include "chrome/browser/chromeos/arc/arc_util.h" |
+#include "chrome/browser/image_decoder.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
+#include "chrome/browser/ui/ash/launcher/arc_app_window.h" |
#include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.h" |
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
@@ -27,6 +29,7 @@ |
#include "components/exo/shell_surface.h" |
#include "components/signin/core/account_id/account_id.h" |
#include "components/user_manager/user_manager.h" |
+#include "extensions/common/constants.h" |
#include "third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationLockType.h" |
#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/env.h" |
@@ -37,12 +40,6 @@ |
namespace { |
-enum class FullScreenMode { |
- NOT_DEFINED, // Fullscreen mode was not defined. |
- ACTIVE, // Fullscreen is activated for an app. |
- NON_ACTIVE, // Fullscreen was not activated for an app. |
-}; |
- |
blink::WebScreenOrientationLockType BlinkOrientationLockFromMojom( |
arc::mojom::OrientationLock orientation_lock) { |
DCHECK_NE(arc::mojom::OrientationLock::CURRENT, orientation_lock); |
@@ -101,11 +98,11 @@ class ArcAppWindowLauncherController::AppWindowInfo { |
return lock_completion_behavior_; |
} |
- void set_app_window(std::unique_ptr<AppWindow> window) { |
+ void set_app_window(std::unique_ptr<ArcAppWindow> window) { |
app_window_ = std::move(window); |
} |
- AppWindow* app_window() { return app_window_.get(); } |
+ ArcAppWindow* app_window() { return app_window_.get(); } |
private: |
const arc::ArcAppShelfId app_shelf_id_; |
@@ -120,132 +117,11 @@ class ArcAppWindowLauncherController::AppWindowInfo { |
ScreenOrientationController::LockCompletionBehavior::None; |
arc::mojom::OrientationLock requested_orientation_lock_ = |
arc::mojom::OrientationLock::NONE; |
- std::unique_ptr<AppWindow> app_window_; |
+ std::unique_ptr<ArcAppWindow> app_window_; |
DISALLOW_COPY_AND_ASSIGN(AppWindowInfo); |
}; |
-// A ui::BaseWindow for a chromeos launcher to control ARC applications. |
-class ArcAppWindowLauncherController::AppWindow : public ui::BaseWindow { |
- public: |
- AppWindow(int task_id, |
- const arc::ArcAppShelfId& app_shelf_id, |
- views::Widget* widget, |
- ArcAppWindowLauncherController* owner) |
- : task_id_(task_id), |
- app_shelf_id_(app_shelf_id), |
- widget_(widget), |
- owner_(owner) {} |
- ~AppWindow() = default; |
- |
- void SetController(ArcAppWindowLauncherItemController* controller) { |
- DCHECK(!controller_ && controller); |
- controller_ = controller; |
- } |
- |
- void ResetController() { controller_ = nullptr; } |
- |
- void SetFullscreenMode(FullScreenMode mode) { |
- DCHECK(mode != FullScreenMode::NOT_DEFINED); |
- fullscreen_mode_ = mode; |
- } |
- |
- FullScreenMode fullscreen_mode() const { return fullscreen_mode_; } |
- |
- int task_id() const { return task_id_; } |
- |
- const arc::ArcAppShelfId& app_shelf_id() const { return app_shelf_id_; } |
- |
- const ash::ShelfID& shelf_id() const { return shelf_id_; } |
- |
- void set_shelf_id(const ash::ShelfID& shelf_id) { shelf_id_ = shelf_id; } |
- |
- views::Widget* widget() const { return widget_; } |
- |
- ArcAppWindowLauncherItemController* controller() { return controller_; } |
- |
- // ui::BaseWindow: |
- bool IsActive() const override { |
- return widget_->IsActive() && owner_->active_task_id_ == task_id_; |
- } |
- |
- bool IsMaximized() const override { |
- NOTREACHED(); |
- return false; |
- } |
- |
- bool IsMinimized() const override { |
- NOTREACHED(); |
- return false; |
- } |
- |
- bool IsFullscreen() const override { |
- NOTREACHED(); |
- return false; |
- } |
- |
- gfx::NativeWindow GetNativeWindow() const override { |
- return widget_->GetNativeWindow(); |
- } |
- |
- gfx::Rect GetRestoredBounds() const override { |
- NOTREACHED(); |
- return gfx::Rect(); |
- } |
- |
- ui::WindowShowState GetRestoredState() const override { |
- NOTREACHED(); |
- return ui::SHOW_STATE_NORMAL; |
- } |
- |
- gfx::Rect GetBounds() const override { |
- NOTREACHED(); |
- return gfx::Rect(); |
- } |
- |
- void Show() override { widget_->Show(); } |
- |
- void ShowInactive() override { NOTREACHED(); } |
- |
- void Hide() override { NOTREACHED(); } |
- |
- void Close() override { arc::CloseTask(task_id_); } |
- |
- void Activate() override { widget_->Activate(); } |
- |
- void Deactivate() override { NOTREACHED(); } |
- |
- void Maximize() override { NOTREACHED(); } |
- |
- void Minimize() override { widget_->Minimize(); } |
- |
- void Restore() override { NOTREACHED(); } |
- |
- void SetBounds(const gfx::Rect& bounds) override { NOTREACHED(); } |
- |
- void FlashFrame(bool flash) override { NOTREACHED(); } |
- |
- bool IsAlwaysOnTop() const override { |
- NOTREACHED(); |
- return false; |
- } |
- |
- void SetAlwaysOnTop(bool always_on_top) override { NOTREACHED(); } |
- |
- private: |
- const int task_id_; |
- const arc::ArcAppShelfId app_shelf_id_; |
- ash::ShelfID shelf_id_; |
- FullScreenMode fullscreen_mode_ = FullScreenMode::NOT_DEFINED; |
- // Unowned pointers |
- views::Widget* const widget_; |
- ArcAppWindowLauncherController* owner_; |
- ArcAppWindowLauncherItemController* controller_ = nullptr; |
- // Unowned pointer, represents host ARC window. |
- |
- DISALLOW_COPY_AND_ASSIGN(AppWindow); |
-}; |
- |
ArcAppWindowLauncherController::ArcAppWindowLauncherController( |
ChromeLauncherController* owner) |
: AppWindowLauncherController(owner) { |
@@ -357,8 +233,7 @@ ArcAppWindowLauncherController::GetAppWindowInfoForTask(int task_id) { |
return it == task_id_to_app_window_info_.end() ? nullptr : it->second.get(); |
} |
-ArcAppWindowLauncherController::AppWindow* |
-ArcAppWindowLauncherController::GetAppWindowForTask(int task_id) { |
+ArcAppWindow* ArcAppWindowLauncherController::GetAppWindowForTask(int task_id) { |
AppWindowInfo* info = GetAppWindowInfoForTask(task_id); |
return info ? info->app_window() : nullptr; |
} |
@@ -399,8 +274,8 @@ void ArcAppWindowLauncherController::AttachControllerToWindowIfNeeded( |
views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
DCHECK(widget); |
DCHECK(!info->app_window()); |
- info->set_app_window( |
- base::MakeUnique<AppWindow>(task_id, info->app_shelf_id(), widget, this)); |
+ info->set_app_window(base::MakeUnique<ArcAppWindow>( |
+ task_id, info->app_shelf_id(), widget, this)); |
RegisterApp(info); |
DCHECK(info->app_window()->controller()); |
const ash::ShelfID shelf_id(info->app_window()->shelf_id()); |
@@ -421,7 +296,7 @@ void ArcAppWindowLauncherController::OnAppReadyChanged( |
std::vector<int> ArcAppWindowLauncherController::GetTaskIdsForApp( |
const std::string& arc_app_id) const { |
- // Note, AppWindow is optional part for a task and it may be not created if |
+ // Note, ArcAppWindow is optional part for a task and it may be not created if |
// another full screen Android app is currently active. Use |
// |task_id_to_app_window_info_| that keeps currently running tasks info. |
std::vector<int> task_ids; |
@@ -494,32 +369,36 @@ void ArcAppWindowLauncherController::OnTaskSetActive(int32_t task_id) { |
return; |
} |
- AppWindow* previous_app_window = GetAppWindowForTask(active_task_id_); |
+ ArcAppWindow* previous_app_window = GetAppWindowForTask(active_task_id_); |
if (previous_app_window) { |
owner()->SetItemStatus(previous_app_window->shelf_id(), |
ash::STATUS_RUNNING); |
previous_app_window->SetFullscreenMode( |
previous_app_window->widget() && |
previous_app_window->widget()->IsFullscreen() |
- ? FullScreenMode::ACTIVE |
- : FullScreenMode::NON_ACTIVE); |
+ ? ArcAppWindow::FullScreenMode::ACTIVE |
+ : ArcAppWindow::FullScreenMode::NON_ACTIVE); |
} |
active_task_id_ = task_id; |
- AppWindow* current_app_window = GetAppWindowForTask(task_id); |
+ ArcAppWindow* current_app_window = GetAppWindowForTask(task_id); |
if (current_app_window) { |
- owner()->SetItemStatus( |
- current_app_window->shelf_id(), |
- current_app_window->widget() && current_app_window->IsActive() |
- ? ash::STATUS_ACTIVE |
- : ash::STATUS_RUNNING); |
+ if (current_app_window->widget() && current_app_window->IsActive()) { |
+ owner()->SetItemStatus(current_app_window->shelf_id(), |
+ ash::STATUS_ACTIVE); |
+ current_app_window->controller()->SetActiveWindow( |
+ current_app_window->GetNativeWindow()); |
+ } else { |
+ owner()->SetItemStatus(current_app_window->shelf_id(), |
+ ash::STATUS_RUNNING); |
+ } |
// TODO(reveman): Figure out how to support fullscreen in interleaved |
// window mode. |
// if (new_active_app_it->second->widget()) { |
// new_active_app_it->second->widget()->SetFullscreen( |
// new_active_app_it->second->fullscreen_mode() == |
- // FullScreenMode::ACTIVE); |
+ // ArcAppWindow::FullScreenMode::ACTIVE); |
// } |
} |
} |
@@ -548,7 +427,7 @@ void ArcAppWindowLauncherController::OnTaskOrientationLockRequested( |
if (ash::Shell::Get() |
->maximize_mode_controller() |
->IsMaximizeModeWindowManagerEnabled()) { |
- AppWindow* app_window = info->app_window(); |
+ ArcAppWindow* app_window = info->app_window(); |
if (app_window) |
SetOrientationLockForAppWindow(app_window); |
} |
@@ -559,14 +438,14 @@ ArcAppWindowLauncherController::ControllerForWindow(aura::Window* window) { |
if (!window) |
return nullptr; |
- AppWindow* app_window = GetAppWindowForTask(active_task_id_); |
+ ArcAppWindow* app_window = GetAppWindowForTask(active_task_id_); |
if (app_window && |
app_window->widget() == views::Widget::GetWidgetForNativeWindow(window)) { |
return app_window->controller(); |
} |
for (auto& it : task_id_to_app_window_info_) { |
- AppWindow* app_window = it.second->app_window(); |
+ ArcAppWindow* app_window = it.second->app_window(); |
if (app_window && |
app_window->widget() == |
views::Widget::GetWidgetForNativeWindow(window)) { |
@@ -588,7 +467,7 @@ void ArcAppWindowLauncherController::OnWindowActivated( |
void ArcAppWindowLauncherController::OnMaximizeModeStarted() { |
for (auto& it : task_id_to_app_window_info_) { |
- AppWindow* app_window = it.second->app_window(); |
+ ArcAppWindow* app_window = it.second->app_window(); |
if (app_window) |
SetOrientationLockForAppWindow(app_window); |
} |
@@ -634,7 +513,7 @@ ArcAppWindowLauncherController::AttachControllerToTask( |
std::unique_ptr<ArcAppWindowLauncherItemController> controller = |
base::MakeUnique<ArcAppWindowLauncherItemController>( |
- app_shelf_id.ToString()); |
+ app_shelf_id.ToString(), owner()); |
ArcAppWindowLauncherItemController* item_controller = controller.get(); |
const ash::ShelfID shelf_id(app_shelf_id.ToString()); |
if (!owner()->GetItem(shelf_id)) { |
@@ -651,7 +530,7 @@ ArcAppWindowLauncherController::AttachControllerToTask( |
void ArcAppWindowLauncherController::RegisterApp( |
AppWindowInfo* app_window_info) { |
- AppWindow* app_window = app_window_info->app_window(); |
+ ArcAppWindow* app_window = app_window_info->app_window(); |
ArcAppWindowLauncherItemController* controller = |
AttachControllerToTask(app_window->task_id(), *app_window_info); |
DCHECK(!controller->app_id().empty()); |
@@ -666,7 +545,7 @@ void ArcAppWindowLauncherController::RegisterApp( |
void ArcAppWindowLauncherController::UnregisterApp( |
AppWindowInfo* app_window_info) { |
- AppWindow* app_window = app_window_info->app_window(); |
+ ArcAppWindow* app_window = app_window_info->app_window(); |
if (!app_window) |
return; |
@@ -678,7 +557,7 @@ void ArcAppWindowLauncherController::UnregisterApp( |
} |
void ArcAppWindowLauncherController::SetOrientationLockForAppWindow( |
- AppWindow* app_window) { |
+ ArcAppWindow* app_window) { |
ash::WmWindow* window = |
ash::WmWindow::Get(app_window->widget()->GetNativeWindow()); |
if (!window) |