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

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator_impl.cc

Issue 12380047: Allow --app-list to be used in conjunction with --incognito for v1 apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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/ui/startup/startup_browser_creator_impl.h ('k') | no next file » | 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/ui/startup/startup_browser_creator_impl.h" 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "apps/app_restore_service.h" 10 #include "apps/app_restore_service.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 extension_misc::LaunchContainer* out_launch_container) { 186 extension_misc::LaunchContainer* out_launch_container) {
187 187
188 ExtensionService* extensions_service = profile->GetExtensionService(); 188 ExtensionService* extensions_service = profile->GetExtensionService();
189 const Extension* extension = 189 const Extension* extension =
190 extensions_service->GetExtensionById(app_id, false); 190 extensions_service->GetExtensionById(app_id, false);
191 191
192 // The extension with id |app_id| may have been uninstalled. 192 // The extension with id |app_id| may have been uninstalled.
193 if (!extension) 193 if (!extension)
194 return false; 194 return false;
195 195
196 // Don't launch platform apps in incognito mode.
197 if (profile->IsOffTheRecord() && extension->is_platform_app())
198 return false;
199
196 // Look at preferences to find the right launch container. If no 200 // Look at preferences to find the right launch container. If no
197 // preference is set, launch as a window. 201 // preference is set, launch as a window.
198 extension_misc::LaunchContainer launch_container = 202 extension_misc::LaunchContainer launch_container =
199 extensions_service->extension_prefs()->GetLaunchContainer( 203 extensions_service->extension_prefs()->GetLaunchContainer(
200 extension, extensions::ExtensionPrefs::LAUNCH_WINDOW); 204 extension, extensions::ExtensionPrefs::LAUNCH_WINDOW);
201 205
202 *out_extension = extension; 206 *out_extension = extension;
203 *out_launch_container = launch_container; 207 *out_launch_container = launch_container;
204 return true; 208 return true;
205 } 209 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 height = std::min(height, work_area.height()); 393 height = std::min(height, work_area.height());
390 bounds->set_size(gfx::Size(width, height)); 394 bounds->set_size(gfx::Size(width, height));
391 bounds->set_x((work_area.width() - bounds->width()) / 2); 395 bounds->set_x((work_area.width() - bounds->width()) / 2);
392 // TODO(nkostylev): work_area does include launcher but should not. 396 // TODO(nkostylev): work_area does include launcher but should not.
393 // Launcher auto hide pref is synced and is most likely not applied here. 397 // Launcher auto hide pref is synced and is most likely not applied here.
394 bounds->set_y((work_area.height() - bounds->height()) / 2); 398 bounds->set_y((work_area.height() - bounds->height()) / 2);
395 } 399 }
396 } 400 }
397 } 401 }
398 402
399 bool StartupBrowserCreatorImpl::IsAppLaunch(Profile* profile, 403 bool StartupBrowserCreatorImpl::IsAppLaunch(std::string* app_url,
400 std::string* app_url,
401 std::string* app_id) { 404 std::string* app_id) {
402 // Don't launch apps in incognito mode.
403 if (profile->IsOffTheRecord())
404 return false;
405 if (command_line_.HasSwitch(switches::kApp)) { 405 if (command_line_.HasSwitch(switches::kApp)) {
406 if (app_url) 406 if (app_url)
407 *app_url = command_line_.GetSwitchValueASCII(switches::kApp); 407 *app_url = command_line_.GetSwitchValueASCII(switches::kApp);
408 return true; 408 return true;
409 } 409 }
410 if (command_line_.HasSwitch(switches::kAppId)) { 410 if (command_line_.HasSwitch(switches::kAppId)) {
411 if (app_id) 411 if (app_id)
412 *app_id = command_line_.GetSwitchValueASCII(switches::kAppId); 412 *app_id = command_line_.GetSwitchValueASCII(switches::kAppId);
413 return true; 413 return true;
414 } 414 }
415 return false; 415 return false;
416 } 416 }
417 417
418 bool StartupBrowserCreatorImpl::OpenApplicationTab(Profile* profile) { 418 bool StartupBrowserCreatorImpl::OpenApplicationTab(Profile* profile) {
419 std::string app_id; 419 std::string app_id;
420 // App shortcuts to URLs always open in an app window. Because this 420 // App shortcuts to URLs always open in an app window. Because this
421 // function will open an app that should be in a tab, there is no need 421 // function will open an app that should be in a tab, there is no need
422 // to look at the app URL. OpenApplicationWindow() will open app url 422 // to look at the app URL. OpenApplicationWindow() will open app url
423 // shortcuts. 423 // shortcuts.
424 if (!IsAppLaunch(profile, NULL, &app_id) || app_id.empty()) 424 if (!IsAppLaunch(NULL, &app_id) || app_id.empty())
425 return false; 425 return false;
426 426
427 extension_misc::LaunchContainer launch_container; 427 extension_misc::LaunchContainer launch_container;
428 const Extension* extension; 428 const Extension* extension;
429 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) 429 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container))
430 return false; 430 return false;
431 431
432 // If the user doesn't want to open a tab, fail. 432 // If the user doesn't want to open a tab, fail.
433 if (launch_container != extension_misc::LAUNCH_TAB) 433 if (launch_container != extension_misc::LAUNCH_TAB)
434 return false; 434 return false;
435 435
436 RecordCmdLineAppHistogram(); 436 RecordCmdLineAppHistogram();
437 437
438 WebContents* app_tab = chrome::OpenApplication(chrome::AppLaunchParams( 438 WebContents* app_tab = chrome::OpenApplication(chrome::AppLaunchParams(
439 profile, extension, extension_misc::LAUNCH_TAB, NEW_FOREGROUND_TAB)); 439 profile, extension, extension_misc::LAUNCH_TAB, NEW_FOREGROUND_TAB));
440 return (app_tab != NULL); 440 return (app_tab != NULL);
441 } 441 }
442 442
443 bool StartupBrowserCreatorImpl::OpenApplicationWindow( 443 bool StartupBrowserCreatorImpl::OpenApplicationWindow(
444 Profile* profile, 444 Profile* profile,
445 content::WebContents** out_app_contents) { 445 content::WebContents** out_app_contents) {
446 // Set |out_app_contents| to NULL early on (just in case). 446 // Set |out_app_contents| to NULL early on (just in case).
447 if (out_app_contents) 447 if (out_app_contents)
448 *out_app_contents = NULL; 448 *out_app_contents = NULL;
449 449
450 std::string url_string, app_id; 450 std::string url_string, app_id;
451 if (!IsAppLaunch(profile, &url_string, &app_id)) 451 if (!IsAppLaunch(&url_string, &app_id))
452 return false; 452 return false;
453 453
454 // This can fail if the app_id is invalid. It can also fail if the 454 // This can fail if the app_id is invalid. It can also fail if the
455 // extension is external, and has not yet been installed. 455 // extension is external, and has not yet been installed.
456 // TODO(skerner): Do something reasonable here. Pop up a warning panel? 456 // TODO(skerner): Do something reasonable here. Pop up a warning panel?
457 // Open an URL to the gallery page of the extension id? 457 // Open an URL to the gallery page of the extension id?
458 if (!app_id.empty()) { 458 if (!app_id.empty()) {
459 extension_misc::LaunchContainer launch_container; 459 extension_misc::LaunchContainer launch_container;
460 const Extension* extension; 460 const Extension* extension;
461 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) 461 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container))
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 } 938 }
939 939
940 #if !defined(OS_WIN) || defined(USE_AURA) 940 #if !defined(OS_WIN) || defined(USE_AURA)
941 // static 941 // static
942 bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser( 942 bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser(
943 Profile* profile, 943 Profile* profile,
944 const std::vector<GURL>& startup_urls) { 944 const std::vector<GURL>& startup_urls) {
945 return false; 945 return false;
946 } 946 }
947 #endif 947 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/startup_browser_creator_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698