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

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: 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"
8 #include "apps/shell_window_registry.h"
7 #include "apps/ui/views/shell_window_frame_view.h" 9 #include "apps/ui/views/shell_window_frame_view.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "base/file_util.h" 11 #include "base/file_util.h"
10 #include "base/path_service.h" 12 #include "base/path_service.h"
11 #include "base/threading/sequenced_worker_pool.h" 13 #include "base/threading/sequenced_worker_pool.h"
12 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
13 #include "chrome/browser/extensions/extension_host.h" 15 #include "chrome/browser/extensions/extension_host.h"
14 #include "chrome/browser/favicon/favicon_tab_helper.h" 16 #include "chrome/browser/favicon/favicon_tab_helper.h"
15 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/host_desktop.h"
16 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" 19 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h"
17 #include "chrome/browser/web_applications/web_app.h" 20 #include "chrome/browser/web_applications/web_app.h"
18 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
20 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/render_view_host.h" 24 #include "content/public/browser/render_view_host.h"
22 #include "content/public/browser/render_widget_host_view.h" 25 #include "content/public/browser/render_widget_host_view.h"
23 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
24 #include "content/public/browser/web_contents_view.h" 27 #include "content/public/browser/web_contents_view.h"
25 #include "extensions/common/draggable_region.h" 28 #include "extensions/common/draggable_region.h"
(...skipping 13 matching lines...) Expand all
39 #include "chrome/browser/shell_integration_linux.h" 42 #include "chrome/browser/shell_integration_linux.h"
40 #endif 43 #endif
41 44
42 #if defined(USE_ASH) 45 #if defined(USE_ASH)
43 #include "ash/ash_constants.h" 46 #include "ash/ash_constants.h"
44 #include "ash/screen_ash.h" 47 #include "ash/screen_ash.h"
45 #include "ash/shell.h" 48 #include "ash/shell.h"
46 #include "ash/wm/custom_frame_view_ash.h" 49 #include "ash/wm/custom_frame_view_ash.h"
47 #include "ash/wm/panels/panel_frame_view.h" 50 #include "ash/wm/panels/panel_frame_view.h"
48 #include "ash/wm/window_state.h" 51 #include "ash/wm/window_state.h"
52 #include "ash/wm/window_state_delegate.h"
49 #include "chrome/browser/ui/ash/ash_util.h" 53 #include "chrome/browser/ui/ash/ash_util.h"
50 #include "ui/aura/client/aura_constants.h" 54 #include "ui/aura/client/aura_constants.h"
51 #include "ui/aura/client/window_tree_client.h" 55 #include "ui/aura/client/window_tree_client.h"
52 #include "ui/aura/root_window.h" 56 #include "ui/aura/root_window.h"
53 #include "ui/aura/window.h" 57 #include "ui/aura/window.h"
54 #endif 58 #endif
55 59
56 using apps::ShellWindow; 60 using apps::ShellWindow;
57 61
58 namespace { 62 namespace {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 118
115 if (!base::PathExists(web_app_path) && 119 if (!base::PathExists(web_app_path) &&
116 !file_util::CreateDirectory(web_app_path)) { 120 !file_util::CreateDirectory(web_app_path)) {
117 return; 121 return;
118 } 122 }
119 ui::win::SetAppIconForWindow(icon_file.value(), hwnd); 123 ui::win::SetAppIconForWindow(icon_file.value(), hwnd);
120 web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon); 124 web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon);
121 } 125 }
122 #endif 126 #endif
123 127
128 #if defined(USE_ASH)
129 class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate {
130 public:
131 NativeAppWindowStateDelegate() {}
132 virtual ~NativeAppWindowStateDelegate(){}
133
134 virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE {
135 bool is_fullscreen = window_state->IsFullscreen();
136
137 // Windows which cannot be maximized should not be fullscreened.
138 if (!is_fullscreen && !window_state->CanMaximize())
139 return true;
140 // |window| may belong to a shell window.
141 apps::ShellWindow* shell_window = apps::ShellWindowRegistry::
142 GetShellWindowForNativeWindowAnyProfile(window_state->window());
143 DCHECK(shell_window);
144 if (!shell_window)
145 return true;
146 if (is_fullscreen)
147 shell_window->Restore();
148 else
149 shell_window->Fullscreen();
150 return true;
151 }
152
153 private:
154 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate);
155 };
156 #endif // USE_ASH
157
124 } // namespace 158 } // namespace
125 159
126 NativeAppWindowViews::NativeAppWindowViews( 160 NativeAppWindowViews::NativeAppWindowViews(
127 ShellWindow* shell_window, 161 ShellWindow* shell_window,
128 const ShellWindow::CreateParams& create_params) 162 const ShellWindow::CreateParams& create_params)
129 : shell_window_(shell_window), 163 : shell_window_(shell_window),
130 web_view_(NULL), 164 web_view_(NULL),
131 window_(NULL), 165 window_(NULL),
132 is_fullscreen_(false), 166 is_fullscreen_(false),
133 frameless_(create_params.frame == ShellWindow::FRAME_NONE), 167 frameless_(create_params.frame == ShellWindow::FRAME_NONE),
(...skipping 11 matching lines...) Expand all
145 } 179 }
146 extension_keybinding_registry_.reset( 180 extension_keybinding_registry_.reset(
147 new ExtensionKeybindingRegistryViews( 181 new ExtensionKeybindingRegistryViews(
148 profile(), 182 profile(),
149 window_->GetFocusManager(), 183 window_->GetFocusManager(),
150 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, 184 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
151 shell_window_)); 185 shell_window_));
152 186
153 OnViewWasResized(); 187 OnViewWasResized();
154 window_->AddObserver(this); 188 window_->AddObserver(this);
189 #if defined(USE_ASH)
190 if (chrome::GetHostDesktopTypeForNativeView(GetNativeWindow()) ==
191 chrome::HOST_DESKTOP_TYPE_ASH) {
192 ash::wm::GetWindowState(GetNativeWindow())->SetDelegate(
193 new NativeAppWindowStateDelegate());
194 }
195 #endif
155 } 196 }
156 197
157 NativeAppWindowViews::~NativeAppWindowViews() { 198 NativeAppWindowViews::~NativeAppWindowViews() {
158 web_view_->SetWebContents(NULL); 199 web_view_->SetWebContents(NULL);
159 } 200 }
160 201
161 void NativeAppWindowViews::InitializeDefaultWindow( 202 void NativeAppWindowViews::InitializeDefaultWindow(
162 const ShellWindow::CreateParams& create_params) { 203 const ShellWindow::CreateParams& create_params) {
163 std::string app_name = 204 std::string app_name =
164 web_app::GenerateApplicationNameFromExtensionId(extension()->id()); 205 web_app::GenerateApplicationNameFromExtensionId(extension()->id());
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 return window_bounds.InsetsFrom(client_bounds); 873 return window_bounds.InsetsFrom(client_bounds);
833 } 874 }
834 875
835 bool NativeAppWindowViews::IsVisible() const { 876 bool NativeAppWindowViews::IsVisible() const {
836 return window_->IsVisible(); 877 return window_->IsVisible();
837 } 878 }
838 879
839 void NativeAppWindowViews::HideWithApp() {} 880 void NativeAppWindowViews::HideWithApp() {}
840 void NativeAppWindowViews::ShowWithApp() {} 881 void NativeAppWindowViews::ShowWithApp() {}
841 void NativeAppWindowViews::UpdateWindowMinMaxSize() {} 882 void NativeAppWindowViews::UpdateWindowMinMaxSize() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698