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

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

Issue 6012006: Revert 68944 - Revert "Add named testing interface." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 if (command_line.HasSwitch(switches::kNoStartupWindow)) { 997 if (command_line.HasSwitch(switches::kNoStartupWindow)) {
998 expected_tab_count = 0; 998 expected_tab_count = 0;
999 } else if (command_line.HasSwitch(switches::kRestoreLastSession)) { 999 } else if (command_line.HasSwitch(switches::kRestoreLastSession)) {
1000 std::string restore_session_value( 1000 std::string restore_session_value(
1001 command_line.GetSwitchValueASCII(switches::kRestoreLastSession)); 1001 command_line.GetSwitchValueASCII(switches::kRestoreLastSession));
1002 base::StringToInt(restore_session_value, &expected_tab_count); 1002 base::StringToInt(restore_session_value, &expected_tab_count);
1003 } else { 1003 } else {
1004 expected_tab_count = 1004 expected_tab_count =
1005 std::max(1, static_cast<int>(command_line.args().size())); 1005 std::max(1, static_cast<int>(command_line.args().size()));
1006 } 1006 }
1007 CreateAutomationProvider<TestingAutomationProvider>( 1007 if (!CreateAutomationProvider<TestingAutomationProvider>(
1008 testing_channel_id, 1008 testing_channel_id,
1009 profile, 1009 profile,
1010 static_cast<size_t>(expected_tab_count)); 1010 static_cast<size_t>(expected_tab_count)))
1011 return false;
1011 } 1012 }
1012 } 1013 }
1013 1014
1014 bool silent_launch = false; 1015 bool silent_launch = false;
1015 1016
1016 if (command_line.HasSwitch(switches::kAutomationClientChannelID)) { 1017 if (command_line.HasSwitch(switches::kAutomationClientChannelID)) {
1017 std::string automation_channel_id = command_line.GetSwitchValueASCII( 1018 std::string automation_channel_id = command_line.GetSwitchValueASCII(
1018 switches::kAutomationClientChannelID); 1019 switches::kAutomationClientChannelID);
1019 // If there are any extra parameters, we expect each one to generate a 1020 // If there are any extra parameters, we expect each one to generate a
1020 // new tab; if there are none then we have no tabs 1021 // new tab; if there are none then we have no tabs
1021 size_t expected_tabs = 1022 size_t expected_tabs =
1022 std::max(static_cast<int>(command_line.args().size()), 0); 1023 std::max(static_cast<int>(command_line.args().size()), 0);
1023 if (expected_tabs == 0) 1024 if (expected_tabs == 0)
1024 silent_launch = true; 1025 silent_launch = true;
1025 1026
1026 if (command_line.HasSwitch(switches::kChromeFrame)) { 1027 if (command_line.HasSwitch(switches::kChromeFrame)) {
1027 CreateAutomationProvider<ChromeFrameAutomationProvider>( 1028 if (!CreateAutomationProvider<ChromeFrameAutomationProvider>(
1028 automation_channel_id, profile, expected_tabs); 1029 automation_channel_id, profile, expected_tabs))
1030 return false;
1029 } else { 1031 } else {
1030 CreateAutomationProvider<AutomationProvider>(automation_channel_id, 1032 if (!CreateAutomationProvider<AutomationProvider>(
1031 profile, expected_tabs); 1033 automation_channel_id, profile, expected_tabs))
1034 return false;
1032 } 1035 }
1033 } 1036 }
1034 1037
1035 // If we have been invoked to display a desktop notification on behalf of 1038 // If we have been invoked to display a desktop notification on behalf of
1036 // the service process, we do not want to open any browser windows. 1039 // the service process, we do not want to open any browser windows.
1037 if (command_line.HasSwitch(switches::kNotifyCloudPrintTokenExpired)) { 1040 if (command_line.HasSwitch(switches::kNotifyCloudPrintTokenExpired)) {
1038 silent_launch = true; 1041 silent_launch = true;
1039 profile->GetCloudPrintProxyService()->ShowTokenExpiredNotification(); 1042 profile->GetCloudPrintProxyService()->ShowTokenExpiredNotification();
1040 } 1043 }
1041 1044
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 // If we don't want to launch a new browser window or tab (in the case 1083 // If we don't want to launch a new browser window or tab (in the case
1081 // of an automation request), we are done here. 1084 // of an automation request), we are done here.
1082 if (!silent_launch) { 1085 if (!silent_launch) {
1083 return browser_init->LaunchBrowser( 1086 return browser_init->LaunchBrowser(
1084 command_line, profile, cur_dir, process_startup, return_code); 1087 command_line, profile, cur_dir, process_startup, return_code);
1085 } 1088 }
1086 return true; 1089 return true;
1087 } 1090 }
1088 1091
1089 template <class AutomationProviderClass> 1092 template <class AutomationProviderClass>
1090 void BrowserInit::CreateAutomationProvider(const std::string& channel_id, 1093 bool BrowserInit::CreateAutomationProvider(const std::string& channel_id,
1091 Profile* profile, 1094 Profile* profile,
1092 size_t expected_tabs) { 1095 size_t expected_tabs) {
1093 scoped_refptr<AutomationProviderClass> automation = 1096 scoped_refptr<AutomationProviderClass> automation =
1094 new AutomationProviderClass(profile); 1097 new AutomationProviderClass(profile);
1095 automation->ConnectToChannel(channel_id); 1098
1099 if (!automation->InitializeChannel(channel_id))
1100 return false;
1096 automation->SetExpectedTabCount(expected_tabs); 1101 automation->SetExpectedTabCount(expected_tabs);
1097 1102
1098 AutomationProviderList* list = 1103 AutomationProviderList* list =
1099 g_browser_process->InitAutomationProviderList(); 1104 g_browser_process->InitAutomationProviderList();
1100 DCHECK(list); 1105 DCHECK(list);
1101 list->AddProvider(automation); 1106 list->AddProvider(automation);
1107
1108 return true;
1102 } 1109 }
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