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/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 Loading... | |
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 // Invoked when the user uses Shift+F4 to toggle the window fullscreen state. | |
135 virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE { | |
136 bool is_fullscreen = window_state->IsFullscreen(); | |
137 | |
138 // Windows which cannot be maximized should not be fullscreened. | |
139 if (!is_fullscreen && !window_state->CanMaximize()) | |
140 return true; | |
141 // |window| may belong to a shell window. | |
142 apps::ShellWindow* shell_window = apps::ShellWindowRegistry:: | |
143 GetShellWindowForNativeWindowAnyProfile(window_state->window()); | |
144 DCHECK(shell_window); | |
145 if (!shell_window) | |
146 return true; | |
147 if (is_fullscreen) | |
148 shell_window->Restore(); | |
149 else | |
150 shell_window->Fullscreen(); | |
151 return true; | |
152 } | |
153 | |
154 private: | |
155 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); | |
156 }; | |
157 #endif // USE_ASH | |
158 | |
124 } // namespace | 159 } // namespace |
125 | 160 |
126 NativeAppWindowViews::NativeAppWindowViews( | 161 NativeAppWindowViews::NativeAppWindowViews( |
127 ShellWindow* shell_window, | 162 ShellWindow* shell_window, |
128 const ShellWindow::CreateParams& create_params) | 163 const ShellWindow::CreateParams& create_params) |
129 : shell_window_(shell_window), | 164 : shell_window_(shell_window), |
130 web_view_(NULL), | 165 web_view_(NULL), |
131 window_(NULL), | 166 window_(NULL), |
132 is_fullscreen_(false), | 167 is_fullscreen_(false), |
133 frameless_(create_params.frame == ShellWindow::FRAME_NONE), | 168 frameless_(create_params.frame == ShellWindow::FRAME_NONE), |
(...skipping 11 matching lines...) Expand all Loading... | |
145 } | 180 } |
146 extension_keybinding_registry_.reset( | 181 extension_keybinding_registry_.reset( |
147 new ExtensionKeybindingRegistryViews( | 182 new ExtensionKeybindingRegistryViews( |
148 profile(), | 183 profile(), |
149 window_->GetFocusManager(), | 184 window_->GetFocusManager(), |
150 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 185 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
151 shell_window_)); | 186 shell_window_)); |
152 | 187 |
153 OnViewWasResized(); | 188 OnViewWasResized(); |
154 window_->AddObserver(this); | 189 window_->AddObserver(this); |
190 #if defined(USE_ASH) | |
191 if (chrome::GetHostDesktopTypeForNativeView(GetNativeWindow()) == | |
192 chrome::HOST_DESKTOP_TYPE_ASH) { | |
193 ash::wm::GetWindowState(GetNativeWindow())->SetDelegate( | |
194 new NativeAppWindowStateDelegate()); | |
pkotwicz
2013/10/25 19:56:38
It MAY be worth passing in |shell_window_| to Nati
oshima
2013/10/25 22:36:20
I'm fine with either way. I'm just using what the
pkotwicz
2013/10/25 23:31:14
I think that it is worth investigating if passing
| |
195 } | |
196 #endif | |
155 } | 197 } |
156 | 198 |
157 NativeAppWindowViews::~NativeAppWindowViews() { | 199 NativeAppWindowViews::~NativeAppWindowViews() { |
158 web_view_->SetWebContents(NULL); | 200 web_view_->SetWebContents(NULL); |
159 } | 201 } |
160 | 202 |
161 void NativeAppWindowViews::InitializeDefaultWindow( | 203 void NativeAppWindowViews::InitializeDefaultWindow( |
162 const ShellWindow::CreateParams& create_params) { | 204 const ShellWindow::CreateParams& create_params) { |
163 std::string app_name = | 205 std::string app_name = |
164 web_app::GenerateApplicationNameFromExtensionId(extension()->id()); | 206 web_app::GenerateApplicationNameFromExtensionId(extension()->id()); |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
832 return window_bounds.InsetsFrom(client_bounds); | 874 return window_bounds.InsetsFrom(client_bounds); |
833 } | 875 } |
834 | 876 |
835 bool NativeAppWindowViews::IsVisible() const { | 877 bool NativeAppWindowViews::IsVisible() const { |
836 return window_->IsVisible(); | 878 return window_->IsVisible(); |
837 } | 879 } |
838 | 880 |
839 void NativeAppWindowViews::HideWithApp() {} | 881 void NativeAppWindowViews::HideWithApp() {} |
840 void NativeAppWindowViews::ShowWithApp() {} | 882 void NativeAppWindowViews::ShowWithApp() {} |
841 void NativeAppWindowViews::UpdateWindowMinMaxSize() {} | 883 void NativeAppWindowViews::UpdateWindowMinMaxSize() {} |
OLD | NEW |