| 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 } | 492 } |
| 493 | 493 |
| 494 // static | 494 // static |
| 495 // TODO(erikkay): There are multiple reasons why this could fail. Should | 495 // TODO(erikkay): There are multiple reasons why this could fail. Should |
| 496 // this function return an error reason as well so that callers can show | 496 // this function return an error reason as well so that callers can show |
| 497 // reasonable errors? | 497 // reasonable errors? |
| 498 TabContents* Browser::OpenApplication(Profile* profile, | 498 TabContents* Browser::OpenApplication(Profile* profile, |
| 499 const std::string& app_id, | 499 const std::string& app_id, |
| 500 TabContents* existing_tab) { | 500 TabContents* existing_tab) { |
| 501 ExtensionsService* extensions_service = profile->GetExtensionsService(); | 501 ExtensionsService* extensions_service = profile->GetExtensionsService(); |
| 502 if (!extensions_service->is_ready()) | |
| 503 return NULL; | |
| 504 | 502 |
| 505 // If the extension with |app_id| could't be found, most likely because it | 503 // If the extension with |app_id| could't be found, most likely because it |
| 506 // was uninstalled. | 504 // was uninstalled. |
| 507 const Extension* extension = | 505 const Extension* extension = |
| 508 extensions_service->GetExtensionById(app_id, false); | 506 extensions_service->GetExtensionById(app_id, false); |
| 509 if (!extension) | 507 if (!extension) |
| 510 return NULL; | 508 return NULL; |
| 511 | 509 |
| 512 return OpenApplication(profile, extension, extension->launch_container(), | 510 return OpenApplication(profile, extension, extension->launch_container(), |
| 513 existing_tab); | 511 existing_tab); |
| 514 } | 512 } |
| 515 | 513 |
| 516 // static | 514 // static |
| 517 TabContents* Browser::OpenApplication( | 515 TabContents* Browser::OpenApplication( |
| 518 Profile* profile, | 516 Profile* profile, |
| 519 const Extension* extension, | 517 const Extension* extension, |
| 520 extension_misc::LaunchContainer container, | 518 extension_misc::LaunchContainer container, |
| 521 TabContents* existing_tab) { | 519 TabContents* existing_tab) { |
| 522 TabContents* tab = NULL; | 520 TabContents* tab = NULL; |
| 523 | 521 |
| 524 UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100); | 522 UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100); |
| 525 | 523 |
| 526 // The app is not yet open. Load it. | |
| 527 switch (container) { | 524 switch (container) { |
| 528 case extension_misc::LAUNCH_WINDOW: | 525 case extension_misc::LAUNCH_WINDOW: |
| 526 tab = Browser::OpenApplicationWindow(profile, |
| 527 extension->GetFullLaunchURL()); |
| 528 break; |
| 529 case extension_misc::LAUNCH_PANEL: | 529 case extension_misc::LAUNCH_PANEL: |
| 530 tab = Browser::OpenApplicationWindow(profile, extension, container, | 530 tab = Browser::OpenApplicationWindow(profile, extension, container, |
| 531 GURL()); | 531 GURL()); |
| 532 break; | 532 break; |
| 533 case extension_misc::LAUNCH_TAB: { | 533 case extension_misc::LAUNCH_TAB: { |
| 534 tab = Browser::OpenApplicationTab(profile, extension, existing_tab); | 534 tab = Browser::OpenApplicationTab(profile, extension, existing_tab); |
| 535 break; | 535 break; |
| 536 } | 536 } |
| 537 default: | 537 default: |
| 538 NOTREACHED(); | 538 NOTREACHED(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 // OnDidGetApplicationInfo, which calls | 582 // OnDidGetApplicationInfo, which calls |
| 583 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as | 583 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as |
| 584 // pending web app action. | 584 // pending web app action. |
| 585 browser->pending_web_app_action_ = UPDATE_SHORTCUT; | 585 browser->pending_web_app_action_ = UPDATE_SHORTCUT; |
| 586 } | 586 } |
| 587 | 587 |
| 588 return contents; | 588 return contents; |
| 589 } | 589 } |
| 590 | 590 |
| 591 // static | 591 // static |
| 592 TabContents* Browser::OpenApplicationWindow(Profile* profile, GURL& url) { | 592 TabContents* Browser::OpenApplicationWindow(Profile* profile, const GURL& url) { |
| 593 return OpenApplicationWindow(profile, NULL, extension_misc::LAUNCH_WINDOW, | 593 return OpenApplicationWindow(profile, NULL, extension_misc::LAUNCH_WINDOW, |
| 594 url); | 594 url); |
| 595 } | 595 } |
| 596 | 596 |
| 597 // static | 597 // static |
| 598 TabContents* Browser::OpenApplicationTab(Profile* profile, | 598 TabContents* Browser::OpenApplicationTab(Profile* profile, |
| 599 const Extension* extension, | 599 const Extension* extension, |
| 600 TabContents* existing_tab) { | 600 TabContents* existing_tab) { |
| 601 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); | 601 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); |
| 602 TabContents* contents = NULL; | 602 TabContents* contents = NULL; |
| (...skipping 3524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4127 NOTREACHED(); | 4127 NOTREACHED(); |
| 4128 return false; | 4128 return false; |
| 4129 } | 4129 } |
| 4130 | 4130 |
| 4131 void Browser::CreateInstantIfNecessary() { | 4131 void Browser::CreateInstantIfNecessary() { |
| 4132 if (type() == TYPE_NORMAL && InstantController::IsEnabled(profile()) && | 4132 if (type() == TYPE_NORMAL && InstantController::IsEnabled(profile()) && |
| 4133 !profile()->IsOffTheRecord()) { | 4133 !profile()->IsOffTheRecord()) { |
| 4134 instant_.reset(new InstantController(profile_, this)); | 4134 instant_.reset(new InstantController(profile_, this)); |
| 4135 } | 4135 } |
| 4136 } | 4136 } |
| OLD | NEW |