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 ddabb37aca101f5cb8960411a531c179b8e54328..5038c15ee2d7e8662ad46f5b51cf017612bf5050 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 |
@@ -93,8 +93,9 @@ class ArcAppWindowLauncherController::AppWindow : public ui::BaseWindow { |
public: |
AppWindow(int task_id, |
const std::string app_id, |
+ views::Widget* widget, |
ArcAppWindowLauncherController* owner) |
- : task_id_(task_id), app_id_(app_id), owner_(owner) {} |
+ : task_id_(task_id), app_id_(app_id), widget_(widget), owner_(owner) {} |
~AppWindow() {} |
void SetController(ArcAppWindowLauncherItemController* controller) { |
@@ -119,16 +120,13 @@ class ArcAppWindowLauncherController::AppWindow : public ui::BaseWindow { |
views::Widget* widget() const { return widget_; } |
- void set_widget(views::Widget* widget) { widget_ = widget; } |
- |
ArcAppWindowLauncherItemController* controller() { return controller_; } |
const std::string app_id() { return app_id_; } |
// ui::BaseWindow: |
bool IsActive() const override { |
- return widget_ && widget_->IsActive() && |
- owner_->active_task_id_ == task_id_; |
+ return widget_->IsActive() && owner_->active_task_id_ == task_id_; |
} |
bool IsMaximized() const override { |
@@ -147,7 +145,7 @@ class ArcAppWindowLauncherController::AppWindow : public ui::BaseWindow { |
} |
gfx::NativeWindow GetNativeWindow() const override { |
- return widget_ ? widget_->GetNativeWindow() : nullptr; |
+ return widget_->GetNativeWindow(); |
} |
gfx::Rect GetRestoredBounds() const override { |
@@ -165,9 +163,7 @@ class ArcAppWindowLauncherController::AppWindow : public ui::BaseWindow { |
return gfx::Rect(); |
} |
- void Show() override { |
- // TODO(khmel): support window minimizing. |
- } |
+ void Show() override { widget_->Show(); } |
void ShowInactive() override { NOTREACHED(); } |
@@ -175,16 +171,13 @@ class ArcAppWindowLauncherController::AppWindow : public ui::BaseWindow { |
void Close() override { arc::CloseTask(task_id_); } |
- void Activate() override { arc::SetTaskActive(task_id_); } |
+ void Activate() override { widget_->Activate(); } |
void Deactivate() override { NOTREACHED(); } |
void Maximize() override { NOTREACHED(); } |
- void Minimize() override { |
- if (widget_) |
- widget_->Minimize(); |
- } |
+ void Minimize() override { widget_->Minimize(); } |
void Restore() override { NOTREACHED(); } |
@@ -218,10 +211,10 @@ class ArcAppWindowLauncherController::AppWindow : public ui::BaseWindow { |
std::string app_id_; |
FullScreenMode fullscreen_mode_ = FullScreenMode::NOT_DEFINED; |
// Unowned pointers |
+ views::Widget* const widget_; |
ArcAppWindowLauncherController* owner_; |
ArcAppWindowLauncherItemController* controller_ = nullptr; |
// Unowned pointer, represents host Arc window. |
- views::Widget* widget_ = nullptr; |
arc::mojom::OrientationLock requested_orientation_lock_ = |
arc::mojom::OrientationLock::NONE; |
@@ -296,10 +289,14 @@ void ArcAppWindowLauncherController::OnWindowInitialized(aura::Window* window) { |
window->AddObserver(this); |
} |
-void ArcAppWindowLauncherController::OnWindowVisibilityChanging( |
+void ArcAppWindowLauncherController::OnWindowVisibilityChanged( |
aura::Window* window, |
bool visible) { |
- // The application id property should be set at this time. |
+ // The application id property should be set at this time. It is important to |
+ // have window->IsVisible set to true before attaching to a controller because |
+ // the window is registered in multi-user manager and this manager may |
+ // consider this new window as hidden for current profile. Multi-user manager |
+ // uses OnWindowVisibilityChanging event to update window state. |
if (visible && observed_profile_ == owner()->GetProfile()) |
oshima
2016/09/15 17:14:32
It looks to me that observerd_profile_ and owner()
khmel
2016/09/15 17:32:15
Actually not, observerd_profile_ is set on creatio
|
AttachControllerToWindowIfNeeded(window); |
} |
@@ -370,8 +367,10 @@ void ArcAppWindowLauncherController::AttachControllerToWindowIfNeeded( |
const std::string& app_id = it->second; |
- std::unique_ptr<AppWindow> app_window(new AppWindow(task_id, app_id, this)); |
- app_window->set_widget(views::Widget::GetWidgetForNativeWindow(window)); |
+ views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
+ DCHECK(widget); |
+ std::unique_ptr<AppWindow> app_window( |
+ new AppWindow(task_id, app_id, widget, this)); |
RegisterApp(app_window.get()); |
DCHECK(app_window->controller()); |
ash::WmWindowAura::Get(window)->SetIntProperty( |