| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 const Extension* extension; | 805 const Extension* extension; |
| 806 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) | 806 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) |
| 807 return false; | 807 return false; |
| 808 | 808 |
| 809 // If the user doesn't want to open a tab, fail. | 809 // If the user doesn't want to open a tab, fail. |
| 810 if (launch_container != extension_misc::LAUNCH_TAB) | 810 if (launch_container != extension_misc::LAUNCH_TAB) |
| 811 return false; | 811 return false; |
| 812 | 812 |
| 813 RecordCmdLineAppHistogram(); | 813 RecordCmdLineAppHistogram(); |
| 814 | 814 |
| 815 TabContents* app_tab = Browser::OpenApplicationTab(profile, extension, | 815 TabContents* app_tab = Browser::OpenApplicationTab(profile, extension, GURL(), |
| 816 NEW_FOREGROUND_TAB); | 816 NEW_FOREGROUND_TAB); |
| 817 return (app_tab != NULL); | 817 return (app_tab != NULL); |
| 818 } | 818 } |
| 819 | 819 |
| 820 bool BrowserInit::LaunchWithProfile::OpenApplicationWindow(Profile* profile) { | 820 bool BrowserInit::LaunchWithProfile::OpenApplicationWindow(Profile* profile) { |
| 821 std::string url_string, app_id; | 821 std::string url_string, app_id; |
| 822 if (!IsAppLaunch(&url_string, &app_id)) | 822 if (!IsAppLaunch(&url_string, &app_id)) |
| 823 return false; | 823 return false; |
| 824 | 824 |
| 825 // This can fail if the app_id is invalid. It can also fail if the | 825 // This can fail if the app_id is invalid. It can also fail if the |
| 826 // extension is external, and has not yet been installed. | 826 // extension is external, and has not yet been installed. |
| 827 // TODO(skerner): Do something reasonable here. Pop up a warning panel? | 827 // TODO(skerner): Do something reasonable here. Pop up a warning panel? |
| 828 // Open an URL to the gallery page of the extension id? | 828 // Open an URL to the gallery page of the extension id? |
| 829 if (!app_id.empty()) { | 829 if (!app_id.empty()) { |
| 830 extension_misc::LaunchContainer launch_container; | 830 extension_misc::LaunchContainer launch_container; |
| 831 const Extension* extension; | 831 const Extension* extension; |
| 832 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) | 832 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) |
| 833 return false; | 833 return false; |
| 834 | 834 |
| 835 // TODO(skerner): Could pass in |extension| and |launch_container|, | 835 // TODO(skerner): Could pass in |extension| and |launch_container|, |
| 836 // and avoid calling GetAppLaunchContainer() both here and in | 836 // and avoid calling GetAppLaunchContainer() both here and in |
| 837 // OpenApplicationTab(). | 837 // OpenApplicationTab(). |
| 838 | 838 |
| 839 if (launch_container == extension_misc::LAUNCH_TAB) | 839 if (launch_container == extension_misc::LAUNCH_TAB) |
| 840 return false; | 840 return false; |
| 841 | 841 |
| 842 RecordCmdLineAppHistogram(); | 842 RecordCmdLineAppHistogram(); |
| 843 TabContents* tab_in_app_window = Browser::OpenApplication( | 843 TabContents* tab_in_app_window = Browser::OpenApplication( |
| 844 profile, extension, launch_container, NEW_WINDOW); | 844 profile, extension, launch_container, GURL(), NEW_WINDOW); |
| 845 return (tab_in_app_window != NULL); | 845 return (tab_in_app_window != NULL); |
| 846 } | 846 } |
| 847 | 847 |
| 848 if (url_string.empty()) | 848 if (url_string.empty()) |
| 849 return false; | 849 return false; |
| 850 | 850 |
| 851 #if defined(OS_WIN) // Fix up Windows shortcuts. | 851 #if defined(OS_WIN) // Fix up Windows shortcuts. |
| 852 ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%"); | 852 ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%"); |
| 853 #endif | 853 #endif |
| 854 GURL url(url_string); | 854 GURL url(url_string); |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 if (!automation->InitializeChannel(channel_id)) | 1548 if (!automation->InitializeChannel(channel_id)) |
| 1549 return false; | 1549 return false; |
| 1550 automation->SetExpectedTabCount(expected_tabs); | 1550 automation->SetExpectedTabCount(expected_tabs); |
| 1551 | 1551 |
| 1552 AutomationProviderList* list = g_browser_process->GetAutomationProviderList(); | 1552 AutomationProviderList* list = g_browser_process->GetAutomationProviderList(); |
| 1553 DCHECK(list); | 1553 DCHECK(list); |
| 1554 list->AddProvider(automation); | 1554 list->AddProvider(automation); |
| 1555 | 1555 |
| 1556 return true; | 1556 return true; |
| 1557 } | 1557 } |
| OLD | NEW |