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