OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/api/app_window/app_window_api.h" | 5 #include "chrome/browser/extensions/api/app_window/app_window_api.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/app_mode/app_mode_utils.h" | 10 #include "chrome/browser/app_mode/app_mode_utils.h" |
11 #include "chrome/browser/devtools/devtools_window.h" | 11 #include "chrome/browser/devtools/devtools_window.h" |
12 #include "chrome/browser/extensions/shell_window_registry.h" | 12 #include "chrome/browser/extensions/shell_window_registry.h" |
13 #include "chrome/browser/extensions/window_controller.h" | 13 #include "chrome/browser/extensions/window_controller.h" |
14 #include "chrome/browser/ui/extensions/native_app_window.h" | 14 #include "chrome/browser/ui/extensions/native_app_window.h" |
15 #include "chrome/browser/ui/extensions/shell_window.h" | 15 #include "chrome/browser/ui/extensions/shell_window.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/extensions/api/app_window.h" | 17 #include "chrome/common/extensions/api/app_window.h" |
18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
19 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
20 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
21 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
24 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
25 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
26 | 26 |
| 27 #if defined(USE_ASH) |
| 28 #include "ash/wm/property_util.h" |
| 29 #include "ui/aura/root_window.h" |
| 30 #include "ui/aura/window.h" |
| 31 #endif |
| 32 |
27 namespace app_window = extensions::api::app_window; | 33 namespace app_window = extensions::api::app_window; |
28 namespace Create = app_window::Create; | 34 namespace Create = app_window::Create; |
29 | 35 |
30 namespace extensions { | 36 namespace extensions { |
31 | 37 |
32 namespace app_window_constants { | 38 namespace app_window_constants { |
33 const char kInvalidWindowId[] = | 39 const char kInvalidWindowId[] = |
34 "The window id can not be more than 256 characters long."; | 40 "The window id can not be more than 256 characters long."; |
35 } | 41 } |
36 | 42 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 url = absolute; | 100 url = absolute; |
95 } | 101 } |
96 | 102 |
97 bool inject_html_titlebar = false; | 103 bool inject_html_titlebar = false; |
98 | 104 |
99 // TODO(jeremya): figure out a way to pass the opening WebContents through to | 105 // TODO(jeremya): figure out a way to pass the opening WebContents through to |
100 // ShellWindow::Create so we can set the opener at create time rather than | 106 // ShellWindow::Create so we can set the opener at create time rather than |
101 // with a hack in AppWindowCustomBindings::GetView(). | 107 // with a hack in AppWindowCustomBindings::GetView(). |
102 ShellWindow::CreateParams create_params; | 108 ShellWindow::CreateParams create_params; |
103 app_window::CreateWindowOptions* options = params->options.get(); | 109 app_window::CreateWindowOptions* options = params->options.get(); |
| 110 bool force_maximize = true; |
104 if (options) { | 111 if (options) { |
105 if (options->id.get()) { | 112 if (options->id.get()) { |
106 // TODO(mek): use URL if no id specified? | 113 // TODO(mek): use URL if no id specified? |
107 // Limit length of id to 256 characters. | 114 // Limit length of id to 256 characters. |
108 if (options->id->length() > 256) { | 115 if (options->id->length() > 256) { |
109 error_ = app_window_constants::kInvalidWindowId; | 116 error_ = app_window_constants::kInvalidWindowId; |
110 return false; | 117 return false; |
111 } | 118 } |
112 | 119 |
113 create_params.window_key = *options->id; | 120 create_params.window_key = *options->id; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 case extensions::api::app_window::STATE_FULLSCREEN: | 227 case extensions::api::app_window::STATE_FULLSCREEN: |
221 create_params.state = ShellWindow::CreateParams::STATE_FULLSCREEN; | 228 create_params.state = ShellWindow::CreateParams::STATE_FULLSCREEN; |
222 break; | 229 break; |
223 case extensions::api::app_window::STATE_MAXIMIZED: | 230 case extensions::api::app_window::STATE_MAXIMIZED: |
224 create_params.state = ShellWindow::CreateParams::STATE_MAXIMIZED; | 231 create_params.state = ShellWindow::CreateParams::STATE_MAXIMIZED; |
225 break; | 232 break; |
226 case extensions::api::app_window::STATE_MINIMIZED: | 233 case extensions::api::app_window::STATE_MINIMIZED: |
227 create_params.state = ShellWindow::CreateParams::STATE_MINIMIZED; | 234 create_params.state = ShellWindow::CreateParams::STATE_MINIMIZED; |
228 break; | 235 break; |
229 } | 236 } |
| 237 } else { |
| 238 force_maximize = false; |
230 } | 239 } |
231 } | 240 } |
232 | 241 |
233 create_params.creator_process_id = | 242 create_params.creator_process_id = |
234 render_view_host_->GetProcess()->GetID(); | 243 render_view_host_->GetProcess()->GetID(); |
235 | 244 |
236 ShellWindow* shell_window = | 245 ShellWindow* shell_window = |
237 ShellWindow::Create(profile(), GetExtension(), url, create_params); | 246 ShellWindow::Create(profile(), GetExtension(), url, create_params); |
238 | 247 |
| 248 #if USE_ASH |
| 249 if (force_maximize && !create_params.maximum_size.IsEmpty()) { |
| 250 // Test if the application can be resized to the full extent of the given |
| 251 // screen. |
| 252 gfx::Size size = |
| 253 shell_window->GetNativeWindow()->GetRootWindow()->bounds().size(); |
| 254 if (size.width() > create_params.maximum_size.width() || |
| 255 size.height() > create_params.maximum_size.height()) |
| 256 force_maximize = false; |
| 257 } |
| 258 if (force_maximize) |
| 259 ash::SetCanBeMaximizedByWorkspace(shell_window->GetNativeWindow(), true); |
| 260 #endif |
| 261 |
239 if (chrome::ShouldForceFullscreenApp()) | 262 if (chrome::ShouldForceFullscreenApp()) |
240 shell_window->Fullscreen(); | 263 shell_window->Fullscreen(); |
241 | 264 |
242 content::RenderViewHost* created_view = | 265 content::RenderViewHost* created_view = |
243 shell_window->web_contents()->GetRenderViewHost(); | 266 shell_window->web_contents()->GetRenderViewHost(); |
244 int view_id = MSG_ROUTING_NONE; | 267 int view_id = MSG_ROUTING_NONE; |
245 if (create_params.creator_process_id == created_view->GetProcess()->GetID()) | 268 if (create_params.creator_process_id == created_view->GetProcess()->GetID()) |
246 view_id = created_view->GetRoutingID(); | 269 view_id = created_view->GetRoutingID(); |
247 | 270 |
248 base::DictionaryValue* result = new base::DictionaryValue; | 271 base::DictionaryValue* result = new base::DictionaryValue; |
(...skipping 13 matching lines...) Expand all Loading... |
262 if (ShellWindowRegistry::Get(profile())->HadDevToolsAttached(created_view)) { | 285 if (ShellWindowRegistry::Get(profile())->HadDevToolsAttached(created_view)) { |
263 new DevToolsRestorer(this, created_view); | 286 new DevToolsRestorer(this, created_view); |
264 return true; | 287 return true; |
265 } | 288 } |
266 | 289 |
267 SendResponse(true); | 290 SendResponse(true); |
268 return true; | 291 return true; |
269 } | 292 } |
270 | 293 |
271 } // namespace extensions | 294 } // namespace extensions |
OLD | NEW |