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

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

Issue 13934007: Adding experimental maximize mode (behind a flag) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comment and tabbed reference Created 7 years, 7 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
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/extensions/extension_prefs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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
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
250 // Rather then maximizing the window after it was created, we maximize it
251 // immediately - that way the initial presentation is much smoother (no odd
252 // rectangles are shown temporarily in the added space). Note that suppressing
253 // animations does not help to remove the shown artifacts.
254 #if USE_ASH
255 if (force_maximize && !create_params.maximum_size.IsEmpty()) {
256 // Check that the application is able to fill the monitor - if not don't
257 // maximize.
258 // TODO(skuhne): In case of multi monitor usage we should find out in
259 // advance on which monitor the window will be displayed (or be happy with
260 // a temporary bad frame upon creation).
261 gfx::Size size = ash::Shell::GetPrimaryRootWindow()->bounds().size();
262 if (size.width() > create_params.maximum_size.width() ||
263 size.height() > create_params.maximum_size.height())
264 force_maximize = false;
265 }
266 #endif
267
268 if (force_maximize)
269 create_params.state = ShellWindow::CreateParams::STATE_MAXIMIZED;
270
236 ShellWindow* shell_window = 271 ShellWindow* shell_window =
237 ShellWindow::Create(profile(), GetExtension(), url, create_params); 272 ShellWindow::Create(profile(), GetExtension(), url, create_params);
238 273
239 if (chrome::ShouldForceFullscreenApp()) 274 if (chrome::ShouldForceFullscreenApp())
240 shell_window->Fullscreen(); 275 shell_window->Fullscreen();
241 276
242 content::RenderViewHost* created_view = 277 content::RenderViewHost* created_view =
243 shell_window->web_contents()->GetRenderViewHost(); 278 shell_window->web_contents()->GetRenderViewHost();
244 int view_id = MSG_ROUTING_NONE; 279 int view_id = MSG_ROUTING_NONE;
245 if (create_params.creator_process_id == created_view->GetProcess()->GetID()) 280 if (create_params.creator_process_id == created_view->GetProcess()->GetID())
(...skipping 16 matching lines...) Expand all
262 if (ShellWindowRegistry::Get(profile())->HadDevToolsAttached(created_view)) { 297 if (ShellWindowRegistry::Get(profile())->HadDevToolsAttached(created_view)) {
263 new DevToolsRestorer(this, created_view); 298 new DevToolsRestorer(this, created_view);
264 return true; 299 return true;
265 } 300 }
266 301
267 SendResponse(true); 302 SendResponse(true);
268 return true; 303 return true;
269 } 304 }
270 305
271 } // namespace extensions 306 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/extensions/extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698