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

Side by Side Diff: chrome/browser/ui/extensions/application_launch.cc

Issue 10949023: Add switch to provide app window size on startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove hack Created 8 years, 3 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/ui/extensions/application_launch.h" 5 #include "chrome/browser/ui/extensions/application_launch.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "chrome/browser/extensions/default_apps_trial.h" 10 #include "chrome/browser/extensions/default_apps_trial.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" 22 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/browser/web_applications/web_app.h" 23 #include "chrome/browser/web_applications/web_app.h"
24 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/extensions/extension.h" 25 #include "chrome/common/extensions/extension.h"
26 #include "chrome/common/extensions/extension_constants.h" 26 #include "chrome/common/extensions/extension_constants.h"
27 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
28 #include "content/public/browser/render_view_host.h" 28 #include "content/public/browser/render_view_host.h"
29 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
30 #include "content/public/browser/web_contents_view.h" 30 #include "content/public/browser/web_contents_view.h"
31 #include "content/public/common/renderer_preferences.h" 31 #include "content/public/common/renderer_preferences.h"
32 #include "ui/gfx/rect.h"
32 33
33 using content::WebContents; 34 using content::WebContents;
34 using extensions::Extension; 35 using extensions::Extension;
35 using extensions::ExtensionPrefs; 36 using extensions::ExtensionPrefs;
36 37
37 namespace { 38 namespace {
38 39
39 // Get the launch URL for a given extension, with optional override/fallback. 40 // Get the launch URL for a given extension, with optional override/fallback.
40 // |override_url|, if non-empty, will be preferred over the extension's 41 // |override_url|, if non-empty, will be preferred over the extension's
41 // launch url. 42 // launch url.
(...skipping 19 matching lines...) Expand all
61 } 62 }
62 63
63 return url; 64 return url;
64 } 65 }
65 66
66 WebContents* OpenApplicationWindow( 67 WebContents* OpenApplicationWindow(
67 Profile* profile, 68 Profile* profile,
68 const Extension* extension, 69 const Extension* extension,
69 extension_misc::LaunchContainer container, 70 extension_misc::LaunchContainer container,
70 const GURL& url_input, 71 const GURL& url_input,
71 Browser** app_browser) { 72 Browser** app_browser,
73 const gfx::Rect& override_bounds) {
72 DCHECK(!url_input.is_empty() || extension); 74 DCHECK(!url_input.is_empty() || extension);
73 GURL url = UrlForExtension(extension, url_input); 75 GURL url = UrlForExtension(extension, url_input);
74 76
75 std::string app_name; 77 std::string app_name;
76 app_name = extension ? 78 app_name = extension ?
77 web_app::GenerateApplicationNameFromExtensionId(extension->id()) : 79 web_app::GenerateApplicationNameFromExtensionId(extension->id()) :
78 web_app::GenerateApplicationNameFromURL(url); 80 web_app::GenerateApplicationNameFromURL(url);
79 81
80 Browser::Type type = Browser::TYPE_POPUP; 82 Browser::Type type = Browser::TYPE_POPUP;
81 83
82 gfx::Rect window_bounds; 84 gfx::Rect window_bounds;
83 if (extension) { 85 if (extension) {
84 window_bounds.set_width(extension->launch_width()); 86 window_bounds.set_width(extension->launch_width());
85 window_bounds.set_height(extension->launch_height()); 87 window_bounds.set_height(extension->launch_height());
88 } else if (!override_bounds.IsEmpty()) {
89 window_bounds = override_bounds;
86 } 90 }
87 91
88 Browser::CreateParams params(type, profile); 92 Browser::CreateParams params(type, profile);
89 params.app_name = app_name; 93 params.app_name = app_name;
90 params.initial_bounds = window_bounds; 94 params.initial_bounds = window_bounds;
91 95
92 #if defined(USE_ASH) 96 #if defined(USE_ASH)
93 if (extension && 97 if (extension &&
94 container == extension_misc::LAUNCH_WINDOW) { 98 container == extension_misc::LAUNCH_WINDOW) {
95 // In ash, LAUNCH_FULLSCREEN launches in a maximized app window and 99 // In ash, LAUNCH_FULLSCREEN launches in a maximized app window and
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 252 }
249 253
250 switch (container) { 254 switch (container) {
251 case extension_misc::LAUNCH_NONE: { 255 case extension_misc::LAUNCH_NONE: {
252 NOTREACHED(); 256 NOTREACHED();
253 break; 257 break;
254 } 258 }
255 case extension_misc::LAUNCH_PANEL: 259 case extension_misc::LAUNCH_PANEL:
256 case extension_misc::LAUNCH_WINDOW: 260 case extension_misc::LAUNCH_WINDOW:
257 tab = OpenApplicationWindow(profile, extension, container, 261 tab = OpenApplicationWindow(profile, extension, container,
258 override_url, NULL); 262 override_url, NULL, gfx::Rect());
259 break; 263 break;
260 case extension_misc::LAUNCH_TAB: { 264 case extension_misc::LAUNCH_TAB: {
261 tab = OpenApplicationTab(profile, extension, override_url, 265 tab = OpenApplicationTab(profile, extension, override_url,
262 params.disposition); 266 params.disposition);
263 break; 267 break;
264 } 268 }
265 default: 269 default:
266 NOTREACHED(); 270 NOTREACHED();
267 break; 271 break;
268 } 272 }
269 return tab; 273 return tab;
270 } 274 }
271 275
272 WebContents* OpenAppShortcutWindow(Profile* profile, 276 WebContents* OpenAppShortcutWindow(Profile* profile,
273 const GURL& url) { 277 const GURL& url,
278 const gfx::Rect& override_bounds) {
274 Browser* app_browser; 279 Browser* app_browser;
275 WebContents* tab = OpenApplicationWindow( 280 WebContents* tab = OpenApplicationWindow(
276 profile, 281 profile,
277 NULL, // this is a URL app. No extension. 282 NULL, // this is a URL app. No extension.
278 extension_misc::LAUNCH_WINDOW, 283 extension_misc::LAUNCH_WINDOW,
279 url, 284 url,
280 &app_browser); 285 &app_browser,
286 override_bounds);
281 287
282 if (!tab) 288 if (!tab)
283 return NULL; 289 return NULL;
284 290
285 // Set UPDATE_SHORTCUT as the pending web app action. This action is picked 291 // Set UPDATE_SHORTCUT as the pending web app action. This action is picked
286 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when 292 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when
287 // the web app info is available, extensions::TabHelper notifies Browser via 293 // the web app info is available, extensions::TabHelper notifies Browser via
288 // OnDidGetApplicationInfo, which calls 294 // OnDidGetApplicationInfo, which calls
289 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as 295 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as
290 // pending web app action. 296 // pending web app action.
291 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( 297 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action(
292 extensions::TabHelper::UPDATE_SHORTCUT); 298 extensions::TabHelper::UPDATE_SHORTCUT);
293 299
294 return tab; 300 return tab;
295 } 301 }
296 302
297 } // namespace application_launch 303 } // namespace application_launch
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/application_launch.h ('k') | chrome/browser/ui/startup/startup_browser_creator_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698