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/shell.h" | |
29 #endif | |
30 | |
27 namespace app_window = extensions::api::app_window; | 31 namespace app_window = extensions::api::app_window; |
28 namespace Create = app_window::Create; | 32 namespace Create = app_window::Create; |
29 | 33 |
30 namespace extensions { | 34 namespace extensions { |
31 | 35 |
32 namespace app_window_constants { | 36 namespace app_window_constants { |
33 const char kInvalidWindowId[] = | 37 const char kInvalidWindowId[] = |
34 "The window id can not be more than 256 characters long."; | 38 "The window id can not be more than 256 characters long."; |
35 } | 39 } |
36 | 40 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 url = absolute; | 98 url = absolute; |
95 } | 99 } |
96 | 100 |
97 bool inject_html_titlebar = false; | 101 bool inject_html_titlebar = false; |
98 | 102 |
99 // TODO(jeremya): figure out a way to pass the opening WebContents through to | 103 // 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 | 104 // ShellWindow::Create so we can set the opener at create time rather than |
101 // with a hack in AppWindowCustomBindings::GetView(). | 105 // with a hack in AppWindowCustomBindings::GetView(). |
102 ShellWindow::CreateParams create_params; | 106 ShellWindow::CreateParams create_params; |
103 app_window::CreateWindowOptions* options = params->options.get(); | 107 app_window::CreateWindowOptions* options = params->options.get(); |
108 #if defined(USE_ASH) | |
109 bool force_maximize = ash::Shell::IsForcedMaximizeMode(); | |
James Cook
2013/04/23 18:27:33
I like this better - less strange ifdef-induced in
Mr4D (OOO till 08-26)
2013/04/23 22:24:00
Right - but it is adding code which is only needed
| |
110 #else | |
111 bool force_maximize = false; | |
112 #endif | |
104 if (options) { | 113 if (options) { |
105 if (options->id.get()) { | 114 if (options->id.get()) { |
106 // TODO(mek): use URL if no id specified? | 115 // TODO(mek): use URL if no id specified? |
107 // Limit length of id to 256 characters. | 116 // Limit length of id to 256 characters. |
108 if (options->id->length() > 256) { | 117 if (options->id->length() > 256) { |
109 error_ = app_window_constants::kInvalidWindowId; | 118 error_ = app_window_constants::kInvalidWindowId; |
110 return false; | 119 return false; |
111 } | 120 } |
112 | 121 |
113 create_params.window_key = *options->id; | 122 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: | 229 case extensions::api::app_window::STATE_FULLSCREEN: |
221 create_params.state = ShellWindow::CreateParams::STATE_FULLSCREEN; | 230 create_params.state = ShellWindow::CreateParams::STATE_FULLSCREEN; |
222 break; | 231 break; |
223 case extensions::api::app_window::STATE_MAXIMIZED: | 232 case extensions::api::app_window::STATE_MAXIMIZED: |
224 create_params.state = ShellWindow::CreateParams::STATE_MAXIMIZED; | 233 create_params.state = ShellWindow::CreateParams::STATE_MAXIMIZED; |
225 break; | 234 break; |
226 case extensions::api::app_window::STATE_MINIMIZED: | 235 case extensions::api::app_window::STATE_MINIMIZED: |
227 create_params.state = ShellWindow::CreateParams::STATE_MINIMIZED; | 236 create_params.state = ShellWindow::CreateParams::STATE_MINIMIZED; |
228 break; | 237 break; |
229 } | 238 } |
239 } else { | |
240 force_maximize = false; | |
230 } | 241 } |
231 } | 242 } |
232 | 243 |
244 if (force_maximize) | |
245 create_params.state = ShellWindow::CreateParams::STATE_MAXIMIZED; | |
246 | |
233 create_params.creator_process_id = | 247 create_params.creator_process_id = |
234 render_view_host_->GetProcess()->GetID(); | 248 render_view_host_->GetProcess()->GetID(); |
235 | 249 |
236 ShellWindow* shell_window = | 250 ShellWindow* shell_window = |
237 ShellWindow::Create(profile(), GetExtension(), url, create_params); | 251 ShellWindow::Create(profile(), GetExtension(), url, create_params); |
238 | 252 |
239 if (chrome::ShouldForceFullscreenApp()) | 253 if (chrome::ShouldForceFullscreenApp()) |
240 shell_window->Fullscreen(); | 254 shell_window->Fullscreen(); |
241 | 255 |
242 content::RenderViewHost* created_view = | 256 content::RenderViewHost* created_view = |
(...skipping 19 matching lines...) Expand all Loading... | |
262 if (ShellWindowRegistry::Get(profile())->HadDevToolsAttached(created_view)) { | 276 if (ShellWindowRegistry::Get(profile())->HadDevToolsAttached(created_view)) { |
263 new DevToolsRestorer(this, created_view); | 277 new DevToolsRestorer(this, created_view); |
264 return true; | 278 return true; |
265 } | 279 } |
266 | 280 |
267 SendResponse(true); | 281 SendResponse(true); |
268 return true; | 282 return true; |
269 } | 283 } |
270 | 284 |
271 } // namespace extensions | 285 } // namespace extensions |
OLD | NEW |