| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/apps/chrome_native_app_window_views.h" | 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views.h" |
| 6 | 6 |
| 7 #include "apps/ui/views/app_window_frame_view.h" | 7 #include "apps/ui/views/app_window_frame_view.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/app_mode/app_mode_utils.h" | 10 #include "chrome/browser/app_mode/app_mode_utils.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 143 } |
| 144 virtual ~NativeAppWindowStateDelegate() { | 144 virtual ~NativeAppWindowStateDelegate() { |
| 145 if (window_state_) { | 145 if (window_state_) { |
| 146 window_state_->RemoveObserver(this); | 146 window_state_->RemoveObserver(this); |
| 147 window_state_->window()->RemoveObserver(this); | 147 window_state_->window()->RemoveObserver(this); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 // Overridden from ash::wm::WindowStateDelegate. | 152 // Overridden from ash::wm::WindowStateDelegate. |
| 153 virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE { | 153 virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) override { |
| 154 // Windows which cannot be maximized should not be fullscreened. | 154 // Windows which cannot be maximized should not be fullscreened. |
| 155 DCHECK(window_state->IsFullscreen() || window_state->CanMaximize()); | 155 DCHECK(window_state->IsFullscreen() || window_state->CanMaximize()); |
| 156 if (window_state->IsFullscreen()) | 156 if (window_state->IsFullscreen()) |
| 157 app_window_->Restore(); | 157 app_window_->Restore(); |
| 158 else if (window_state->CanMaximize()) | 158 else if (window_state->CanMaximize()) |
| 159 app_window_->OSFullscreen(); | 159 app_window_->OSFullscreen(); |
| 160 return true; | 160 return true; |
| 161 } | 161 } |
| 162 | 162 |
| 163 // Overridden from ash::wm::WindowStateObserver: | 163 // Overridden from ash::wm::WindowStateObserver: |
| 164 virtual void OnPostWindowStateTypeChange( | 164 virtual void OnPostWindowStateTypeChange( |
| 165 ash::wm::WindowState* window_state, | 165 ash::wm::WindowState* window_state, |
| 166 ash::wm::WindowStateType old_type) OVERRIDE { | 166 ash::wm::WindowStateType old_type) override { |
| 167 // Since the window state might get set by a window manager, it is possible | 167 // Since the window state might get set by a window manager, it is possible |
| 168 // to come here before the application set its |BaseWindow|. | 168 // to come here before the application set its |BaseWindow|. |
| 169 if (!window_state->IsFullscreen() && !window_state->IsMinimized() && | 169 if (!window_state->IsFullscreen() && !window_state->IsMinimized() && |
| 170 app_window_->GetBaseWindow() && | 170 app_window_->GetBaseWindow() && |
| 171 app_window_->GetBaseWindow()->IsFullscreenOrPending()) { | 171 app_window_->GetBaseWindow()->IsFullscreenOrPending()) { |
| 172 app_window_->Restore(); | 172 app_window_->Restore(); |
| 173 // Usually OnNativeWindowChanged() is called when the window bounds are | 173 // Usually OnNativeWindowChanged() is called when the window bounds are |
| 174 // changed as a result of a state type change. Because the change in state | 174 // changed as a result of a state type change. Because the change in state |
| 175 // type has already occurred, we need to call OnNativeWindowChanged() | 175 // type has already occurred, we need to call OnNativeWindowChanged() |
| 176 // explicitly. | 176 // explicitly. |
| 177 app_window_->OnNativeWindowChanged(); | 177 app_window_->OnNativeWindowChanged(); |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Overridden from aura::WindowObserver: | 181 // Overridden from aura::WindowObserver: |
| 182 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { | 182 virtual void OnWindowDestroying(aura::Window* window) override { |
| 183 window_state_->RemoveObserver(this); | 183 window_state_->RemoveObserver(this); |
| 184 window_state_->window()->RemoveObserver(this); | 184 window_state_->window()->RemoveObserver(this); |
| 185 window_state_ = NULL; | 185 window_state_ = NULL; |
| 186 } | 186 } |
| 187 | 187 |
| 188 // Not owned. | 188 // Not owned. |
| 189 AppWindow* app_window_; | 189 AppWindow* app_window_; |
| 190 ash::wm::WindowState* window_state_; | 190 ash::wm::WindowState* window_state_; |
| 191 | 191 |
| 192 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); | 192 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 InitializePanelWindow(create_params); | 695 InitializePanelWindow(create_params); |
| 696 } else { | 696 } else { |
| 697 InitializeDefaultWindow(create_params); | 697 InitializeDefaultWindow(create_params); |
| 698 } | 698 } |
| 699 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( | 699 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( |
| 700 Profile::FromBrowserContext(app_window->browser_context()), | 700 Profile::FromBrowserContext(app_window->browser_context()), |
| 701 widget()->GetFocusManager(), | 701 widget()->GetFocusManager(), |
| 702 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 702 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
| 703 NULL)); | 703 NULL)); |
| 704 } | 704 } |
| OLD | NEW |