| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 window_state_( | 134 window_state_( |
| 135 ash::wm::GetWindowState(native_app_window->GetNativeWindow())) { | 135 ash::wm::GetWindowState(native_app_window->GetNativeWindow())) { |
| 136 // Add a window state observer to exit fullscreen properly in case | 136 // Add a window state observer to exit fullscreen properly in case |
| 137 // fullscreen is exited without going through AppWindow::Restore(). This | 137 // fullscreen is exited without going through AppWindow::Restore(). This |
| 138 // is the case when exiting immersive fullscreen via the "Restore" window | 138 // is the case when exiting immersive fullscreen via the "Restore" window |
| 139 // control. | 139 // control. |
| 140 // TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048 | 140 // TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048 |
| 141 window_state_->AddObserver(this); | 141 window_state_->AddObserver(this); |
| 142 window_state_->window()->AddObserver(this); | 142 window_state_->window()->AddObserver(this); |
| 143 } | 143 } |
| 144 virtual ~NativeAppWindowStateDelegate() { | 144 ~NativeAppWindowStateDelegate() override { |
| 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 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 void OnPostWindowStateTypeChange(ash::wm::WindowState* window_state, |
| 165 ash::wm::WindowState* window_state, | 165 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 | 166 // Since the window state might get set by a window manager, it is possible |
| 168 // to come here before the application set its |BaseWindow|. | 167 // to come here before the application set its |BaseWindow|. |
| 169 if (!window_state->IsFullscreen() && !window_state->IsMinimized() && | 168 if (!window_state->IsFullscreen() && !window_state->IsMinimized() && |
| 170 app_window_->GetBaseWindow() && | 169 app_window_->GetBaseWindow() && |
| 171 app_window_->GetBaseWindow()->IsFullscreenOrPending()) { | 170 app_window_->GetBaseWindow()->IsFullscreenOrPending()) { |
| 172 app_window_->Restore(); | 171 app_window_->Restore(); |
| 173 // Usually OnNativeWindowChanged() is called when the window bounds are | 172 // Usually OnNativeWindowChanged() is called when the window bounds are |
| 174 // changed as a result of a state type change. Because the change in state | 173 // changed as a result of a state type change. Because the change in state |
| 175 // type has already occurred, we need to call OnNativeWindowChanged() | 174 // type has already occurred, we need to call OnNativeWindowChanged() |
| 176 // explicitly. | 175 // explicitly. |
| 177 app_window_->OnNativeWindowChanged(); | 176 app_window_->OnNativeWindowChanged(); |
| 178 } | 177 } |
| 179 } | 178 } |
| 180 | 179 |
| 181 // Overridden from aura::WindowObserver: | 180 // Overridden from aura::WindowObserver: |
| 182 virtual void OnWindowDestroying(aura::Window* window) override { | 181 void OnWindowDestroying(aura::Window* window) override { |
| 183 window_state_->RemoveObserver(this); | 182 window_state_->RemoveObserver(this); |
| 184 window_state_->window()->RemoveObserver(this); | 183 window_state_->window()->RemoveObserver(this); |
| 185 window_state_ = NULL; | 184 window_state_ = NULL; |
| 186 } | 185 } |
| 187 | 186 |
| 188 // Not owned. | 187 // Not owned. |
| 189 AppWindow* app_window_; | 188 AppWindow* app_window_; |
| 190 ash::wm::WindowState* window_state_; | 189 ash::wm::WindowState* window_state_; |
| 191 | 190 |
| 192 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); | 191 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 InitializePanelWindow(create_params); | 698 InitializePanelWindow(create_params); |
| 700 } else { | 699 } else { |
| 701 InitializeDefaultWindow(create_params); | 700 InitializeDefaultWindow(create_params); |
| 702 } | 701 } |
| 703 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( | 702 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( |
| 704 Profile::FromBrowserContext(app_window->browser_context()), | 703 Profile::FromBrowserContext(app_window->browser_context()), |
| 705 widget()->GetFocusManager(), | 704 widget()->GetFocusManager(), |
| 706 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 705 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
| 707 NULL)); | 706 NULL)); |
| 708 } | 707 } |
| OLD | NEW |