Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: chrome/browser/extensions/api/app_window/app_window_api.cc

Issue 16702003: Move ShellWindow into apps component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: yar Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "apps/shell_window.h"
7 #include "base/command_line.h" 8 #include "base/command_line.h"
8 #include "base/time/time.h" 9 #include "base/time/time.h"
9 #include "base/values.h" 10 #include "base/values.h"
10 #include "chrome/browser/app_mode/app_mode_utils.h" 11 #include "chrome/browser/app_mode/app_mode_utils.h"
11 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/devtools/devtools_window.h" 13 #include "chrome/browser/devtools/devtools_window.h"
13 #include "chrome/browser/extensions/shell_window_registry.h" 14 #include "chrome/browser/extensions/shell_window_registry.h"
14 #include "chrome/browser/extensions/window_controller.h" 15 #include "chrome/browser/extensions/window_controller.h"
16 #include "chrome/browser/ui/apps/chrome_shell_window_delegate.h"
15 #include "chrome/browser/ui/extensions/native_app_window.h" 17 #include "chrome/browser/ui/extensions/native_app_window.h"
16 #include "chrome/browser/ui/extensions/shell_window.h"
17 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/extensions/api/app_window.h" 19 #include "chrome/common/extensions/api/app_window.h"
19 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
20 #include "content/public/browser/notification_types.h" 21 #include "content/public/browser/notification_types.h"
21 #include "content/public/browser/render_process_host.h" 22 #include "content/public/browser/render_process_host.h"
22 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_view_host.h"
23 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
24 #include "content/public/common/url_constants.h" 25 #include "content/public/common/url_constants.h"
25 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
26 #include "ui/base/ui_base_types.h" 27 #include "ui/base/ui_base_types.h"
27 #include "ui/gfx/rect.h" 28 #include "ui/gfx/rect.h"
28 29
29 #if defined(USE_ASH) 30 #if defined(USE_ASH)
30 #include "ash/shell.h" 31 #include "ash/shell.h"
31 #include "ash/wm/property_util.h" 32 #include "ash/wm/property_util.h"
32 #include "ui/aura/root_window.h" 33 #include "ui/aura/root_window.h"
33 #include "ui/aura/window.h" 34 #include "ui/aura/window.h"
34 #endif 35 #endif
35 36
37 using apps::ShellWindow;
38
36 namespace app_window = extensions::api::app_window; 39 namespace app_window = extensions::api::app_window;
37 namespace Create = app_window::Create; 40 namespace Create = app_window::Create;
38 41
39 namespace extensions { 42 namespace extensions {
40 43
41 namespace app_window_constants { 44 namespace app_window_constants {
42 const char kInvalidWindowId[] = 45 const char kInvalidWindowId[] =
43 "The window id can not be more than 256 characters long."; 46 "The window id can not be more than 256 characters long.";
44 } 47 }
45 48
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 gfx::Size size = ash::Shell::GetPrimaryRootWindow()->bounds().size(); 285 gfx::Size size = ash::Shell::GetPrimaryRootWindow()->bounds().size();
283 if (size.width() > create_params.maximum_size.width() || 286 if (size.width() > create_params.maximum_size.width() ||
284 size.height() > create_params.maximum_size.height()) 287 size.height() > create_params.maximum_size.height())
285 force_maximize = false; 288 force_maximize = false;
286 } 289 }
287 #endif 290 #endif
288 291
289 if (force_maximize) 292 if (force_maximize)
290 create_params.state = ui::SHOW_STATE_MAXIMIZED; 293 create_params.state = ui::SHOW_STATE_MAXIMIZED;
291 294
292 ShellWindow* shell_window = 295 ShellWindow* shell_window = ShellWindow::Create(
293 ShellWindow::Create(profile(), GetExtension(), url, create_params); 296 profile(),
297 new chrome::ChromeShellWindowDelegate(),
298 GetExtension(),
299 url,
300 create_params);
294 301
295 if (chrome::ShouldForceFullscreenApp()) 302 if (chrome::ShouldForceFullscreenApp())
296 shell_window->Fullscreen(); 303 shell_window->Fullscreen();
297 304
298 content::RenderViewHost* created_view = 305 content::RenderViewHost* created_view =
299 shell_window->web_contents()->GetRenderViewHost(); 306 shell_window->web_contents()->GetRenderViewHost();
300 int view_id = MSG_ROUTING_NONE; 307 int view_id = MSG_ROUTING_NONE;
301 if (create_params.creator_process_id == created_view->GetProcess()->GetID()) 308 if (create_params.creator_process_id == created_view->GetProcess()->GetID())
302 view_id = created_view->GetRoutingID(); 309 view_id = created_view->GetRoutingID();
303 310
304 base::DictionaryValue* result = new base::DictionaryValue; 311 base::DictionaryValue* result = new base::DictionaryValue;
305 result->Set("viewId", base::Value::CreateIntegerValue(view_id)); 312 result->Set("viewId", base::Value::CreateIntegerValue(view_id));
306 result->Set("injectTitlebar", 313 result->Set("injectTitlebar",
307 base::Value::CreateBooleanValue(inject_html_titlebar)); 314 base::Value::CreateBooleanValue(inject_html_titlebar));
308 result->Set("id", base::Value::CreateStringValue(shell_window->window_key())); 315 result->Set("id", base::Value::CreateStringValue(shell_window->window_key()));
309 SetCreateResultFromShellWindow(shell_window, result); 316 SetCreateResultFromShellWindow(shell_window, result);
310 SetResult(result); 317 SetResult(result);
311 318
312 if (ShellWindowRegistry::Get(profile())->HadDevToolsAttached(created_view)) { 319 if (ShellWindowRegistry::Get(profile())->HadDevToolsAttached(created_view)) {
313 new DevToolsRestorer(this, created_view); 320 new DevToolsRestorer(this, created_view);
314 return true; 321 return true;
315 } 322 }
316 323
317 SendResponse(true); 324 SendResponse(true);
318 return true; 325 return true;
319 } 326 }
320 327
321 } // namespace extensions 328 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698