| 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/browser_frame_aura.h" | 5 #include "chrome/browser/ui/views/frame/browser_frame_aura.h" |
| 6 | 6 |
| 7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/ui/views/frame/browser_view.h" | 8 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 9 #include "chrome/browser/ui/views/frame/system_menu_model_delegate.h" | 9 #include "chrome/browser/ui/views/frame/system_menu_model_delegate.h" |
| 10 #include "grit/chromium_strings.h" | 10 #include "grit/chromium_strings.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 browser_frame_(browser_frame) {} | 37 browser_frame_(browser_frame) {} |
| 38 | 38 |
| 39 virtual void OnWindowPropertyChanged(aura::Window* window, | 39 virtual void OnWindowPropertyChanged(aura::Window* window, |
| 40 const void* key, | 40 const void* key, |
| 41 intptr_t old) OVERRIDE { | 41 intptr_t old) OVERRIDE { |
| 42 if (key != aura::client::kShowStateKey) | 42 if (key != aura::client::kShowStateKey) |
| 43 return; | 43 return; |
| 44 | 44 |
| 45 // Allow the frame to be replaced when maximizing an app. | 45 // Allow the frame to be replaced when maximizing an app. |
| 46 if (browser_frame_->non_client_view() && | 46 if (browser_frame_->non_client_view() && |
| 47 browser_frame_aura_->browser_view()->browser()->is_app()) | 47 browser_frame_aura_->browser_view()->browser()->is_app()) { |
| 48 browser_frame_->non_client_view()->UpdateFrame(); | 48 // Defer frame layout when replacing the frame. Layout will occur when the |
| 49 // window's bounds are updated. The window maximize/restore animations |
| 50 // clone the window's layers and rely on the subsequent layout to set |
| 51 // the layer sizes. |
| 52 browser_frame_->non_client_view()->UpdateFrame(false); |
| 53 } |
| 49 } | 54 } |
| 50 | 55 |
| 51 virtual void OnWindowBoundsChanged(aura::Window* window, | 56 virtual void OnWindowBoundsChanged(aura::Window* window, |
| 52 const gfx::Rect& old_bounds, | 57 const gfx::Rect& old_bounds, |
| 53 const gfx::Rect& new_bounds) OVERRIDE { | 58 const gfx::Rect& new_bounds) OVERRIDE { |
| 54 // Don't do anything if we don't have our non-client view yet. | 59 // Don't do anything if we don't have our non-client view yet. |
| 55 if (!browser_frame_->non_client_view()) | 60 if (!browser_frame_->non_client_view()) |
| 56 return; | 61 return; |
| 57 | 62 |
| 58 // If the window just moved to the top of the screen, or just moved away | 63 // If the window just moved to the top of the screen, or just moved away |
| (...skipping 19 matching lines...) Expand all Loading... |
| 78 browser_view_(browser_view), | 83 browser_view_(browser_view), |
| 79 window_property_watcher_(new WindowPropertyWatcher(this, browser_frame)) { | 84 window_property_watcher_(new WindowPropertyWatcher(this, browser_frame)) { |
| 80 GetNativeWindow()->SetName("BrowserFrameAura"); | 85 GetNativeWindow()->SetName("BrowserFrameAura"); |
| 81 GetNativeWindow()->AddObserver(window_property_watcher_.get()); | 86 GetNativeWindow()->AddObserver(window_property_watcher_.get()); |
| 82 #if defined(USE_ASH) | 87 #if defined(USE_ASH) |
| 83 if (browser_view->browser()->type() != Browser::TYPE_POPUP) { | 88 if (browser_view->browser()->type() != Browser::TYPE_POPUP) { |
| 84 ash::SetPersistsAcrossAllWorkspaces( | 89 ash::SetPersistsAcrossAllWorkspaces( |
| 85 GetNativeWindow(), | 90 GetNativeWindow(), |
| 86 ash::WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_NO); | 91 ash::WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_NO); |
| 87 } | 92 } |
| 88 // HACK: Don't animate app windows. They delete and rebuild their frame on | |
| 89 // maximize, which breaks the layer animations. We probably shouldn't rebuild | |
| 90 // the frame view on this transition. | |
| 91 // TODO(jamescook): Fix app window animation. http://crbug.com/131293 | |
| 92 if (browser_view->browser()->is_app()) { | |
| 93 Window* window = GetNativeWindow(); | |
| 94 window->SetProperty(aura::client::kAnimationsDisabledKey, true); | |
| 95 } | |
| 96 #endif | 93 #endif |
| 97 } | 94 } |
| 98 | 95 |
| 99 /////////////////////////////////////////////////////////////////////////////// | 96 /////////////////////////////////////////////////////////////////////////////// |
| 100 // BrowserFrameAura, views::ContextMenuController overrides: | 97 // BrowserFrameAura, views::ContextMenuController overrides: |
| 101 void BrowserFrameAura::ShowContextMenuForView(views::View* source, | 98 void BrowserFrameAura::ShowContextMenuForView(views::View* source, |
| 102 const gfx::Point& p) { | 99 const gfx::Point& p) { |
| 103 // Only show context menu if point is in unobscured parts of browser, i.e. | 100 // Only show context menu if point is in unobscured parts of browser, i.e. |
| 104 // if NonClientHitTest returns : | 101 // if NonClientHitTest returns : |
| 105 // - HTCAPTION: in title bar or unobscured part of tabstrip | 102 // - HTCAPTION: in title bar or unobscured part of tabstrip |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 BrowserFrame* browser_frame, | 188 BrowserFrame* browser_frame, |
| 192 BrowserView* browser_view) { | 189 BrowserView* browser_view) { |
| 193 return new BrowserFrameAura(browser_frame, browser_view); | 190 return new BrowserFrameAura(browser_frame, browser_view); |
| 194 } | 191 } |
| 195 | 192 |
| 196 /////////////////////////////////////////////////////////////////////////////// | 193 /////////////////////////////////////////////////////////////////////////////// |
| 197 // BrowserFrameAura, private: | 194 // BrowserFrameAura, private: |
| 198 | 195 |
| 199 BrowserFrameAura::~BrowserFrameAura() { | 196 BrowserFrameAura::~BrowserFrameAura() { |
| 200 } | 197 } |
| OLD | NEW |