Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: chrome/browser/ui/browser_init.cc

Issue 4202004: Add named testing interface (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser_init.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 if (command_line.HasSwitch(switches::kNoStartupWindow)) { 966 if (command_line.HasSwitch(switches::kNoStartupWindow)) {
967 expected_tab_count = 0; 967 expected_tab_count = 0;
968 } else if (command_line.HasSwitch(switches::kRestoreLastSession)) { 968 } else if (command_line.HasSwitch(switches::kRestoreLastSession)) {
969 std::string restore_session_value( 969 std::string restore_session_value(
970 command_line.GetSwitchValueASCII(switches::kRestoreLastSession)); 970 command_line.GetSwitchValueASCII(switches::kRestoreLastSession));
971 base::StringToInt(restore_session_value, &expected_tab_count); 971 base::StringToInt(restore_session_value, &expected_tab_count);
972 } else { 972 } else {
973 expected_tab_count = 973 expected_tab_count =
974 std::max(1, static_cast<int>(command_line.args().size())); 974 std::max(1, static_cast<int>(command_line.args().size()));
975 } 975 }
976 CreateAutomationProvider<TestingAutomationProvider>( 976 if (!CreateAutomationProvider<TestingAutomationProvider>(
977 testing_channel_id, 977 testing_channel_id,
978 profile, 978 profile,
979 static_cast<size_t>(expected_tab_count)); 979 static_cast<size_t>(expected_tab_count)))
980 return false;
980 } 981 }
981 } 982 }
982 983
983 bool silent_launch = false; 984 bool silent_launch = false;
984 985
985 if (command_line.HasSwitch(switches::kAutomationClientChannelID)) { 986 if (command_line.HasSwitch(switches::kAutomationClientChannelID)) {
986 std::string automation_channel_id = command_line.GetSwitchValueASCII( 987 std::string automation_channel_id = command_line.GetSwitchValueASCII(
987 switches::kAutomationClientChannelID); 988 switches::kAutomationClientChannelID);
988 // If there are any extra parameters, we expect each one to generate a 989 // If there are any extra parameters, we expect each one to generate a
989 // new tab; if there are none then we have no tabs 990 // new tab; if there are none then we have no tabs
990 size_t expected_tabs = 991 size_t expected_tabs =
991 std::max(static_cast<int>(command_line.args().size()), 0); 992 std::max(static_cast<int>(command_line.args().size()), 0);
992 if (expected_tabs == 0) 993 if (expected_tabs == 0)
993 silent_launch = true; 994 silent_launch = true;
994 995
995 if (command_line.HasSwitch(switches::kChromeFrame)) { 996 if (command_line.HasSwitch(switches::kChromeFrame)) {
996 CreateAutomationProvider<ChromeFrameAutomationProvider>( 997 if (!CreateAutomationProvider<ChromeFrameAutomationProvider>(
997 automation_channel_id, profile, expected_tabs); 998 automation_channel_id, profile, expected_tabs))
999 return false;
998 } else { 1000 } else {
999 CreateAutomationProvider<AutomationProvider>(automation_channel_id, 1001 if (!CreateAutomationProvider<AutomationProvider>(
1000 profile, expected_tabs); 1002 automation_channel_id, profile, expected_tabs))
1003 return false;
1001 } 1004 }
1002 } 1005 }
1003 1006
1004 // If we have been invoked to display a desktop notification on behalf of 1007 // If we have been invoked to display a desktop notification on behalf of
1005 // the service process, we do not want to open any browser windows. 1008 // the service process, we do not want to open any browser windows.
1006 if (command_line.HasSwitch(switches::kNotifyCloudPrintTokenExpired)) { 1009 if (command_line.HasSwitch(switches::kNotifyCloudPrintTokenExpired)) {
1007 silent_launch = true; 1010 silent_launch = true;
1008 profile->GetCloudPrintProxyService()->ShowTokenExpiredNotification(); 1011 profile->GetCloudPrintProxyService()->ShowTokenExpiredNotification();
1009 } 1012 }
1010 1013
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 // If we don't want to launch a new browser window or tab (in the case 1052 // If we don't want to launch a new browser window or tab (in the case
1050 // of an automation request), we are done here. 1053 // of an automation request), we are done here.
1051 if (!silent_launch) { 1054 if (!silent_launch) {
1052 return browser_init->LaunchBrowser( 1055 return browser_init->LaunchBrowser(
1053 command_line, profile, cur_dir, process_startup, return_code); 1056 command_line, profile, cur_dir, process_startup, return_code);
1054 } 1057 }
1055 return true; 1058 return true;
1056 } 1059 }
1057 1060
1058 template <class AutomationProviderClass> 1061 template <class AutomationProviderClass>
1059 void BrowserInit::CreateAutomationProvider(const std::string& channel_id, 1062 bool BrowserInit::CreateAutomationProvider(const std::string& channel_id,
1060 Profile* profile, 1063 Profile* profile,
1061 size_t expected_tabs) { 1064 size_t expected_tabs) {
1062 scoped_refptr<AutomationProviderClass> automation = 1065 scoped_refptr<AutomationProviderClass> automation =
1063 new AutomationProviderClass(profile); 1066 new AutomationProviderClass(profile);
1064 automation->ConnectToChannel(channel_id); 1067
1068 if (!automation->InitializeChannel(channel_id))
1069 return false;
1065 automation->SetExpectedTabCount(expected_tabs); 1070 automation->SetExpectedTabCount(expected_tabs);
1066 1071
1067 AutomationProviderList* list = 1072 AutomationProviderList* list =
1068 g_browser_process->InitAutomationProviderList(); 1073 g_browser_process->InitAutomationProviderList();
1069 DCHECK(list); 1074 DCHECK(list);
1070 list->AddProvider(automation); 1075 list->AddProvider(automation);
1076
1077 return true;
1071 } 1078 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_init.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698