Chromium Code Reviews| 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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 | 621 |
| 622 // This can fail if the app_id is invalid. It can also fail if the | 622 // This can fail if the app_id is invalid. It can also fail if the |
| 623 // extension is external, and has not yet been installed. | 623 // extension is external, and has not yet been installed. |
| 624 // TODO(skerner): Do something reasonable here. Pop up a warning panel? | 624 // TODO(skerner): Do something reasonable here. Pop up a warning panel? |
| 625 // Open an URL to the gallery page of the extension id? | 625 // Open an URL to the gallery page of the extension id? |
| 626 if (!app_id.empty()) { | 626 if (!app_id.empty()) { |
| 627 ExtensionsService* extensions_service = profile->GetExtensionsService(); | 627 ExtensionsService* extensions_service = profile->GetExtensionsService(); |
| 628 const Extension* extension = | 628 const Extension* extension = |
| 629 extensions_service->GetExtensionById(app_id, false); | 629 extensions_service->GetExtensionById(app_id, false); |
| 630 | 630 |
| 631 // The extension with |app_id| may have been uninstalled. | 631 // The extension with id |app_id| may have been uninstalled. |
| 632 if (!extension) | 632 if (!extension) |
| 633 return false; | 633 return false; |
| 634 | 634 |
| 635 // Look at prefs to find the container in which an app should launch. | 635 // Look at preferences to find the right launch container. If no |
| 636 // If no preference is set, launch in a window. | 636 // preference is set, launch as a window. |
| 637 extension_misc::LaunchContainer launch_container = | 637 extension_misc::LaunchContainer launch_container = |
| 638 extensions_service->extension_prefs()->GetLaunchContainer( | 638 extensions_service->extension_prefs()->GetLaunchContainer( |
| 639 extension, ExtensionPrefs::LAUNCH_WINDOW); | 639 extension, ExtensionPrefs::LAUNCH_WINDOW); |
| 640 | 640 |
| 641 TabContents* app_window = Browser::OpenApplication( | 641 TabContents* app_window = Browser::OpenApplication( |
| 642 profile, extension, launch_container, NULL); | 642 profile, extension, launch_container, NULL); |
| 643 return (app_window != NULL); | 643 return (app_window != NULL); |
| 644 } | 644 } |
| 645 | 645 |
| 646 if (url_string.empty()) | 646 if (url_string.empty()) |
| 647 return false; | 647 return false; |
| 648 | 648 |
| 649 #if defined(OS_WIN) // Fix up Windows shortcuts. | 649 #if defined(OS_WIN) // Fix up Windows shortcuts. |
| 650 ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%"); | 650 ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%"); |
| 651 #endif | 651 #endif |
| 652 GURL url(url_string); | 652 GURL url(url_string); |
| 653 | 653 |
| 654 // Restrict allowed URLs for --app switch. | 654 // Restrict allowed URLs for --app switch. |
| 655 if (!url.is_empty() && url.is_valid()) { | 655 if (!url.is_empty() && url.is_valid()) { |
| 656 ChildProcessSecurityPolicy *policy = | 656 ChildProcessSecurityPolicy *policy = |
| 657 ChildProcessSecurityPolicy::GetInstance(); | 657 ChildProcessSecurityPolicy::GetInstance(); |
| 658 if (policy->IsWebSafeScheme(url.scheme()) || | 658 if (policy->IsWebSafeScheme(url.scheme()) || |
| 659 url.SchemeIs(chrome::kFileScheme)) { | 659 url.SchemeIs(chrome::kFileScheme)) { |
| 660 Browser::OpenApplicationWindow(profile, url); | 660 TabContents* app_window = Browser::OpenUrlAppShortcutWindow( |
|
Aaron Boodman
2010/12/06 23:45:24
app_widow -> app_tab?
Sam Kerner (Chrome)
2010/12/07 04:12:30
Done.
| |
| 661 return true; | 661 profile, |
| 662 url, | |
| 663 true); // Update app info. | |
| 664 return (app_window != NULL); | |
| 662 } | 665 } |
| 663 } | 666 } |
| 664 return false; | 667 return false; |
| 665 } | 668 } |
| 666 | 669 |
| 667 void BrowserInit::LaunchWithProfile::ProcessLaunchURLs( | 670 void BrowserInit::LaunchWithProfile::ProcessLaunchURLs( |
| 668 bool process_startup, | 671 bool process_startup, |
| 669 const std::vector<GURL>& urls_to_open) { | 672 const std::vector<GURL>& urls_to_open) { |
| 670 // If we're starting up in "background mode" (no open browser window) then | 673 // If we're starting up in "background mode" (no open browser window) then |
| 671 // don't open any browser windows. | 674 // don't open any browser windows. |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1089 return false; | 1092 return false; |
| 1090 automation->SetExpectedTabCount(expected_tabs); | 1093 automation->SetExpectedTabCount(expected_tabs); |
| 1091 | 1094 |
| 1092 AutomationProviderList* list = | 1095 AutomationProviderList* list = |
| 1093 g_browser_process->InitAutomationProviderList(); | 1096 g_browser_process->InitAutomationProviderList(); |
| 1094 DCHECK(list); | 1097 DCHECK(list); |
| 1095 list->AddProvider(automation); | 1098 list->AddProvider(automation); |
| 1096 | 1099 |
| 1097 return true; | 1100 return true; |
| 1098 } | 1101 } |
| OLD | NEW |