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

Side by Side Diff: chrome/browser/ui/window_sizer/window_sizer_ash.cc

Issue 424463002: Makes a window that has been resized to maximized bounds, then maximized and then restored shrink (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Maximizes a window that has been resized to maximized bounds (comments and restrict to ash) Created 6 years, 4 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/window_sizer/window_sizer.h" 5 #include "chrome/browser/ui/window_sizer/window_sizer.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/window_positioner.h" 8 #include "ash/wm/window_positioner.h"
9 #include "ash/wm/window_state.h" 9 #include "ash/wm/window_state.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_window.h" 11 #include "chrome/browser/ui/browser_window.h"
12 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
13 #include "ui/aura/window_event_dispatcher.h" 13 #include "ui/aura/window_event_dispatcher.h"
14 #include "ui/gfx/screen.h" 14 #include "ui/gfx/screen.h"
15 15
16 bool WindowSizer::GetBrowserBoundsAsh(gfx::Rect* bounds, 16 bool WindowSizer::GetBrowserBoundsAsh(gfx::Rect* bounds,
17 ui::WindowShowState* show_state) const { 17 ui::WindowShowState* show_state) const {
18 if (!browser_ ||
19 browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH)
20 return false;
21
22 if (bounds->IsEmpty()) { 18 if (bounds->IsEmpty()) {
23 if (browser_->is_type_tabbed()) { 19 if (browser_->is_type_tabbed()) {
24 GetTabbedBrowserBoundsAsh(bounds, show_state); 20 GetTabbedBrowserBoundsAsh(bounds, show_state);
25 return true; 21 return true;
26 } 22 }
27 23
28 if (browser_->is_trusted_source()) { 24 if (browser_->is_trusted_source()) {
29 // For trusted popups (v1 apps and system windows), do not use the last 25 // For trusted popups (v1 apps and system windows), do not use the last
30 // active window bounds, only use saved or default bounds. 26 // active window bounds, only use saved or default bounds.
31 if (!GetSavedWindowBounds(bounds, show_state)) 27 if (!GetSavedWindowBounds(bounds, show_state))
(...skipping 16 matching lines...) Expand all
48 // looking for a good screen location. We are interpreting (0,0) as an 44 // looking for a good screen location. We are interpreting (0,0) as an
49 // unspecified location. 45 // unspecified location.
50 if (browser_->is_type_popup() && bounds->origin().IsOrigin()) { 46 if (browser_->is_type_popup() && bounds->origin().IsOrigin()) {
51 *bounds = ash::Shell::GetInstance()->window_positioner()-> 47 *bounds = ash::Shell::GetInstance()->window_positioner()->
52 GetPopupPosition(*bounds); 48 GetPopupPosition(*bounds);
53 return true; 49 return true;
54 } 50 }
55 return false; 51 return false;
56 } 52 }
57 53
54 bool WindowSizer::GetBrowserBoundsAshAdjusted(
msw 2014/08/05 01:42:58 Merge this into GetBrowserBoundsAsh. Its one call
varkha 2014/08/05 15:00:20 Done. Was considering doing that but wanted to see
55 gfx::Rect* bounds,
56 ui::WindowShowState* show_state) const {
57 if (!browser_ ||
58 browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH)
59 return false;
60
61 bool determined = GetBrowserBoundsAsh(bounds, show_state);
62
63 if (*show_state == ui::SHOW_STATE_DEFAULT) {
64 gfx::Display display = screen_->GetDisplayMatching(*bounds);
65 gfx::Rect work_area = display.work_area();
66 bounds->AdjustToFit(work_area);
67 if (*bounds == work_area) {
68 // A window that occupies the whole work area gets maximized.
69 // |window_bounds| returned here become the restore bounds once the window
msw 2014/08/05 01:42:58 nit: s/|window_bounds|/|bounds|/ to match the actu
varkha 2014/08/05 15:00:20 Done.
70 // gets maximized after this method returns. Return a sensible default
71 // in order to make restored state visibly different from maximized.
72 *show_state = ui::SHOW_STATE_MAXIMIZED;
73 *bounds = ash::WindowPositioner::GetDefaultWindowBounds(display);
74 determined = true;
75 }
76 }
77 return determined;
78 }
79
58 void WindowSizer::GetTabbedBrowserBoundsAsh( 80 void WindowSizer::GetTabbedBrowserBoundsAsh(
59 gfx::Rect* bounds_in_screen, 81 gfx::Rect* bounds_in_screen,
60 ui::WindowShowState* show_state) const { 82 ui::WindowShowState* show_state) const {
61 DCHECK(show_state); 83 DCHECK(show_state);
62 DCHECK(bounds_in_screen); 84 DCHECK(bounds_in_screen);
63 DCHECK(browser_->is_type_tabbed()); 85 DCHECK(browser_->is_type_tabbed());
64 DCHECK(bounds_in_screen->IsEmpty()); 86 DCHECK(bounds_in_screen->IsEmpty());
65 87
66 ui::WindowShowState passed_show_state = *show_state; 88 ui::WindowShowState passed_show_state = *show_state;
67 89
(...skipping 30 matching lines...) Expand all
98 browser_->window() ? browser_->window()->GetNativeWindow() : NULL; 120 browser_->window() ? browser_->window()->GetNativeWindow() : NULL;
99 121
100 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow( 122 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow(
101 screen_, 123 screen_,
102 browser_window, 124 browser_window,
103 is_saved_bounds, 125 is_saved_bounds,
104 passed_show_state, 126 passed_show_state,
105 bounds_in_screen, 127 bounds_in_screen,
106 show_state); 128 show_state);
107 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698