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

Side by Side Diff: chrome/browser/ui/views/extensions/native_app_window_views.cc

Issue 14031021: Save and restore State for ShellWindows, including panels (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/native_app_window_views.h" 5 #include "chrome/browser/ui/views/extensions/native_app_window_views.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
(...skipping 22 matching lines...) Expand all
33 #include "ui/base/win/shell.h" 33 #include "ui/base/win/shell.h"
34 #endif 34 #endif
35 35
36 #if defined(USE_ASH) 36 #if defined(USE_ASH)
37 #include "ash/screen_ash.h" 37 #include "ash/screen_ash.h"
38 #include "ash/shell.h" 38 #include "ash/shell.h"
39 #include "ash/wm/custom_frame_view_ash.h" 39 #include "ash/wm/custom_frame_view_ash.h"
40 #include "ash/wm/panels/panel_frame_view.h" 40 #include "ash/wm/panels/panel_frame_view.h"
41 #include "ash/wm/window_properties.h" 41 #include "ash/wm/window_properties.h"
42 #include "chrome/browser/ui/ash/ash_util.h" 42 #include "chrome/browser/ui/ash/ash_util.h"
43 #include "ui/aura/client/aura_constants.h"
43 #include "ui/aura/root_window.h" 44 #include "ui/aura/root_window.h"
45 #include "ui/aura/window.h"
44 #endif 46 #endif
45 47
46 namespace { 48 namespace {
47 49
48 const int kMinPanelWidth = 100; 50 const int kMinPanelWidth = 100;
49 const int kMinPanelHeight = 100; 51 const int kMinPanelHeight = 100;
50 const int kDefaultPanelWidth = 200; 52 const int kDefaultPanelWidth = 200;
51 const int kDefaultPanelHeight = 300; 53 const int kDefaultPanelHeight = 300;
52 const int kResizeInsideBoundsSize = 5; 54 const int kResizeInsideBoundsSize = 5;
53 55
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 261 }
260 #else 262 #else
261 params.bounds = gfx::Rect(preferred_size_); 263 params.bounds = gfx::Rect(preferred_size_);
262 #endif 264 #endif
263 // TODO(erg): Conceptually, these are toplevel windows, but we theoretically 265 // TODO(erg): Conceptually, these are toplevel windows, but we theoretically
264 // could plumb context through to here in some cases. 266 // could plumb context through to here in some cases.
265 params.top_level = true; 267 params.top_level = true;
266 window_->Init(params); 268 window_->Init(params);
267 window_->set_focus_on_creation(create_params.focused); 269 window_->set_focus_on_creation(create_params.focused);
268 270
269 #if !defined(USE_ASH) 271 #if defined(USE_ASH)
270 // TODO(oshima|stevenjb): Ideally, we should be able to just pre-determine 272 if (create_params.state == ui::SHOW_STATE_DETACHED) {
271 // the exact location and size, but this doesn't work well 273 gfx::Rect window_bounds(create_params.bounds.x(),
272 // on non-ash environment where we don't have full control over 274 create_params.bounds.y(),
273 // window management. 275 preferred_size_.width(),
274 gfx::Rect window_bounds = 276 preferred_size_.height());
275 window_->non_client_view()->GetWindowBoundsForClientBounds( 277 aura::Window* win = GetNativeWindow();
Mr4D (OOO till 08-26) 2013/05/06 21:40:16 Please no abbrev
stevenjb 2013/05/07 16:06:32 Done.
276 create_params.bounds); 278 win->SetProperty(ash::internal::kPanelAttachedKey, false);
277 window_->SetBounds(window_bounds); 279 win->SetDefaultParentByRootWindow(
280 win->GetRootWindow(),
281 win->GetBoundsInScreen());
282 window_->SetBounds(window_bounds);
283 }
284 #else
285 // TODO(stevenjb): NativeAppWindow panels need to be implemented for other
286 // platforms.
278 #endif 287 #endif
279 } 288 }
280 289
281 // BaseWindow implementation. 290 // BaseWindow implementation.
282 291
283 bool NativeAppWindowViews::IsActive() const { 292 bool NativeAppWindowViews::IsActive() const {
284 return window_->IsActive(); 293 return window_->IsActive();
285 } 294 }
286 295
287 bool NativeAppWindowViews::IsMaximized() const { 296 bool NativeAppWindowViews::IsMaximized() const {
288 return window_->IsMaximized(); 297 return window_->IsMaximized();
289 } 298 }
290 299
291 bool NativeAppWindowViews::IsMinimized() const { 300 bool NativeAppWindowViews::IsMinimized() const {
292 return window_->IsMinimized(); 301 return window_->IsMinimized();
293 } 302 }
294 303
295 bool NativeAppWindowViews::IsFullscreen() const { 304 bool NativeAppWindowViews::IsFullscreen() const {
296 return window_->IsFullscreen(); 305 return window_->IsFullscreen();
297 } 306 }
298 307
299 gfx::NativeWindow NativeAppWindowViews::GetNativeWindow() { 308 gfx::NativeWindow NativeAppWindowViews::GetNativeWindow() {
300 return window_->GetNativeWindow(); 309 return window_->GetNativeWindow();
301 } 310 }
302 311
303 gfx::Rect NativeAppWindowViews::GetRestoredBounds() const { 312 gfx::Rect NativeAppWindowViews::GetRestoredBounds() const {
304 return window_->GetRestoredBounds(); 313 return window_->GetRestoredBounds();
305 } 314 }
306 315
316 ui::WindowShowState NativeAppWindowViews::GetRestoredState() const {
317 if (IsMaximized())
318 return ui::SHOW_STATE_MAXIMIZED;
319 #if defined(USE_ASH)
320 // On Ash, restore fullscreen.
321 if (IsFullscreen())
322 return ui::SHOW_STATE_FULLSCREEN;
323 // Use kRestoreShowStateKey in case a window is minimized/hidden.
324 ui::WindowShowState restore_state =
325 window_->GetNativeWindow()->GetProperty(
326 aura::client::kRestoreShowStateKey);
327 if (restore_state != ui::SHOW_STATE_MINIMIZED)
328 return restore_state;
329 #endif
330 return ui::SHOW_STATE_NORMAL;
331 }
332
307 gfx::Rect NativeAppWindowViews::GetBounds() const { 333 gfx::Rect NativeAppWindowViews::GetBounds() const {
308 return window_->GetWindowBoundsInScreen(); 334 return window_->GetWindowBoundsInScreen();
309 } 335 }
310 336
311 void NativeAppWindowViews::Show() { 337 void NativeAppWindowViews::Show() {
312 if (window_->IsVisible()) { 338 if (window_->IsVisible()) {
313 window_->Activate(); 339 window_->Activate();
314 return; 340 return;
315 } 341 }
316 342
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 window_->SetFullscreen(fullscreen); 694 window_->SetFullscreen(fullscreen);
669 // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we 695 // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we
670 // ever drop the window out of fullscreen in response to something that 696 // ever drop the window out of fullscreen in response to something that
671 // wasn't the app calling webkitCancelFullScreen(). 697 // wasn't the app calling webkitCancelFullScreen().
672 } 698 }
673 699
674 bool NativeAppWindowViews::IsFullscreenOrPending() const { 700 bool NativeAppWindowViews::IsFullscreenOrPending() const {
675 return is_fullscreen_; 701 return is_fullscreen_;
676 } 702 }
677 703
704 bool NativeAppWindowViews::IsDetached() const {
705 if (!shell_window_->window_type_is_panel())
706 return false;
707 #if defined(USE_ASH)
708 return !window_->GetNativeWindow()->GetProperty(
709 ash::internal::kPanelAttachedKey);
710 #else
711 return false;
712 #endif
713 }
714
678 views::View* NativeAppWindowViews::GetContentsView() { 715 views::View* NativeAppWindowViews::GetContentsView() {
679 return this; 716 return this;
680 } 717 }
681 718
682 void NativeAppWindowViews::UpdateWindowIcon() { 719 void NativeAppWindowViews::UpdateWindowIcon() {
683 window_->UpdateWindowIcon(); 720 window_->UpdateWindowIcon();
684 } 721 }
685 722
686 void NativeAppWindowViews::UpdateWindowTitle() { 723 void NativeAppWindowViews::UpdateWindowTitle() {
687 window_->UpdateWindowTitle(); 724 window_->UpdateWindowTitle();
(...skipping 20 matching lines...) Expand all
708 } 745 }
709 746
710 //------------------------------------------------------------------------------ 747 //------------------------------------------------------------------------------
711 // NativeAppWindow::Create 748 // NativeAppWindow::Create
712 749
713 // static 750 // static
714 NativeAppWindow* NativeAppWindow::Create( 751 NativeAppWindow* NativeAppWindow::Create(
715 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { 752 ShellWindow* shell_window, const ShellWindow::CreateParams& params) {
716 return new NativeAppWindowViews(shell_window, params); 753 return new NativeAppWindowViews(shell_window, params);
717 } 754 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698