Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_aura.h" |
| 6 | 6 |
| 7 #include "base/debug/stack_trace.h" | 7 #include "base/debug/stack_trace.h" |
| 8 #include "chrome/browser/ui/views/frame/browser_frame.h" | 8 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 9 #include "chrome/browser/ui/views/frame/browser_view.h" | 9 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 10 #include "grit/ash_resources.h" | 10 #include "grit/ash_resources.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { | 155 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { |
| 156 owner_->CloseControlWidget(); | 156 owner_->CloseControlWidget(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 private: | 159 private: |
| 160 AppNonClientFrameViewAura* owner_; | 160 AppNonClientFrameViewAura* owner_; |
| 161 | 161 |
| 162 DISALLOW_COPY_AND_ASSIGN(FrameObserver); | 162 DISALLOW_COPY_AND_ASSIGN(FrameObserver); |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 const char AppNonClientFrameViewAura::kControlWindowName[] = | |
|
sky
2012/09/20 20:02:15
Typically we put:
// static
on the line before thi
James Cook
2012/09/20 20:06:54
Done.
| |
| 166 "AppNonClientFrameViewAuraControls"; | |
| 167 | |
| 165 AppNonClientFrameViewAura::AppNonClientFrameViewAura( | 168 AppNonClientFrameViewAura::AppNonClientFrameViewAura( |
| 166 BrowserFrame* frame, BrowserView* browser_view) | 169 BrowserFrame* frame, BrowserView* browser_view) |
| 167 : BrowserNonClientFrameView(frame, browser_view), | 170 : BrowserNonClientFrameView(frame, browser_view), |
| 168 control_view_(new ControlView(this)), | 171 control_view_(new ControlView(this)), |
| 169 control_widget_(NULL), | 172 control_widget_(NULL), |
| 170 frame_observer_(new FrameObserver(this)) { | 173 frame_observer_(new FrameObserver(this)) { |
| 171 // This FrameView is always maximized so we don't want the window to have | 174 // This FrameView is always maximized so we don't want the window to have |
| 172 // resize borders. | 175 // resize borders. |
| 173 frame->GetNativeView()->set_hit_test_bounds_override_inner(gfx::Insets()); | 176 frame->GetNativeView()->set_hit_test_bounds_override_inner(gfx::Insets()); |
| 174 // Watch for frame close so we can clean up the control widget. | 177 // Watch for frame close so we can clean up the control widget. |
| 175 frame->AddObserver(frame_observer_.get()); | 178 frame->AddObserver(frame_observer_.get()); |
| 176 set_background(views::Background::CreateSolidBackground(SK_ColorBLACK)); | 179 set_background(views::Background::CreateSolidBackground(SK_ColorBLACK)); |
| 177 // Create the controls. | 180 // Create the controls. |
| 178 control_widget_ = new views::Widget; | 181 control_widget_ = new views::Widget; |
| 179 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); | 182 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); |
| 180 params.parent = browser_view->GetNativeWindow(); | 183 params.parent = browser_view->GetNativeWindow(); |
| 181 params.transparent = true; | 184 params.transparent = true; |
| 182 control_widget_->Init(params); | 185 control_widget_->Init(params); |
| 183 control_widget_->SetContentsView(control_view_); | 186 control_widget_->SetContentsView(control_view_); |
| 184 aura::Window* window = control_widget_->GetNativeView(); | 187 aura::Window* window = control_widget_->GetNativeView(); |
| 185 window->SetName("AppNonClientFrameViewAuraControls"); | 188 window->SetName(kControlWindowName); |
| 186 gfx::Rect control_bounds = GetControlBounds(); | 189 gfx::Rect control_bounds = GetControlBounds(); |
| 187 window->SetBounds(control_bounds); | 190 window->SetBounds(control_bounds); |
| 188 control_widget_->Show(); | 191 control_widget_->Show(); |
| 189 } | 192 } |
| 190 | 193 |
| 191 AppNonClientFrameViewAura::~AppNonClientFrameViewAura() { | 194 AppNonClientFrameViewAura::~AppNonClientFrameViewAura() { |
| 192 frame()->RemoveObserver(frame_observer_.get()); | 195 frame()->RemoveObserver(frame_observer_.get()); |
| 196 // This frame view can be replaced (and deleted) if the window is restored | |
| 197 // via a keyboard shortcut like Alt-[. Ensure we close the control widget. | |
| 198 CloseControlWidget(); | |
| 193 } | 199 } |
| 194 | 200 |
| 195 gfx::Rect AppNonClientFrameViewAura::GetBoundsForClientView() const { | 201 gfx::Rect AppNonClientFrameViewAura::GetBoundsForClientView() const { |
| 196 return GetLocalBounds(); | 202 return GetLocalBounds(); |
| 197 } | 203 } |
| 198 | 204 |
| 199 gfx::Rect AppNonClientFrameViewAura::GetWindowBoundsForClientBounds( | 205 gfx::Rect AppNonClientFrameViewAura::GetWindowBoundsForClientBounds( |
| 200 const gfx::Rect& client_bounds) const { | 206 const gfx::Rect& client_bounds) const { |
| 201 return client_bounds; | 207 return client_bounds; |
| 202 } | 208 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 location.x(), location.y(), | 255 location.x(), location.y(), |
| 250 preferred.width(), preferred.height()); | 256 preferred.width(), preferred.height()); |
| 251 } | 257 } |
| 252 | 258 |
| 253 void AppNonClientFrameViewAura::CloseControlWidget() { | 259 void AppNonClientFrameViewAura::CloseControlWidget() { |
| 254 if (control_widget_) { | 260 if (control_widget_) { |
| 255 control_widget_->Close(); | 261 control_widget_->Close(); |
| 256 control_widget_ = NULL; | 262 control_widget_ = NULL; |
| 257 } | 263 } |
| 258 } | 264 } |
| OLD | NEW |