Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 { | |
| 129 public: | |
| 130 NativeAppWindowStateDelegate(ShellWindow* shell_window) | |
| 131 : shell_window_(shell_window) { | |
| 132 DCHECK(shell_window_); | |
| 133 } | |
| 134 virtual ~NativeAppWindowStateDelegate(){} | |
| 135 | |
| 136 virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE { | |
| 137 bool is_fullscreen = window_state->IsFullscreen(); | |
| 138 | |
| 139 DCHECK_EQ( | |
|
pkotwicz
2013/10/29 00:46:01
Nit: remove the DCHECK
oshima
2013/10/29 02:05:42
Done.
| |
| 140 apps::ShellWindowRegistry::GetShellWindowForNativeWindowAnyProfile( | |
| 141 window_state->window()), | |
| 142 shell_window_); | |
| 143 | |
| 144 // Windows which cannot be maximized should not be fullscreened. | |
| 145 if (is_fullscreen || window_state->CanMaximize()) { | |
|
pkotwicz
2013/10/29 00:46:01
I personally think that testing CanMaximize() here
oshima
2013/10/29 02:05:42
Done.
| |
| 146 if (is_fullscreen) | |
| 147 shell_window_->Restore(); | |
| 148 else | |
| 149 shell_window_->Fullscreen(); | |
| 150 } | |
| 151 return true; | |
| 152 } | |
| 153 | |
| 154 private: | |
| 155 ShellWindow* shell_window_; // not owned. | |
| 156 | |
| 157 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); | |
| 158 }; | |
| 159 #endif // USE_ASH | |
| 160 | |
| 123 } // namespace | 161 } // namespace |
| 124 | 162 |
| 125 NativeAppWindowViews::NativeAppWindowViews( | 163 NativeAppWindowViews::NativeAppWindowViews( |
| 126 ShellWindow* shell_window, | 164 ShellWindow* shell_window, |
| 127 const ShellWindow::CreateParams& create_params) | 165 const ShellWindow::CreateParams& create_params) |
| 128 : shell_window_(shell_window), | 166 : shell_window_(shell_window), |
| 129 web_view_(NULL), | 167 web_view_(NULL), |
| 130 window_(NULL), | 168 window_(NULL), |
| 131 is_fullscreen_(false), | 169 is_fullscreen_(false), |
| 132 frameless_(create_params.frame == ShellWindow::FRAME_NONE), | 170 frameless_(create_params.frame == ShellWindow::FRAME_NONE), |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 144 } | 182 } |
| 145 extension_keybinding_registry_.reset( | 183 extension_keybinding_registry_.reset( |
| 146 new ExtensionKeybindingRegistryViews( | 184 new ExtensionKeybindingRegistryViews( |
| 147 profile(), | 185 profile(), |
| 148 window_->GetFocusManager(), | 186 window_->GetFocusManager(), |
| 149 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 187 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
| 150 shell_window_)); | 188 shell_window_)); |
| 151 | 189 |
| 152 OnViewWasResized(); | 190 OnViewWasResized(); |
| 153 window_->AddObserver(this); | 191 window_->AddObserver(this); |
| 192 #if defined(USE_ASH) | |
| 193 if (chrome::GetHostDesktopTypeForNativeView(GetNativeWindow()) == | |
| 194 chrome::HOST_DESKTOP_TYPE_ASH) { | |
| 195 ash::wm::GetWindowState(GetNativeWindow())->SetDelegate( | |
| 196 new NativeAppWindowStateDelegate(shell_window)); | |
| 197 } | |
| 198 #endif | |
| 154 } | 199 } |
| 155 | 200 |
| 156 NativeAppWindowViews::~NativeAppWindowViews() { | 201 NativeAppWindowViews::~NativeAppWindowViews() { |
| 157 web_view_->SetWebContents(NULL); | 202 web_view_->SetWebContents(NULL); |
| 158 } | 203 } |
| 159 | 204 |
| 160 void NativeAppWindowViews::InitializeDefaultWindow( | 205 void NativeAppWindowViews::InitializeDefaultWindow( |
| 161 const ShellWindow::CreateParams& create_params) { | 206 const ShellWindow::CreateParams& create_params) { |
| 162 std::string app_name = | 207 std::string app_name = |
| 163 web_app::GenerateApplicationNameFromExtensionId(extension()->id()); | 208 web_app::GenerateApplicationNameFromExtensionId(extension()->id()); |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 831 return window_bounds.InsetsFrom(client_bounds); | 876 return window_bounds.InsetsFrom(client_bounds); |
| 832 } | 877 } |
| 833 | 878 |
| 834 bool NativeAppWindowViews::IsVisible() const { | 879 bool NativeAppWindowViews::IsVisible() const { |
| 835 return window_->IsVisible(); | 880 return window_->IsVisible(); |
| 836 } | 881 } |
| 837 | 882 |
| 838 void NativeAppWindowViews::HideWithApp() {} | 883 void NativeAppWindowViews::HideWithApp() {} |
| 839 void NativeAppWindowViews::ShowWithApp() {} | 884 void NativeAppWindowViews::ShowWithApp() {} |
| 840 void NativeAppWindowViews::UpdateWindowMinMaxSize() {} | 885 void NativeAppWindowViews::UpdateWindowMinMaxSize() {} |
| OLD | NEW |