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

Side by Side Diff: chrome/browser/ui/views/apps/native_app_window_views.cc

Issue 42353002: Introduce WindowStateDelegate::ToggleFullscreen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: exclude accelerator_commands_browsertest on win Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/native_app_window_views.h" 5 #include "chrome/browser/ui/views/apps/native_app_window_views.h"
6 6
7 #include "apps/shell_window.h"
7 #include "apps/ui/views/shell_window_frame_view.h" 8 #include "apps/ui/views/shell_window_frame_view.h"
8 #include "base/command_line.h" 9 #include "base/command_line.h"
9 #include "base/file_util.h" 10 #include "base/file_util.h"
10 #include "base/path_service.h" 11 #include "base/path_service.h"
11 #include "base/threading/sequenced_worker_pool.h" 12 #include "base/threading/sequenced_worker_pool.h"
12 #include "chrome/app/chrome_command_ids.h" 13 #include "chrome/app/chrome_command_ids.h"
13 #include "chrome/browser/extensions/extension_host.h" 14 #include "chrome/browser/extensions/extension_host.h"
14 #include "chrome/browser/favicon/favicon_tab_helper.h" 15 #include "chrome/browser/favicon/favicon_tab_helper.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/host_desktop.h"
16 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" 18 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h"
17 #include "chrome/browser/web_applications/web_app.h" 19 #include "chrome/browser/web_applications/web_app.h"
18 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/extensions/extension.h" 21 #include "chrome/common/extensions/extension.h"
20 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_view_host.h"
22 #include "content/public/browser/render_widget_host_view.h" 24 #include "content/public/browser/render_widget_host_view.h"
23 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
24 #include "content/public/browser/web_contents_view.h" 26 #include "content/public/browser/web_contents_view.h"
25 #include "extensions/common/draggable_region.h" 27 #include "extensions/common/draggable_region.h"
(...skipping 13 matching lines...) Expand all
39 #include "chrome/browser/shell_integration_linux.h" 41 #include "chrome/browser/shell_integration_linux.h"
40 #endif 42 #endif
41 43
42 #if defined(USE_ASH) 44 #if defined(USE_ASH)
43 #include "ash/ash_constants.h" 45 #include "ash/ash_constants.h"
44 #include "ash/screen_ash.h" 46 #include "ash/screen_ash.h"
45 #include "ash/shell.h" 47 #include "ash/shell.h"
46 #include "ash/wm/custom_frame_view_ash.h" 48 #include "ash/wm/custom_frame_view_ash.h"
47 #include "ash/wm/panels/panel_frame_view.h" 49 #include "ash/wm/panels/panel_frame_view.h"
48 #include "ash/wm/window_state.h" 50 #include "ash/wm/window_state.h"
51 #include "ash/wm/window_state_delegate.h"
49 #include "chrome/browser/ui/ash/ash_util.h" 52 #include "chrome/browser/ui/ash/ash_util.h"
50 #include "ui/aura/client/aura_constants.h" 53 #include "ui/aura/client/aura_constants.h"
51 #include "ui/aura/client/window_tree_client.h" 54 #include "ui/aura/client/window_tree_client.h"
52 #include "ui/aura/window.h" 55 #include "ui/aura/window.h"
53 #endif 56 #endif
54 57
55 using apps::ShellWindow; 58 using apps::ShellWindow;
56 59
57 namespace { 60 namespace {
58 61
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 116
114 if (!base::PathExists(web_app_path) && 117 if (!base::PathExists(web_app_path) &&
115 !file_util::CreateDirectory(web_app_path)) { 118 !file_util::CreateDirectory(web_app_path)) {
116 return; 119 return;
117 } 120 }
118 ui::win::SetAppIconForWindow(icon_file.value(), hwnd); 121 ui::win::SetAppIconForWindow(icon_file.value(), hwnd);
119 web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon); 122 web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon);
120 } 123 }
121 #endif 124 #endif
122 125
126 #if defined(USE_ASH)
127 // This class handles a user's fullscreen request (Shift+F4/F4).
128 class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate {
129 public:
130 explicit NativeAppWindowStateDelegate(ShellWindow* shell_window)
131 : shell_window_(shell_window) {
132 DCHECK(shell_window_);
133 }
134 virtual ~NativeAppWindowStateDelegate(){}
135
136 // Overridden from ash::wm::WindowStateDelegate.
137 virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE {
138 // Windows which cannot be maximized should not be fullscreened.
139 DCHECK(window_state->IsFullscreen() || window_state->CanMaximize());
140 if (window_state->IsFullscreen())
141 shell_window_->Restore();
142 else if (window_state->CanMaximize())
143 shell_window_->Fullscreen();
144 return true;
145 }
146
147 private:
148 ShellWindow* shell_window_; // not owned.
149
150 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate);
151 };
152 #endif // USE_ASH
153
123 } // namespace 154 } // namespace
124 155
125 NativeAppWindowViews::NativeAppWindowViews( 156 NativeAppWindowViews::NativeAppWindowViews(
126 ShellWindow* shell_window, 157 ShellWindow* shell_window,
127 const ShellWindow::CreateParams& create_params) 158 const ShellWindow::CreateParams& create_params)
128 : shell_window_(shell_window), 159 : shell_window_(shell_window),
129 web_view_(NULL), 160 web_view_(NULL),
130 window_(NULL), 161 window_(NULL),
131 is_fullscreen_(false), 162 is_fullscreen_(false),
132 frameless_(create_params.frame == ShellWindow::FRAME_NONE), 163 frameless_(create_params.frame == ShellWindow::FRAME_NONE),
(...skipping 11 matching lines...) Expand all
144 } 175 }
145 extension_keybinding_registry_.reset( 176 extension_keybinding_registry_.reset(
146 new ExtensionKeybindingRegistryViews( 177 new ExtensionKeybindingRegistryViews(
147 profile(), 178 profile(),
148 window_->GetFocusManager(), 179 window_->GetFocusManager(),
149 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, 180 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
150 shell_window_)); 181 shell_window_));
151 182
152 OnViewWasResized(); 183 OnViewWasResized();
153 window_->AddObserver(this); 184 window_->AddObserver(this);
185 #if defined(USE_ASH)
186 if (chrome::GetHostDesktopTypeForNativeView(GetNativeWindow()) ==
187 chrome::HOST_DESKTOP_TYPE_ASH) {
188 ash::wm::GetWindowState(GetNativeWindow())->SetDelegate(
189 scoped_ptr<ash::wm::WindowStateDelegate>(
190 new NativeAppWindowStateDelegate(shell_window)).Pass());
191 }
192 #endif
154 } 193 }
155 194
156 NativeAppWindowViews::~NativeAppWindowViews() { 195 NativeAppWindowViews::~NativeAppWindowViews() {
157 web_view_->SetWebContents(NULL); 196 web_view_->SetWebContents(NULL);
158 } 197 }
159 198
160 void NativeAppWindowViews::InitializeDefaultWindow( 199 void NativeAppWindowViews::InitializeDefaultWindow(
161 const ShellWindow::CreateParams& create_params) { 200 const ShellWindow::CreateParams& create_params) {
162 std::string app_name = 201 std::string app_name =
163 web_app::GenerateApplicationNameFromExtensionId(extension()->id()); 202 web_app::GenerateApplicationNameFromExtensionId(extension()->id());
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 return window_bounds.InsetsFrom(client_bounds); 870 return window_bounds.InsetsFrom(client_bounds);
832 } 871 }
833 872
834 bool NativeAppWindowViews::IsVisible() const { 873 bool NativeAppWindowViews::IsVisible() const {
835 return window_->IsVisible(); 874 return window_->IsVisible();
836 } 875 }
837 876
838 void NativeAppWindowViews::HideWithApp() {} 877 void NativeAppWindowViews::HideWithApp() {}
839 void NativeAppWindowViews::ShowWithApp() {} 878 void NativeAppWindowViews::ShowWithApp() {}
840 void NativeAppWindowViews::UpdateWindowMinMaxSize() {} 879 void NativeAppWindowViews::UpdateWindowMinMaxSize() {}
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/chrome_shell_delegate_browsertest.cc ('k') | chrome/browser/ui/views/frame/browser_frame_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698