Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 | 4 |
| 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views_aura.h" | 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views_aura.h" |
| 6 | 6 |
| 7 #include "apps/ui/views/app_window_frame_view.h" | 7 #include "apps/ui/views/app_window_frame_view.h" |
| 8 #include "ash/ash_constants.h" | 8 #include "ash/ash_constants.h" |
| 9 #include "ash/frame/custom_frame_view_ash.h" | 9 #include "ash/frame/custom_frame_view_ash.h" |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 } // namespace | 113 } // namespace |
| 114 | 114 |
| 115 ChromeNativeAppWindowViewsAura::ChromeNativeAppWindowViewsAura() { | 115 ChromeNativeAppWindowViewsAura::ChromeNativeAppWindowViewsAura() { |
| 116 } | 116 } |
| 117 | 117 |
| 118 ChromeNativeAppWindowViewsAura::~ChromeNativeAppWindowViewsAura() { | 118 ChromeNativeAppWindowViewsAura::~ChromeNativeAppWindowViewsAura() { |
| 119 } | 119 } |
| 120 | 120 |
| 121 void ChromeNativeAppWindowViewsAura::InitializeWindow( | |
| 122 AppWindow* app_window, | |
| 123 const AppWindow::CreateParams& create_params) { | |
| 124 ChromeNativeAppWindowViews::InitializeWindow(app_window, create_params); | |
| 125 #if defined(OS_CHROMEOS) | |
|
benwells
2015/04/28 23:46:01
why only chromeos / not ash?
varkha
2015/04/29 16:54:16
Done. You are right, since I've last worked on thi
| |
| 126 // Restore docked state on Chrome OS and ignore it elsewhere. | |
| 127 if (create_params.state == ui::SHOW_STATE_DOCKED) { | |
| 128 widget()->GetNativeWindow()->SetProperty(aura::client::kShowStateKey, | |
| 129 create_params.state); | |
| 130 } | |
| 131 #endif | |
| 132 } | |
| 133 | |
| 121 void ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit( | 134 void ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit( |
| 122 const AppWindow::CreateParams& create_params, | 135 const AppWindow::CreateParams& create_params, |
| 123 views::Widget::InitParams* init_params, | 136 views::Widget::InitParams* init_params, |
| 124 views::Widget* widget) { | 137 views::Widget* widget) { |
| 125 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 138 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 126 std::string app_name = web_app::GenerateApplicationNameFromExtensionId( | 139 std::string app_name = web_app::GenerateApplicationNameFromExtensionId( |
| 127 app_window()->extension_id()); | 140 app_window()->extension_id()); |
| 128 // Set up a custom WM_CLASS for app windows. This allows task switchers in | 141 // Set up a custom WM_CLASS for app windows. This allows task switchers in |
| 129 // X11 environments to distinguish them from main browser windows. | 142 // X11 environments to distinguish them from main browser windows. |
| 130 init_params->wm_class_name = web_app::GetWMClassFromAppName(app_name); | 143 init_params->wm_class_name = web_app::GetWMClassFromAppName(app_name); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 144 ash::kShellWindowId_ImeWindowParentContainer); | 157 ash::kShellWindowId_ImeWindowParentContainer); |
| 145 } | 158 } |
| 146 #endif | 159 #endif |
| 147 } | 160 } |
| 148 | 161 |
| 149 void ChromeNativeAppWindowViewsAura::OnBeforePanelWidgetInit( | 162 void ChromeNativeAppWindowViewsAura::OnBeforePanelWidgetInit( |
| 150 views::Widget::InitParams* init_params, | 163 views::Widget::InitParams* init_params, |
| 151 views::Widget* widget) { | 164 views::Widget* widget) { |
| 152 ChromeNativeAppWindowViews::OnBeforePanelWidgetInit(init_params, widget); | 165 ChromeNativeAppWindowViews::OnBeforePanelWidgetInit(init_params, widget); |
| 153 | 166 |
| 154 if (ash::Shell::HasInstance()) { | 167 using BoundsSpecification = AppWindow::BoundsSpecification; |
| 168 bool position_specified = | |
| 169 init_params->bounds.x() != BoundsSpecification::kUnspecifiedPosition && | |
| 170 init_params->bounds.y() != BoundsSpecification::kUnspecifiedPosition; | |
| 171 if (ash::Shell::HasInstance() && !position_specified) { | |
| 155 // Open a new panel on the target root. | 172 // Open a new panel on the target root. |
| 156 init_params->bounds = ash::ScreenUtil::ConvertRectToScreen( | 173 init_params->bounds = ash::ScreenUtil::ConvertRectToScreen( |
| 157 ash::Shell::GetTargetRootWindow(), gfx::Rect(GetPreferredSize())); | 174 ash::Shell::GetTargetRootWindow(), gfx::Rect(GetPreferredSize())); |
| 158 } | 175 } |
| 159 } | 176 } |
| 160 | 177 |
| 161 apps::AppWindowFrameView* | 178 apps::AppWindowFrameView* |
| 162 ChromeNativeAppWindowViewsAura::CreateNonStandardAppFrame() { | 179 ChromeNativeAppWindowViewsAura::CreateNonStandardAppFrame() { |
| 163 apps::AppWindowFrameView* frame = | 180 apps::AppWindowFrameView* frame = |
| 164 ChromeNativeAppWindowViews::CreateNonStandardAppFrame(); | 181 ChromeNativeAppWindowViews::CreateNonStandardAppFrame(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 if (IsFullscreen()) { | 233 if (IsFullscreen()) { |
| 217 if (immersive_fullscreen_controller_.get() && | 234 if (immersive_fullscreen_controller_.get() && |
| 218 immersive_fullscreen_controller_->IsEnabled()) { | 235 immersive_fullscreen_controller_->IsEnabled()) { |
| 219 // Restore windows which were previously in immersive fullscreen to | 236 // Restore windows which were previously in immersive fullscreen to |
| 220 // maximized. Restoring the window to a different fullscreen type | 237 // maximized. Restoring the window to a different fullscreen type |
| 221 // makes for a bad experience. | 238 // makes for a bad experience. |
| 222 return ui::SHOW_STATE_MAXIMIZED; | 239 return ui::SHOW_STATE_MAXIMIZED; |
| 223 } | 240 } |
| 224 return ui::SHOW_STATE_FULLSCREEN; | 241 return ui::SHOW_STATE_FULLSCREEN; |
| 225 } | 242 } |
| 243 if (widget()->GetNativeWindow()->GetProperty(aura::client::kShowStateKey) == | |
| 244 ui::SHOW_STATE_DOCKED) { | |
| 245 return ui::SHOW_STATE_DOCKED; | |
| 246 } | |
| 226 } | 247 } |
| 227 // Whitelist states to return so that invalid and transient states | 248 // Whitelist states to return so that invalid and transient states |
| 228 // are not saved and used to restore windows when they are recreated. | 249 // are not saved and used to restore windows when they are recreated. |
| 229 switch (restore_state) { | 250 switch (restore_state) { |
| 230 case ui::SHOW_STATE_NORMAL: | 251 case ui::SHOW_STATE_NORMAL: |
| 231 case ui::SHOW_STATE_MAXIMIZED: | 252 case ui::SHOW_STATE_MAXIMIZED: |
| 232 case ui::SHOW_STATE_FULLSCREEN: | 253 case ui::SHOW_STATE_FULLSCREEN: |
| 233 return restore_state; | 254 return restore_state; |
| 234 | 255 |
| 235 case ui::SHOW_STATE_DEFAULT: | 256 case ui::SHOW_STATE_DEFAULT: |
| 236 case ui::SHOW_STATE_MINIMIZED: | 257 case ui::SHOW_STATE_MINIMIZED: |
| 237 case ui::SHOW_STATE_INACTIVE: | 258 case ui::SHOW_STATE_INACTIVE: |
| 259 case ui::SHOW_STATE_DOCKED: | |
| 238 case ui::SHOW_STATE_END: | 260 case ui::SHOW_STATE_END: |
| 239 return ui::SHOW_STATE_NORMAL; | 261 return ui::SHOW_STATE_NORMAL; |
| 240 } | 262 } |
| 241 | 263 |
| 242 return ui::SHOW_STATE_NORMAL; | 264 return ui::SHOW_STATE_NORMAL; |
| 243 } | 265 } |
| 244 | 266 |
| 245 bool ChromeNativeAppWindowViewsAura::IsAlwaysOnTop() const { | 267 bool ChromeNativeAppWindowViewsAura::IsAlwaysOnTop() const { |
| 246 return app_window()->window_type_is_panel() | 268 return app_window()->window_type_is_panel() |
| 247 ? ash::wm::GetWindowState(widget()->GetNativeWindow()) | 269 ? ash::wm::GetWindowState(widget()->GetNativeWindow()) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 ChromeNativeAppWindowViews::UpdateShape(region.Pass()); | 368 ChromeNativeAppWindowViews::UpdateShape(region.Pass()); |
| 347 | 369 |
| 348 aura::Window* native_window = widget()->GetNativeWindow(); | 370 aura::Window* native_window = widget()->GetNativeWindow(); |
| 349 if (shape() && !had_shape) { | 371 if (shape() && !had_shape) { |
| 350 native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( | 372 native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( |
| 351 new ShapedAppWindowTargeter(native_window, this))); | 373 new ShapedAppWindowTargeter(native_window, this))); |
| 352 } else if (!shape() && had_shape) { | 374 } else if (!shape() && had_shape) { |
| 353 native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); | 375 native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); |
| 354 } | 376 } |
| 355 } | 377 } |
| OLD | NEW |