| OLD | NEW |
| 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 Loading... |
| 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()) | |
| 500 return NULL; | |
| 501 | 499 |
| 502 // If the extension with |app_id| could't be found, most likely because it | 500 // If the extension with |app_id| could't be found, most likely because it |
| 503 // was uninstalled. | 501 // was uninstalled. |
| 504 const Extension* extension = | 502 const Extension* extension = |
| 505 extensions_service->GetExtensionById(app_id, false); | 503 extensions_service->GetExtensionById(app_id, false); |
| 506 if (!extension) | 504 if (!extension) |
| 507 return NULL; | 505 return NULL; |
| 508 | 506 |
| 509 return OpenApplication(profile, extension, extension->launch_container(), | 507 return OpenApplication(profile, extension, extension->launch_container(), |
| 510 existing_tab); | 508 existing_tab); |
| 511 } | 509 } |
| 512 | 510 |
| 513 // static | 511 // static |
| 514 TabContents* Browser::OpenApplication( | 512 TabContents* Browser::OpenApplication( |
| 515 Profile* profile, | 513 Profile* profile, |
| 516 const Extension* extension, | 514 const Extension* extension, |
| 517 extension_misc::LaunchContainer container, | 515 extension_misc::LaunchContainer container, |
| 518 TabContents* existing_tab) { | 516 TabContents* existing_tab) { |
| 519 TabContents* tab = NULL; | 517 TabContents* tab = NULL; |
| 520 | 518 |
| 521 UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100); | 519 UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100); |
| 522 | 520 |
| 523 // The app is not yet open. Load it. | |
| 524 switch (container) { | 521 switch (container) { |
| 525 case extension_misc::LAUNCH_WINDOW: | 522 case extension_misc::LAUNCH_WINDOW: |
| 523 tab = Browser::OpenApplicationWindow(profile, |
| 524 extension->GetFullLaunchURL()); |
| 525 break; |
| 526 case extension_misc::LAUNCH_PANEL: | 526 case extension_misc::LAUNCH_PANEL: |
| 527 tab = Browser::OpenApplicationWindow(profile, extension, container, | 527 tab = Browser::OpenApplicationWindow(profile, extension, container, |
| 528 GURL()); | 528 GURL()); |
| 529 break; | 529 break; |
| 530 case extension_misc::LAUNCH_TAB: { | 530 case extension_misc::LAUNCH_TAB: { |
| 531 tab = Browser::OpenApplicationTab(profile, extension, existing_tab); | 531 tab = Browser::OpenApplicationTab(profile, extension, existing_tab); |
| 532 break; | 532 break; |
| 533 } | 533 } |
| 534 default: | 534 default: |
| 535 NOTREACHED(); | 535 NOTREACHED(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 // OnDidGetApplicationInfo, which calls | 578 // OnDidGetApplicationInfo, which calls |
| 579 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as | 579 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as |
| 580 // pending web app action. | 580 // pending web app action. |
| 581 browser->pending_web_app_action_ = UPDATE_SHORTCUT; | 581 browser->pending_web_app_action_ = UPDATE_SHORTCUT; |
| 582 } | 582 } |
| 583 | 583 |
| 584 return contents; | 584 return contents; |
| 585 } | 585 } |
| 586 | 586 |
| 587 // static | 587 // static |
| 588 TabContents* Browser::OpenApplicationWindow(Profile* profile, GURL& url) { | 588 TabContents* Browser::OpenApplicationWindow(Profile* profile, const GURL& url) { |
| 589 return OpenApplicationWindow(profile, NULL, extension_misc::LAUNCH_WINDOW, | 589 return OpenApplicationWindow(profile, NULL, extension_misc::LAUNCH_WINDOW, |
| 590 url); | 590 url); |
| 591 } | 591 } |
| 592 | 592 |
| 593 // static | 593 // static |
| 594 TabContents* Browser::OpenApplicationTab(Profile* profile, | 594 TabContents* Browser::OpenApplicationTab(Profile* profile, |
| 595 const Extension* extension, | 595 const Extension* extension, |
| 596 TabContents* existing_tab) { | 596 TabContents* existing_tab) { |
| 597 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); | 597 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); |
| 598 TabContents* contents = NULL; | 598 TabContents* contents = NULL; |
| (...skipping 3478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4077 NOTREACHED(); | 4077 NOTREACHED(); |
| 4078 return false; | 4078 return false; |
| 4079 } | 4079 } |
| 4080 | 4080 |
| 4081 void Browser::CreateInstantIfNecessary() { | 4081 void Browser::CreateInstantIfNecessary() { |
| 4082 if (type() == TYPE_NORMAL && InstantController::IsEnabled(profile()) && | 4082 if (type() == TYPE_NORMAL && InstantController::IsEnabled(profile()) && |
| 4083 !profile()->IsOffTheRecord()) { | 4083 !profile()->IsOffTheRecord()) { |
| 4084 instant_.reset(new InstantController(profile_, this)); | 4084 instant_.reset(new InstantController(profile_, this)); |
| 4085 } | 4085 } |
| 4086 } | 4086 } |
| OLD | NEW |