Chromium Code Reviews| 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 #include "ash/wm/property_util.h" | |
| 30 #include "ui/aura/root_window.h" | |
| 31 #include "ui/aura/window.h" | |
| 32 #endif | |
| 33 | |
| 27 namespace app_window = extensions::api::app_window; | 34 namespace app_window = extensions::api::app_window; |
| 28 namespace Create = app_window::Create; | 35 namespace Create = app_window::Create; |
| 29 | 36 |
| 30 namespace extensions { | 37 namespace extensions { |
| 31 | 38 |
| 32 namespace app_window_constants { | 39 namespace app_window_constants { |
| 33 const char kInvalidWindowId[] = | 40 const char kInvalidWindowId[] = |
| 34 "The window id can not be more than 256 characters long."; | 41 "The window id can not be more than 256 characters long."; |
| 35 } | 42 } |
| 36 | 43 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 url = absolute; | 101 url = absolute; |
| 95 } | 102 } |
| 96 | 103 |
| 97 bool inject_html_titlebar = false; | 104 bool inject_html_titlebar = false; |
| 98 | 105 |
| 99 // TODO(jeremya): figure out a way to pass the opening WebContents through to | 106 // 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 | 107 // ShellWindow::Create so we can set the opener at create time rather than |
| 101 // with a hack in AppWindowCustomBindings::GetView(). | 108 // with a hack in AppWindowCustomBindings::GetView(). |
| 102 ShellWindow::CreateParams create_params; | 109 ShellWindow::CreateParams create_params; |
| 103 app_window::CreateWindowOptions* options = params->options.get(); | 110 app_window::CreateWindowOptions* options = params->options.get(); |
| 111 #if defined(USE_ASH) | |
| 112 bool force_maximize = ash::Shell::IsForcedMaximizeMode(); | |
| 113 #else | |
| 114 bool force_maximize = false; | |
| 115 #endif | |
| 104 if (options) { | 116 if (options) { |
| 105 if (options->id.get()) { | 117 if (options->id.get()) { |
| 106 // TODO(mek): use URL if no id specified? | 118 // TODO(mek): use URL if no id specified? |
| 107 // Limit length of id to 256 characters. | 119 // Limit length of id to 256 characters. |
| 108 if (options->id->length() > 256) { | 120 if (options->id->length() > 256) { |
| 109 error_ = app_window_constants::kInvalidWindowId; | 121 error_ = app_window_constants::kInvalidWindowId; |
| 110 return false; | 122 return false; |
| 111 } | 123 } |
| 112 | 124 |
| 113 create_params.window_key = *options->id; | 125 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: | 232 case extensions::api::app_window::STATE_FULLSCREEN: |
| 221 create_params.state = ShellWindow::CreateParams::STATE_FULLSCREEN; | 233 create_params.state = ShellWindow::CreateParams::STATE_FULLSCREEN; |
| 222 break; | 234 break; |
| 223 case extensions::api::app_window::STATE_MAXIMIZED: | 235 case extensions::api::app_window::STATE_MAXIMIZED: |
| 224 create_params.state = ShellWindow::CreateParams::STATE_MAXIMIZED; | 236 create_params.state = ShellWindow::CreateParams::STATE_MAXIMIZED; |
| 225 break; | 237 break; |
| 226 case extensions::api::app_window::STATE_MINIMIZED: | 238 case extensions::api::app_window::STATE_MINIMIZED: |
| 227 create_params.state = ShellWindow::CreateParams::STATE_MINIMIZED; | 239 create_params.state = ShellWindow::CreateParams::STATE_MINIMIZED; |
| 228 break; | 240 break; |
| 229 } | 241 } |
| 242 } else { | |
| 243 force_maximize = false; | |
| 230 } | 244 } |
| 231 } | 245 } |
| 232 | 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 |
| 253 #if USE_ASH | |
| 254 if (force_maximize && !create_params.maximum_size.IsEmpty()) { | |
| 255 // Test if the application can be resized to the full extent of the given | |
| 256 // screen. | |
| 257 gfx::Size size = | |
| 258 shell_window->GetNativeWindow()->GetRootWindow()->bounds().size(); | |
| 259 if (size.width() > create_params.maximum_size.width() || | |
| 260 size.height() > create_params.maximum_size.height()) | |
| 261 force_maximize = false; | |
| 262 } | |
| 263 #endif | |
| 264 if (force_maximize) | |
|
sky
2013/05/01 04:32:04
And I don't think you wanted this either.
Mr4D (OOO till 08-26)
2013/05/01 17:57:23
Done.
| |
| 265 ash::SetPersistsAcrossAllWorkspaces(shell_window->GetNativeWindow(), | |
| 266 ash::WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_NO); | |
| 267 | |
| 239 if (chrome::ShouldForceFullscreenApp()) | 268 if (chrome::ShouldForceFullscreenApp()) |
| 240 shell_window->Fullscreen(); | 269 shell_window->Fullscreen(); |
| 241 | 270 |
| 242 content::RenderViewHost* created_view = | 271 content::RenderViewHost* created_view = |
| 243 shell_window->web_contents()->GetRenderViewHost(); | 272 shell_window->web_contents()->GetRenderViewHost(); |
| 244 int view_id = MSG_ROUTING_NONE; | 273 int view_id = MSG_ROUTING_NONE; |
| 245 if (create_params.creator_process_id == created_view->GetProcess()->GetID()) | 274 if (create_params.creator_process_id == created_view->GetProcess()->GetID()) |
| 246 view_id = created_view->GetRoutingID(); | 275 view_id = created_view->GetRoutingID(); |
| 247 | 276 |
| 248 base::DictionaryValue* result = new base::DictionaryValue; | 277 base::DictionaryValue* result = new base::DictionaryValue; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 262 if (ShellWindowRegistry::Get(profile())->HadDevToolsAttached(created_view)) { | 291 if (ShellWindowRegistry::Get(profile())->HadDevToolsAttached(created_view)) { |
| 263 new DevToolsRestorer(this, created_view); | 292 new DevToolsRestorer(this, created_view); |
| 264 return true; | 293 return true; |
| 265 } | 294 } |
| 266 | 295 |
| 267 SendResponse(true); | 296 SendResponse(true); |
| 268 return true; | 297 return true; |
| 269 } | 298 } |
| 270 | 299 |
| 271 } // namespace extensions | 300 } // namespace extensions |
| OLD | NEW |