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_init.h" | 5 #include "chrome/browser/ui/browser_init.h" |
6 | 6 |
7 #include <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 | 613 |
614 bool BrowserInit::LaunchWithProfile::OpenApplicationWindow(Profile* profile) { | 614 bool BrowserInit::LaunchWithProfile::OpenApplicationWindow(Profile* profile) { |
615 std::string url_string, app_id; | 615 std::string url_string, app_id; |
616 if (!IsAppLaunch(&url_string, &app_id)) | 616 if (!IsAppLaunch(&url_string, &app_id)) |
617 return false; | 617 return false; |
618 | 618 |
619 // This can fail if the app_id is invalid. It can also fail if the | 619 // This can fail if the app_id is invalid. It can also fail if the |
620 // extension is external, and has not yet been installed. | 620 // extension is external, and has not yet been installed. |
621 // TODO(skerner): Do something reasonable here. Pop up a warning panel? | 621 // TODO(skerner): Do something reasonable here. Pop up a warning panel? |
622 // Open an URL to the gallery page of the extension id? | 622 // Open an URL to the gallery page of the extension id? |
623 if (!app_id.empty()) | 623 if (!app_id.empty()) { |
624 return Browser::OpenApplication(profile, app_id, NULL) != NULL; | 624 ExtensionsService* extensions_service = profile->GetExtensionsService(); |
| 625 const Extension* extension = |
| 626 extensions_service->GetExtensionById(app_id, false); |
| 627 |
| 628 // The extension with |app_id| may have been uninstalled. |
| 629 if (!extension) |
| 630 return false; |
| 631 |
| 632 // Look at prefs to find the container in which an app should launch. |
| 633 // If no preference is set, launch in a window. |
| 634 extension_misc::LaunchContainer launch_container = |
| 635 extensions_service->extension_prefs()->GetLaunchContainer( |
| 636 extension, ExtensionPrefs::LAUNCH_WINDOW); |
| 637 |
| 638 TabContents* app_window = Browser::OpenApplication( |
| 639 profile, extension, launch_container, NULL); |
| 640 return (app_window != NULL); |
| 641 } |
625 | 642 |
626 if (url_string.empty()) | 643 if (url_string.empty()) |
627 return false; | 644 return false; |
628 | 645 |
629 #if defined(OS_WIN) // Fix up Windows shortcuts. | 646 #if defined(OS_WIN) // Fix up Windows shortcuts. |
630 ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%"); | 647 ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%"); |
631 #endif | 648 #endif |
632 GURL url(url_string); | 649 GURL url(url_string); |
633 | 650 |
634 // Restrict allowed URLs for --app switch. | 651 // Restrict allowed URLs for --app switch. |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 return false; | 1086 return false; |
1070 automation->SetExpectedTabCount(expected_tabs); | 1087 automation->SetExpectedTabCount(expected_tabs); |
1071 | 1088 |
1072 AutomationProviderList* list = | 1089 AutomationProviderList* list = |
1073 g_browser_process->InitAutomationProviderList(); | 1090 g_browser_process->InitAutomationProviderList(); |
1074 DCHECK(list); | 1091 DCHECK(list); |
1075 list->AddProvider(automation); | 1092 list->AddProvider(automation); |
1076 | 1093 |
1077 return true; | 1094 return true; |
1078 } | 1095 } |
OLD | NEW |