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

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 (nits, restricts to tabbed browsers) 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_ || 18 if (!browser_ ||
19 browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) 19 browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH)
20 return false; 20 return false;
21 21
22 bool determined = false;
22 if (bounds->IsEmpty()) { 23 if (bounds->IsEmpty()) {
23 if (browser_->is_type_tabbed()) { 24 if (browser_->is_type_tabbed()) {
24 GetTabbedBrowserBoundsAsh(bounds, show_state); 25 GetTabbedBrowserBoundsAsh(bounds, show_state);
25 return true; 26 determined = true;
26 } 27 } else if (browser_->is_trusted_source()) {
27
28 if (browser_->is_trusted_source()) {
29 // For trusted popups (v1 apps and system windows), do not use the last 28 // For trusted popups (v1 apps and system windows), do not use the last
30 // active window bounds, only use saved or default bounds. 29 // active window bounds, only use saved or default bounds.
31 if (!GetSavedWindowBounds(bounds, show_state)) 30 if (!GetSavedWindowBounds(bounds, show_state))
32 GetDefaultWindowBounds(GetTargetDisplay(gfx::Rect()), bounds); 31 GetDefaultWindowBounds(GetTargetDisplay(gfx::Rect()), bounds);
33 return true; 32 determined = true;
33 } else {
34 // In Ash, prioritize the last saved |show_state|. If you have questions
35 // or comments about this behavior please contact oshima@chromium.org.
36 if (state_provider_) {
37 gfx::Rect ignored_bounds, ignored_work_area;
38 state_provider_->GetPersistentState(&ignored_bounds,
39 &ignored_work_area,
40 show_state);
41 }
34 } 42 }
35 43 } else if (browser_->is_type_popup() && bounds->origin().IsOrigin()) {
36 // In Ash, prioritize the last saved |show_state|. If you have questions 44 // In case of a popup with an 'unspecified' location in ash, we are
37 // or comments about this behavior please contact oshima@chromium.org. 45 // looking for a good screen location. We are interpreting (0,0) as an
38 if (state_provider_) { 46 // unspecified location.
39 gfx::Rect ignored_bounds, ignored_work_area; 47 *bounds = ash::Shell::GetInstance()->window_positioner()->
40 state_provider_->GetPersistentState(&ignored_bounds, 48 GetPopupPosition(*bounds);
41 &ignored_work_area, 49 determined = true;
42 show_state);
43 }
44 return false;
45 } 50 }
46 51
47 // In case of a popup with an 'unspecified' location in ash, we are 52 if (browser_->is_type_tabbed() && *show_state == ui::SHOW_STATE_DEFAULT) {
48 // looking for a good screen location. We are interpreting (0,0) as an 53 gfx::Display display = screen_->GetDisplayMatching(*bounds);
49 // unspecified location. 54 gfx::Rect work_area = display.work_area();
50 if (browser_->is_type_popup() && bounds->origin().IsOrigin()) { 55 bounds->AdjustToFit(work_area);
51 *bounds = ash::Shell::GetInstance()->window_positioner()-> 56 if (*bounds == work_area) {
52 GetPopupPosition(*bounds); 57 // A |browser_| that occupies the whole work area gets maximized.
53 return true; 58 // |bounds| returned here become the restore bounds once the window
59 // gets maximized after this method returns. Return a sensible default
60 // in order to make restored state visibly different from maximized.
61 *show_state = ui::SHOW_STATE_MAXIMIZED;
62 *bounds = ash::WindowPositioner::GetDefaultWindowBounds(display);
63 determined = true;
64 }
54 } 65 }
55 return false; 66 return determined;
56 } 67 }
57 68
58 void WindowSizer::GetTabbedBrowserBoundsAsh( 69 void WindowSizer::GetTabbedBrowserBoundsAsh(
59 gfx::Rect* bounds_in_screen, 70 gfx::Rect* bounds_in_screen,
60 ui::WindowShowState* show_state) const { 71 ui::WindowShowState* show_state) const {
61 DCHECK(show_state); 72 DCHECK(show_state);
62 DCHECK(bounds_in_screen); 73 DCHECK(bounds_in_screen);
63 DCHECK(browser_->is_type_tabbed()); 74 DCHECK(browser_->is_type_tabbed());
64 DCHECK(bounds_in_screen->IsEmpty()); 75 DCHECK(bounds_in_screen->IsEmpty());
65 76
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 browser_->window() ? browser_->window()->GetNativeWindow() : NULL; 109 browser_->window() ? browser_->window()->GetNativeWindow() : NULL;
99 110
100 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow( 111 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow(
101 screen_, 112 screen_,
102 browser_window, 113 browser_window,
103 is_saved_bounds, 114 is_saved_bounds,
104 passed_show_state, 115 passed_show_state,
105 bounds_in_screen, 116 bounds_in_screen,
106 show_state); 117 show_state);
107 } 118 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/window_sizer/window_sizer.h ('k') | chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698