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

Side by Side Diff: chrome/browser/ui/views/frame/browser_frame_ash.cc

Issue 25535005: Rename BrowserFrameAura to BrowserFrameAsh (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit as per jamescook@ Created 7 years, 2 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/frame/browser_frame_aura.h" 5 #include "chrome/browser/ui/views/frame/browser_frame_ash.h"
6 6
7 #include "base/command_line.h" 7 #include "ash/wm/window_state.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "ash/wm/window_util.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h" 9 #include "chrome/browser/ui/views/frame/browser_view.h"
10 #include "grit/chromium_strings.h"
11 #include "grit/generated_resources.h"
12 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
13 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
14 #include "ui/aura/window_observer.h" 12 #include "ui/aura/window_observer.h"
15 #include "ui/base/hit_test.h"
16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/gfx/font.h"
18 #include "ui/views/view.h" 13 #include "ui/views/view.h"
19 14
20 #if defined(USE_ASH)
21 #include "ash/wm/window_state.h"
22 #include "ash/wm/window_util.h"
23 #endif
24
25 using aura::Window; 15 using aura::Window;
26 16
27 //////////////////////////////////////////////////////////////////////////////// 17 ////////////////////////////////////////////////////////////////////////////////
28 // BrowserFrameAura::WindowPropertyWatcher 18 // BrowserFrameAsh::WindowPropertyWatcher
29 19
30 class BrowserFrameAura::WindowPropertyWatcher : public aura::WindowObserver { 20 class BrowserFrameAsh::WindowPropertyWatcher : public aura::WindowObserver {
31 public: 21 public:
32 explicit WindowPropertyWatcher(BrowserFrameAura* browser_frame_aura, 22 explicit WindowPropertyWatcher(BrowserFrameAsh* browser_frame_ash,
33 BrowserFrame* browser_frame) 23 BrowserFrame* browser_frame)
34 : browser_frame_aura_(browser_frame_aura), 24 : browser_frame_ash_(browser_frame_ash),
35 browser_frame_(browser_frame) {} 25 browser_frame_(browser_frame) {}
36 26
37 virtual void OnWindowPropertyChanged(aura::Window* window, 27 virtual void OnWindowPropertyChanged(aura::Window* window,
38 const void* key, 28 const void* key,
39 intptr_t old) OVERRIDE { 29 intptr_t old) OVERRIDE {
40 if (key != aura::client::kShowStateKey) 30 if (key != aura::client::kShowStateKey)
41 return; 31 return;
42 32
43 ui::WindowShowState old_state = static_cast<ui::WindowShowState>(old); 33 ui::WindowShowState old_state = static_cast<ui::WindowShowState>(old);
44 ui::WindowShowState new_state = 34 ui::WindowShowState new_state =
45 window->GetProperty(aura::client::kShowStateKey); 35 window->GetProperty(aura::client::kShowStateKey);
46 36
47 // Allow the frame to be replaced when entering or exiting the maximized 37 // Allow the frame to be replaced when entering or exiting the maximized
48 // state. 38 // state.
49 if (browser_frame_->non_client_view() && 39 if (browser_frame_->non_client_view() &&
50 browser_frame_aura_->browser_view()->browser()->is_app() && 40 browser_frame_ash_->browser_view()->browser()->is_app() &&
51 (old_state == ui::SHOW_STATE_MAXIMIZED || 41 (old_state == ui::SHOW_STATE_MAXIMIZED ||
52 new_state == ui::SHOW_STATE_MAXIMIZED)) { 42 new_state == ui::SHOW_STATE_MAXIMIZED)) {
53 // Defer frame layout when replacing the frame. Layout will occur when the 43 // Defer frame layout when replacing the frame. Layout will occur when the
54 // window's bounds are updated. The window maximize/restore animations 44 // window's bounds are updated. The window maximize/restore animations
55 // clone the window's layers and rely on the subsequent layout to set 45 // clone the window's layers and rely on the subsequent layout to set
56 // the layer sizes. 46 // the layer sizes.
57 // If the window is minimized, the frame view needs to be updated via 47 // If the window is minimized, the frame view needs to be updated via
58 // an OnBoundsChanged event so that the frame will change its size 48 // an OnBoundsChanged event so that the frame will change its size
59 // properly. 49 // properly.
60 browser_frame_->non_client_view()->UpdateFrame( 50 browser_frame_->non_client_view()->UpdateFrame(
61 old_state == ui::SHOW_STATE_MINIMIZED); 51 old_state == ui::SHOW_STATE_MINIMIZED);
62 } 52 }
63 } 53 }
64 54
65 virtual void OnWindowBoundsChanged(aura::Window* window, 55 virtual void OnWindowBoundsChanged(aura::Window* window,
66 const gfx::Rect& old_bounds, 56 const gfx::Rect& old_bounds,
67 const gfx::Rect& new_bounds) OVERRIDE { 57 const gfx::Rect& new_bounds) OVERRIDE {
68 // Don't do anything if we don't have our non-client view yet. 58 // Don't do anything if we don't have our non-client view yet.
69 if (!browser_frame_->non_client_view()) 59 if (!browser_frame_->non_client_view())
70 return; 60 return;
71 61
72 // If the window just moved to the top of the screen, or just moved away 62 // If the window just moved to the top of the screen, or just moved away
73 // from it, invoke Layout() so the header size can change. 63 // from it, invoke Layout() so the header size can change.
74 if ((old_bounds.y() == 0 && new_bounds.y() != 0) || 64 if ((old_bounds.y() == 0 && new_bounds.y() != 0) ||
75 (old_bounds.y() != 0 && new_bounds.y() == 0)) 65 (old_bounds.y() != 0 && new_bounds.y() == 0))
76 browser_frame_->non_client_view()->Layout(); 66 browser_frame_->non_client_view()->Layout();
77 } 67 }
78 68
79 private: 69 private:
80 BrowserFrameAura* browser_frame_aura_; 70 BrowserFrameAsh* browser_frame_ash_;
81 BrowserFrame* browser_frame_; 71 BrowserFrame* browser_frame_;
82 72
83 DISALLOW_COPY_AND_ASSIGN(WindowPropertyWatcher); 73 DISALLOW_COPY_AND_ASSIGN(WindowPropertyWatcher);
84 }; 74 };
85 75
86 /////////////////////////////////////////////////////////////////////////////// 76 ///////////////////////////////////////////////////////////////////////////////
87 // BrowserFrameAura, public: 77 // BrowserFrameAsh, public:
88 78
89 // static 79 // static
90 const char BrowserFrameAura::kWindowName[] = "BrowserFrameAura"; 80 const char BrowserFrameAsh::kWindowName[] = "BrowserFrameAsh";
91 81
92 BrowserFrameAura::BrowserFrameAura(BrowserFrame* browser_frame, 82 BrowserFrameAsh::BrowserFrameAsh(BrowserFrame* browser_frame,
93 BrowserView* browser_view) 83 BrowserView* browser_view)
94 : views::NativeWidgetAura(browser_frame), 84 : views::NativeWidgetAura(browser_frame),
95 browser_view_(browser_view), 85 browser_view_(browser_view),
96 window_property_watcher_(new WindowPropertyWatcher(this, browser_frame)) { 86 window_property_watcher_(new WindowPropertyWatcher(this, browser_frame)) {
97 GetNativeWindow()->SetName(kWindowName); 87 GetNativeWindow()->SetName(kWindowName);
98 GetNativeWindow()->AddObserver(window_property_watcher_.get()); 88 GetNativeWindow()->AddObserver(window_property_watcher_.get());
99 #if defined(USE_ASH)
100 if (browser_view->browser()->is_type_tabbed()) 89 if (browser_view->browser()->is_type_tabbed())
101 ash::wm::SetAnimateToFullscreen(GetNativeWindow(), false); 90 ash::wm::SetAnimateToFullscreen(GetNativeWindow(), false);
102 91
103 // Turn on auto window management if we don't need an explicit bounds. 92 // Turn on auto window management if we don't need an explicit bounds.
104 // This way the requested bounds are honored. 93 // This way the requested bounds are honored.
105 if (!browser_view->browser()->bounds_overridden() && 94 if (!browser_view->browser()->bounds_overridden() &&
106 !browser_view->browser()->is_session_restore()) 95 !browser_view->browser()->is_session_restore())
107 SetWindowAutoManaged(); 96 SetWindowAutoManaged();
108 #endif
109 #if defined(OS_CHROMEOS) 97 #if defined(OS_CHROMEOS)
110 // For legacy reasons v1 apps (like Secure Shell) are allowed to consume keys 98 // For legacy reasons v1 apps (like Secure Shell) are allowed to consume keys
111 // like brightness, volume, etc. Otherwise these keys are handled by the 99 // like brightness, volume, etc. Otherwise these keys are handled by the
112 // Ash window manager. 100 // Ash window manager.
113 if (browser_view->browser()->is_app()) { 101 if (browser_view->browser()->is_app()) {
114 ash::wm::GetWindowState(GetNativeWindow())-> 102 ash::wm::GetWindowState(GetNativeWindow())->
115 set_can_consume_system_keys(true); 103 set_can_consume_system_keys(true);
116 } 104 }
117 #endif // defined(OS_CHROMEOS) 105 #endif // defined(OS_CHROMEOS)
118 } 106 }
119 107
120 /////////////////////////////////////////////////////////////////////////////// 108 ///////////////////////////////////////////////////////////////////////////////
121 // BrowserFrameAura, views::NativeWidgetAura overrides: 109 // BrowserFrameAsh, views::NativeWidgetAura overrides:
122 110
123 void BrowserFrameAura::OnWindowDestroying() { 111 void BrowserFrameAsh::OnWindowDestroying() {
124 // Window is destroyed before our destructor is called, so clean up our 112 // Window is destroyed before our destructor is called, so clean up our
125 // observer here. 113 // observer here.
126 GetNativeWindow()->RemoveObserver(window_property_watcher_.get()); 114 GetNativeWindow()->RemoveObserver(window_property_watcher_.get());
127 views::NativeWidgetAura::OnWindowDestroying(); 115 views::NativeWidgetAura::OnWindowDestroying();
128 } 116 }
129 117
130 void BrowserFrameAura::OnWindowTargetVisibilityChanged(bool visible) { 118 void BrowserFrameAsh::OnWindowTargetVisibilityChanged(bool visible) {
131 if (visible) { 119 if (visible) {
132 // Once the window has been shown we know the requested bounds 120 // Once the window has been shown we know the requested bounds
133 // (if provided) have been honored and we can switch on window management. 121 // (if provided) have been honored and we can switch on window management.
134 SetWindowAutoManaged(); 122 SetWindowAutoManaged();
135 } 123 }
136 views::NativeWidgetAura::OnWindowTargetVisibilityChanged(visible); 124 views::NativeWidgetAura::OnWindowTargetVisibilityChanged(visible);
137 } 125 }
138 126
139 //////////////////////////////////////////////////////////////////////////////// 127 ////////////////////////////////////////////////////////////////////////////////
140 // BrowserFrameAura, NativeBrowserFrame implementation: 128 // BrowserFrameAsh, NativeBrowserFrame implementation:
141 129
142 views::NativeWidget* BrowserFrameAura::AsNativeWidget() { 130 views::NativeWidget* BrowserFrameAsh::AsNativeWidget() {
143 return this; 131 return this;
144 } 132 }
145 133
146 const views::NativeWidget* BrowserFrameAura::AsNativeWidget() const { 134 const views::NativeWidget* BrowserFrameAsh::AsNativeWidget() const {
147 return this; 135 return this;
148 } 136 }
149 137
150 bool BrowserFrameAura::UsesNativeSystemMenu() const { 138 bool BrowserFrameAsh::UsesNativeSystemMenu() const {
151 return false; 139 return false;
152 } 140 }
153 141
154 int BrowserFrameAura::GetMinimizeButtonOffset() const { 142 int BrowserFrameAsh::GetMinimizeButtonOffset() const {
155 return 0; 143 return 0;
156 } 144 }
157 145
158 void BrowserFrameAura::TabStripDisplayModeChanged() { 146 void BrowserFrameAsh::TabStripDisplayModeChanged() {
159 }
160
161 ////////////////////////////////////////////////////////////////////////////////
162 // BrowserFrame, public:
163
164 // static
165 const gfx::Font& BrowserFrame::GetTitleFont() {
166 static gfx::Font* title_font = new gfx::Font;
167 return *title_font;
168 } 147 }
169 148
170 /////////////////////////////////////////////////////////////////////////////// 149 ///////////////////////////////////////////////////////////////////////////////
171 // BrowserFrameAura, private: 150 // BrowserFrameAsh, private:
172 151
173 BrowserFrameAura::~BrowserFrameAura() { 152 BrowserFrameAsh::~BrowserFrameAsh() {
174 } 153 }
175 154
176 void BrowserFrameAura::SetWindowAutoManaged() { 155 void BrowserFrameAsh::SetWindowAutoManaged() {
177 #if defined(USE_ASH)
178 if (browser_view_->browser()->type() != Browser::TYPE_POPUP || 156 if (browser_view_->browser()->type() != Browser::TYPE_POPUP ||
179 browser_view_->browser()->is_app()) { 157 browser_view_->browser()->is_app()) {
180 ash::wm::GetWindowState(GetNativeWindow())-> 158 ash::wm::GetWindowState(GetNativeWindow())->
181 set_window_position_managed(true); 159 set_window_position_managed(true);
182 } 160 }
183 #endif
184 } 161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698