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

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"
pkotwicz 2013/10/29 16:45:14 Nit: You do not need the above include anymore
oshima 2013/10/29 17:45:54 Done.
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/window.h" 56 #include "ui/aura/window.h"
53 #endif 57 #endif
54 58
55 using apps::ShellWindow; 59 using apps::ShellWindow;
56 60
57 namespace { 61 namespace {
58 62
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 117
114 if (!base::PathExists(web_app_path) && 118 if (!base::PathExists(web_app_path) &&
115 !file_util::CreateDirectory(web_app_path)) { 119 !file_util::CreateDirectory(web_app_path)) {
116 return; 120 return;
117 } 121 }
118 ui::win::SetAppIconForWindow(icon_file.value(), hwnd); 122 ui::win::SetAppIconForWindow(icon_file.value(), hwnd);
119 web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon); 123 web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon);
120 } 124 }
121 #endif 125 #endif
122 126
127 #if defined(USE_ASH)
128 class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate {
James Cook 2013/10/29 16:13:04 nit: Class comment saying this is needed for fulls
oshima 2013/10/29 17:45:54 Done.
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 DCHECK(window_state->IsFullscreen() || window_state->CanMaximize());
139 // Windows which cannot be maximized should not be fullscreened.
pkotwicz 2013/10/29 16:45:14 Nit: Move comment above DCHECK?
oshima 2013/10/29 17:45:54 Done.
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 new NativeAppWindowStateDelegate(shell_window));
190 }
191 #endif
154 } 192 }
155 193
156 NativeAppWindowViews::~NativeAppWindowViews() { 194 NativeAppWindowViews::~NativeAppWindowViews() {
157 web_view_->SetWebContents(NULL); 195 web_view_->SetWebContents(NULL);
158 } 196 }
159 197
160 void NativeAppWindowViews::InitializeDefaultWindow( 198 void NativeAppWindowViews::InitializeDefaultWindow(
161 const ShellWindow::CreateParams& create_params) { 199 const ShellWindow::CreateParams& create_params) {
162 std::string app_name = 200 std::string app_name =
163 web_app::GenerateApplicationNameFromExtensionId(extension()->id()); 201 web_app::GenerateApplicationNameFromExtensionId(extension()->id());
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 return window_bounds.InsetsFrom(client_bounds); 869 return window_bounds.InsetsFrom(client_bounds);
832 } 870 }
833 871
834 bool NativeAppWindowViews::IsVisible() const { 872 bool NativeAppWindowViews::IsVisible() const {
835 return window_->IsVisible(); 873 return window_->IsVisible();
836 } 874 }
837 875
838 void NativeAppWindowViews::HideWithApp() {} 876 void NativeAppWindowViews::HideWithApp() {}
839 void NativeAppWindowViews::ShowWithApp() {} 877 void NativeAppWindowViews::ShowWithApp() {}
840 void NativeAppWindowViews::UpdateWindowMinMaxSize() {} 878 void NativeAppWindowViews::UpdateWindowMinMaxSize() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698