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

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

Issue 5019005: Add "open as window" menu item to NTP app menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test. Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #include <windows.h> 9 #include <windows.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 489 }
490 490
491 // static 491 // static
492 // TODO(erikkay): There are multiple reasons why this could fail. Should 492 // TODO(erikkay): There are multiple reasons why this could fail. Should
493 // this function return an error reason as well so that callers can show 493 // this function return an error reason as well so that callers can show
494 // reasonable errors? 494 // reasonable errors?
495 TabContents* Browser::OpenApplication(Profile* profile, 495 TabContents* Browser::OpenApplication(Profile* profile,
496 const std::string& app_id, 496 const std::string& app_id,
497 TabContents* existing_tab) { 497 TabContents* existing_tab) {
498 ExtensionsService* extensions_service = profile->GetExtensionsService(); 498 ExtensionsService* extensions_service = profile->GetExtensionsService();
499 if (!extensions_service->is_ready()) 499 if (!extensions_service->is_ready()) {
Aaron Boodman 2010/11/17 06:12:47 Again here, I think we can take this code out now.
Sam Kerner (Chrome) 2010/11/18 03:53:36 Done.
500 // The extensions service should load extensions as part of
501 // profile construction. The fact that we have a profile should
502 // imply that the extensions service is ready.
503 NOTREACHED();
500 return NULL; 504 return NULL;
505 }
501 506
502 // If the extension with |app_id| could't be found, most likely because it 507 // If the extension with |app_id| could't be found, most likely because it
503 // was uninstalled. 508 // was uninstalled.
504 const Extension* extension = 509 const Extension* extension =
505 extensions_service->GetExtensionById(app_id, false); 510 extensions_service->GetExtensionById(app_id, false);
506 if (!extension) 511 if (!extension)
507 return NULL; 512 return NULL;
508 513
509 return OpenApplication(profile, extension, extension->launch_container(), 514 return OpenApplication(profile, extension, extension->launch_container(),
510 existing_tab); 515 existing_tab);
511 } 516 }
512 517
513 // static 518 // static
514 TabContents* Browser::OpenApplication( 519 TabContents* Browser::OpenApplication(
515 Profile* profile, 520 Profile* profile,
516 const Extension* extension, 521 const Extension* extension,
517 extension_misc::LaunchContainer container, 522 extension_misc::LaunchContainer container,
518 TabContents* existing_tab) { 523 TabContents* existing_tab) {
519 TabContents* tab = NULL; 524 TabContents* tab = NULL;
520 525
521 UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100); 526 UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100);
522 527
523 // The app is not yet open. Load it.
524 switch (container) { 528 switch (container) {
525 case extension_misc::LAUNCH_WINDOW: 529 case extension_misc::LAUNCH_WINDOW:
530 tab = Browser::OpenApplicationWindow(profile,
531 extension->GetFullLaunchURL());
532 break;
526 case extension_misc::LAUNCH_PANEL: 533 case extension_misc::LAUNCH_PANEL:
527 tab = Browser::OpenApplicationWindow(profile, extension, container, 534 tab = Browser::OpenApplicationWindow(profile, extension, container,
528 GURL()); 535 GURL());
529 break; 536 break;
530 case extension_misc::LAUNCH_TAB: { 537 case extension_misc::LAUNCH_TAB: {
531 tab = Browser::OpenApplicationTab(profile, extension, existing_tab); 538 tab = Browser::OpenApplicationTab(profile, extension, existing_tab);
532 break; 539 break;
533 } 540 }
534 default: 541 default:
535 NOTREACHED(); 542 NOTREACHED();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 // OnDidGetApplicationInfo, which calls 585 // OnDidGetApplicationInfo, which calls
579 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as 586 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as
580 // pending web app action. 587 // pending web app action.
581 browser->pending_web_app_action_ = UPDATE_SHORTCUT; 588 browser->pending_web_app_action_ = UPDATE_SHORTCUT;
582 } 589 }
583 590
584 return contents; 591 return contents;
585 } 592 }
586 593
587 // static 594 // static
588 TabContents* Browser::OpenApplicationWindow(Profile* profile, GURL& url) { 595 TabContents* Browser::OpenApplicationWindow(Profile* profile, const GURL& url) {
589 return OpenApplicationWindow(profile, NULL, extension_misc::LAUNCH_WINDOW, 596 return OpenApplicationWindow(profile, NULL, extension_misc::LAUNCH_WINDOW,
590 url); 597 url);
591 } 598 }
592 599
593 // static 600 // static
594 TabContents* Browser::OpenApplicationTab(Profile* profile, 601 TabContents* Browser::OpenApplicationTab(Profile* profile,
595 const Extension* extension, 602 const Extension* extension,
596 TabContents* existing_tab) { 603 TabContents* existing_tab) {
597 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); 604 Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
598 TabContents* contents = NULL; 605 TabContents* contents = NULL;
(...skipping 3494 matching lines...) Expand 10 before | Expand all | Expand 10 after
4093 NOTREACHED(); 4100 NOTREACHED();
4094 return false; 4101 return false;
4095 } 4102 }
4096 4103
4097 void Browser::CreateInstantIfNecessary() { 4104 void Browser::CreateInstantIfNecessary() {
4098 if (type() == TYPE_NORMAL && InstantController::IsEnabled(profile()) && 4105 if (type() == TYPE_NORMAL && InstantController::IsEnabled(profile()) &&
4099 !profile()->IsOffTheRecord()) { 4106 !profile()->IsOffTheRecord()) {
4100 instant_.reset(new InstantController(profile_, this)); 4107 instant_.reset(new InstantController(profile_, this));
4101 } 4108 }
4102 } 4109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698