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

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

Issue 11229041: Rename and move Ash window frame files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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/app_non_client_frame_view_aura.h" 5 #include "chrome/browser/ui/views/frame/app_non_client_frame_view_ash.h"
6 6
7 #include "ash/wm/workspace/frame_maximize_button.h"
7 #include "base/debug/stack_trace.h" 8 #include "base/debug/stack_trace.h"
8 #include "chrome/browser/ui/views/frame/browser_frame.h" 9 #include "chrome/browser/ui/views/frame/browser_frame.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h" 10 #include "chrome/browser/ui/views/frame/browser_view.h"
10 #include "grit/ash_resources.h" 11 #include "grit/ash_resources.h"
11 #include "grit/generated_resources.h" // Accessibility names 12 #include "grit/generated_resources.h" // Accessibility names
12 #include "grit/theme_resources.h" 13 #include "grit/theme_resources.h"
13 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
14 #include "ui/base/hit_test.h" 15 #include "ui/base/hit_test.h"
15 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/base/theme_provider.h" 18 #include "ui/base/theme_provider.h"
18 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
19 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
20 #include "ui/gfx/point.h" 21 #include "ui/gfx/point.h"
21 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
22 #include "ui/gfx/size.h" 23 #include "ui/gfx/size.h"
23 #include "ui/views/controls/button/image_button.h" 24 #include "ui/views/controls/button/image_button.h"
24 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
25 #include "ui/views/window/non_client_view.h" 26 #include "ui/views/window/non_client_view.h"
26 27
27 #if defined(USE_ASH)
28 #include "ash/wm/workspace/frame_maximize_button.h"
29 #endif
30
31 namespace { 28 namespace {
32 // The number of pixels within the shadow to draw the buttons. 29 // The number of pixels within the shadow to draw the buttons.
33 const int kShadowStart = 16; 30 const int kShadowStart = 16;
34 // The size and close buttons are designed to overlap. 31 // The size and close buttons are designed to overlap.
35 const int kButtonOverlap = 1; 32 const int kButtonOverlap = 1;
36 33
37 // TODO(pkotwicz): Remove these constants once the IDR_AURA_FULLSCREEN_SHADOW 34 // TODO(pkotwicz): Remove these constants once the IDR_AURA_FULLSCREEN_SHADOW
38 // resource is updated. 35 // resource is updated.
39 const int kShadowHeightStretch = -1; 36 const int kShadowHeightStretch = -1;
40 } 37 }
41 38
42 class AppNonClientFrameViewAura::ControlView 39 class AppNonClientFrameViewAsh::ControlView
43 : public views::View, public views::ButtonListener { 40 : public views::View, public views::ButtonListener {
44 public: 41 public:
45 explicit ControlView(AppNonClientFrameViewAura* owner) : 42 explicit ControlView(AppNonClientFrameViewAsh* owner) :
46 owner_(owner), 43 owner_(owner),
47 close_button_(new views::ImageButton(this)), 44 close_button_(new views::ImageButton(this)),
48 #if defined(USE_ASH)
49 restore_button_(new ash::FrameMaximizeButton(this, owner_)) 45 restore_button_(new ash::FrameMaximizeButton(this, owner_))
50 #else
51 restore_button_(new views::ImageButton(this))
52 #endif
53 { 46 {
54 close_button_->SetAccessibleName( 47 close_button_->SetAccessibleName(
55 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); 48 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
56 restore_button_->SetAccessibleName( 49 restore_button_->SetAccessibleName(
57 l10n_util::GetStringUTF16(IDS_ACCNAME_MAXIMIZE)); 50 l10n_util::GetStringUTF16(IDS_ACCNAME_MAXIMIZE));
58 51
59 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 52 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
60 53
61 int control_base_resource_id = owner->browser_view()->IsOffTheRecord() ? 54 int control_base_resource_id = owner->browser_view()->IsOffTheRecord() ?
62 IDR_AURA_WINDOW_HEADER_BASE_INCOGNITO_ACTIVE : 55 IDR_AURA_WINDOW_HEADER_BASE_INCOGNITO_ACTIVE :
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 int hot_image_id, int pushed_image_id) { 120 int hot_image_id, int pushed_image_id) {
128 ui::ThemeProvider* theme_provider = GetThemeProvider(); 121 ui::ThemeProvider* theme_provider = GetThemeProvider();
129 button->SetImage(views::CustomButton::BS_NORMAL, 122 button->SetImage(views::CustomButton::BS_NORMAL,
130 theme_provider->GetImageSkiaNamed(normal_image_id)); 123 theme_provider->GetImageSkiaNamed(normal_image_id));
131 button->SetImage(views::CustomButton::BS_HOT, 124 button->SetImage(views::CustomButton::BS_HOT,
132 theme_provider->GetImageSkiaNamed(hot_image_id)); 125 theme_provider->GetImageSkiaNamed(hot_image_id));
133 button->SetImage(views::CustomButton::BS_PUSHED, 126 button->SetImage(views::CustomButton::BS_PUSHED,
134 theme_provider->GetImageSkiaNamed(pushed_image_id)); 127 theme_provider->GetImageSkiaNamed(pushed_image_id));
135 } 128 }
136 129
137 AppNonClientFrameViewAura* owner_; 130 AppNonClientFrameViewAsh* owner_;
138 views::ImageButton* close_button_; 131 views::ImageButton* close_button_;
139 views::ImageButton* restore_button_; 132 views::ImageButton* restore_button_;
140 const gfx::ImageSkia* control_base_; 133 const gfx::ImageSkia* control_base_;
141 const gfx::ImageSkia* shadow_; 134 const gfx::ImageSkia* shadow_;
142 135
143 DISALLOW_COPY_AND_ASSIGN(ControlView); 136 DISALLOW_COPY_AND_ASSIGN(ControlView);
144 }; 137 };
145 138
146 // Observer to detect when the browser frame widget closes so we can clean 139 // Observer to detect when the browser frame widget closes so we can clean
147 // up our ControlView. Because we can be closed via a keyboard shortcut we 140 // up our ControlView. Because we can be closed via a keyboard shortcut we
148 // are not guaranteed to run AppNonClientFrameView's Close() or Restore(). 141 // are not guaranteed to run AppNonClientFrameView's Close() or Restore().
149 class AppNonClientFrameViewAura::FrameObserver : public views::WidgetObserver { 142 class AppNonClientFrameViewAsh::FrameObserver : public views::WidgetObserver {
150 public: 143 public:
151 explicit FrameObserver(AppNonClientFrameViewAura* owner) : owner_(owner) {} 144 explicit FrameObserver(AppNonClientFrameViewAsh* owner) : owner_(owner) {}
152 virtual ~FrameObserver() {} 145 virtual ~FrameObserver() {}
153 146
154 // views::WidgetObserver: 147 // views::WidgetObserver:
155 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { 148 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE {
156 owner_->CloseControlWidget(); 149 owner_->CloseControlWidget();
157 } 150 }
158 151
159 private: 152 private:
160 AppNonClientFrameViewAura* owner_; 153 AppNonClientFrameViewAsh* owner_;
161 154
162 DISALLOW_COPY_AND_ASSIGN(FrameObserver); 155 DISALLOW_COPY_AND_ASSIGN(FrameObserver);
163 }; 156 };
164 157
165 // static 158 // static
166 const char AppNonClientFrameViewAura::kViewClassName[] = 159 const char AppNonClientFrameViewAsh::kViewClassName[] =
167 "AppNonClientFrameViewAura"; 160 "AppNonClientFrameViewAsh";
168 // static 161 // static
169 const char AppNonClientFrameViewAura::kControlWindowName[] = 162 const char AppNonClientFrameViewAsh::kControlWindowName[] =
170 "AppNonClientFrameViewAuraControls"; 163 "AppNonClientFrameViewAshControls";
171 164
172 AppNonClientFrameViewAura::AppNonClientFrameViewAura( 165 AppNonClientFrameViewAsh::AppNonClientFrameViewAsh(
173 BrowserFrame* frame, BrowserView* browser_view) 166 BrowserFrame* frame, BrowserView* browser_view)
174 : BrowserNonClientFrameView(frame, browser_view), 167 : BrowserNonClientFrameView(frame, browser_view),
175 control_view_(new ControlView(this)), 168 control_view_(new ControlView(this)),
176 control_widget_(NULL), 169 control_widget_(NULL),
177 frame_observer_(new FrameObserver(this)) { 170 frame_observer_(new FrameObserver(this)) {
178 // This FrameView is always maximized so we don't want the window to have 171 // This FrameView is always maximized so we don't want the window to have
179 // resize borders. 172 // resize borders.
180 frame->GetNativeView()->set_hit_test_bounds_override_inner(gfx::Insets()); 173 frame->GetNativeView()->set_hit_test_bounds_override_inner(gfx::Insets());
181 // Watch for frame close so we can clean up the control widget. 174 // Watch for frame close so we can clean up the control widget.
182 frame->AddObserver(frame_observer_.get()); 175 frame->AddObserver(frame_observer_.get());
183 set_background(views::Background::CreateSolidBackground(SK_ColorBLACK)); 176 set_background(views::Background::CreateSolidBackground(SK_ColorBLACK));
184 // Create the controls. 177 // Create the controls.
185 control_widget_ = new views::Widget; 178 control_widget_ = new views::Widget;
186 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); 179 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
187 params.parent = browser_view->GetNativeWindow(); 180 params.parent = browser_view->GetNativeWindow();
188 params.transparent = true; 181 params.transparent = true;
189 control_widget_->Init(params); 182 control_widget_->Init(params);
190 control_widget_->SetContentsView(control_view_); 183 control_widget_->SetContentsView(control_view_);
191 aura::Window* window = control_widget_->GetNativeView(); 184 aura::Window* window = control_widget_->GetNativeView();
192 window->SetName(kControlWindowName); 185 window->SetName(kControlWindowName);
193 gfx::Rect control_bounds = GetControlBounds(); 186 gfx::Rect control_bounds = GetControlBounds();
194 window->SetBounds(control_bounds); 187 window->SetBounds(control_bounds);
195 control_widget_->Show(); 188 control_widget_->Show();
196 } 189 }
197 190
198 AppNonClientFrameViewAura::~AppNonClientFrameViewAura() { 191 AppNonClientFrameViewAsh::~AppNonClientFrameViewAsh() {
199 frame()->RemoveObserver(frame_observer_.get()); 192 frame()->RemoveObserver(frame_observer_.get());
200 // This frame view can be replaced (and deleted) if the window is restored 193 // This frame view can be replaced (and deleted) if the window is restored
201 // via a keyboard shortcut like Alt-[. Ensure we close the control widget. 194 // via a keyboard shortcut like Alt-[. Ensure we close the control widget.
202 CloseControlWidget(); 195 CloseControlWidget();
203 } 196 }
204 197
205 gfx::Rect AppNonClientFrameViewAura::GetBoundsForClientView() const { 198 gfx::Rect AppNonClientFrameViewAsh::GetBoundsForClientView() const {
206 return GetLocalBounds(); 199 return GetLocalBounds();
207 } 200 }
208 201
209 gfx::Rect AppNonClientFrameViewAura::GetWindowBoundsForClientBounds( 202 gfx::Rect AppNonClientFrameViewAsh::GetWindowBoundsForClientBounds(
210 const gfx::Rect& client_bounds) const { 203 const gfx::Rect& client_bounds) const {
211 return client_bounds; 204 return client_bounds;
212 } 205 }
213 206
214 int AppNonClientFrameViewAura::NonClientHitTest( 207 int AppNonClientFrameViewAsh::NonClientHitTest(
215 const gfx::Point& point) { 208 const gfx::Point& point) {
216 return HTNOWHERE; 209 return HTNOWHERE;
217 } 210 }
218 211
219 void AppNonClientFrameViewAura::GetWindowMask(const gfx::Size& size, 212 void AppNonClientFrameViewAsh::GetWindowMask(const gfx::Size& size,
220 gfx::Path* window_mask) { 213 gfx::Path* window_mask) {
221 } 214 }
222 215
223 void AppNonClientFrameViewAura::ResetWindowControls() { 216 void AppNonClientFrameViewAsh::ResetWindowControls() {
224 } 217 }
225 218
226 void AppNonClientFrameViewAura::UpdateWindowIcon() { 219 void AppNonClientFrameViewAsh::UpdateWindowIcon() {
227 } 220 }
228 221
229 void AppNonClientFrameViewAura::UpdateWindowTitle() { 222 void AppNonClientFrameViewAsh::UpdateWindowTitle() {
230 } 223 }
231 224
232 gfx::Rect AppNonClientFrameViewAura::GetBoundsForTabStrip( 225 gfx::Rect AppNonClientFrameViewAsh::GetBoundsForTabStrip(
233 views::View* tabstrip) const { 226 views::View* tabstrip) const {
234 return gfx::Rect(); 227 return gfx::Rect();
235 } 228 }
236 229
237 BrowserNonClientFrameView::TabStripInsets 230 BrowserNonClientFrameView::TabStripInsets
238 AppNonClientFrameViewAura::GetTabStripInsets(bool restored) const { 231 AppNonClientFrameViewAsh::GetTabStripInsets(bool restored) const {
239 return TabStripInsets(); 232 return TabStripInsets();
240 } 233 }
241 234
242 int AppNonClientFrameViewAura::GetThemeBackgroundXInset() const { 235 int AppNonClientFrameViewAsh::GetThemeBackgroundXInset() const {
243 return 0; 236 return 0;
244 } 237 }
245 238
246 void AppNonClientFrameViewAura::UpdateThrobber(bool running) { 239 void AppNonClientFrameViewAsh::UpdateThrobber(bool running) {
247 } 240 }
248 241
249 std::string AppNonClientFrameViewAura::GetClassName() const { 242 std::string AppNonClientFrameViewAsh::GetClassName() const {
250 return kViewClassName; 243 return kViewClassName;
251 } 244 }
252 245
253 void AppNonClientFrameViewAura::OnBoundsChanged( 246 void AppNonClientFrameViewAsh::OnBoundsChanged(
254 const gfx::Rect& previous_bounds) { 247 const gfx::Rect& previous_bounds) {
255 if (control_widget_) 248 if (control_widget_)
256 control_widget_->GetNativeView()->SetBounds(GetControlBounds()); 249 control_widget_->GetNativeView()->SetBounds(GetControlBounds());
257 } 250 }
258 251
259 gfx::Rect AppNonClientFrameViewAura::GetControlBounds() const { 252 gfx::Rect AppNonClientFrameViewAsh::GetControlBounds() const {
260 if (!control_view_) 253 if (!control_view_)
261 return gfx::Rect(); 254 return gfx::Rect();
262 gfx::Size preferred = control_view_->GetPreferredSize(); 255 gfx::Size preferred = control_view_->GetPreferredSize();
263 return gfx::Rect( 256 return gfx::Rect(
264 width() - preferred.width(), 0, 257 width() - preferred.width(), 0,
265 preferred.width(), preferred.height()); 258 preferred.width(), preferred.height());
266 } 259 }
267 260
268 void AppNonClientFrameViewAura::CloseControlWidget() { 261 void AppNonClientFrameViewAsh::CloseControlWidget() {
269 if (control_widget_) { 262 if (control_widget_) {
270 control_widget_->Close(); 263 control_widget_->Close();
271 control_widget_ = NULL; 264 control_widget_ = NULL;
272 } 265 }
273 } 266 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698