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

Side by Side Diff: chrome/browser/automation/automation_provider.cc

Issue 23503040: Remove all NetworkLibrary dependencies from AutomationTestingProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 3 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/automation/automation_provider.h" 5 #include "chrome/browser/automation/automation_provider.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 AutomationProvider::AutomationProvider(Profile* profile) 152 AutomationProvider::AutomationProvider(Profile* profile)
153 : profile_(profile), 153 : profile_(profile),
154 reply_message_(NULL), 154 reply_message_(NULL),
155 reinitialize_on_channel_error_( 155 reinitialize_on_channel_error_(
156 CommandLine::ForCurrentProcess()->HasSwitch( 156 CommandLine::ForCurrentProcess()->HasSwitch(
157 switches::kAutomationReinitializeOnChannelError)), 157 switches::kAutomationReinitializeOnChannelError)),
158 use_initial_load_observers_(true), 158 use_initial_load_observers_(true),
159 is_connected_(false), 159 is_connected_(false),
160 initial_tab_loads_complete_(false), 160 initial_tab_loads_complete_(false),
161 network_library_initialized_(true),
162 login_webui_ready_(true) { 161 login_webui_ready_(true) {
163 TRACE_EVENT_BEGIN_ETW("AutomationProvider::AutomationProvider", 0, ""); 162 TRACE_EVENT_BEGIN_ETW("AutomationProvider::AutomationProvider", 0, "");
164 163
165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
166 165
167 browser_tracker_.reset(new AutomationBrowserTracker(this)); 166 browser_tracker_.reset(new AutomationBrowserTracker(this));
168 tab_tracker_.reset(new AutomationTabTracker(this)); 167 tab_tracker_.reset(new AutomationTabTracker(this));
169 window_tracker_.reset(new AutomationWindowTracker(this)); 168 window_tracker_.reset(new AutomationWindowTracker(this));
170 new_tab_ui_load_observer_.reset(new NewTabUILoadObserver(this, profile)); 169 new_tab_ui_load_observer_.reset(new NewTabUILoadObserver(this, profile));
171 metric_event_duration_observer_.reset(new MetricEventDurationObserver()); 170 metric_event_duration_observer_.reset(new MetricEventDurationObserver());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 #if defined(OS_CHROMEOS) 214 #if defined(OS_CHROMEOS)
216 if (use_initial_load_observers_) { 215 if (use_initial_load_observers_) {
217 // Wait for webui login to be ready. 216 // Wait for webui login to be ready.
218 // Observer will delete itself. 217 // Observer will delete itself.
219 if (CommandLine::ForCurrentProcess()->HasSwitch( 218 if (CommandLine::ForCurrentProcess()->HasSwitch(
220 chromeos::switches::kLoginManager) && 219 chromeos::switches::kLoginManager) &&
221 !chromeos::LoginState::Get()->IsUserLoggedIn()) { 220 !chromeos::LoginState::Get()->IsUserLoggedIn()) {
222 login_webui_ready_ = false; 221 login_webui_ready_ = false;
223 new OOBEWebuiReadyObserver(this); 222 new OOBEWebuiReadyObserver(this);
224 } 223 }
225
226 // Wait for the network manager to initialize.
227 // The observer will delete itself when done.
228 network_library_initialized_ = false;
229 NetworkManagerInitObserver* observer = new NetworkManagerInitObserver(this);
230 if (!observer->Init())
231 delete observer;
232 } 224 }
233 #endif 225 #endif
234 226
235 TRACE_EVENT_END_ETW("AutomationProvider::InitializeChannel", 0, ""); 227 TRACE_EVENT_END_ETW("AutomationProvider::InitializeChannel", 0, "");
236 228
237 return true; 229 return true;
238 } 230 }
239 231
240 IPC::Channel::Mode AutomationProvider::GetChannelMode( 232 IPC::Channel::Mode AutomationProvider::GetChannelMode(
241 bool use_named_interface) { 233 bool use_named_interface) {
(...skipping 15 matching lines...) Expand all
257 else 249 else
258 initial_load_observer_.reset(new InitialLoadObserver(expected_tabs, this)); 250 initial_load_observer_.reset(new InitialLoadObserver(expected_tabs, this));
259 } 251 }
260 252
261 void AutomationProvider::OnInitialTabLoadsComplete() { 253 void AutomationProvider::OnInitialTabLoadsComplete() {
262 initial_tab_loads_complete_ = true; 254 initial_tab_loads_complete_ = true;
263 VLOG(2) << "OnInitialTabLoadsComplete"; 255 VLOG(2) << "OnInitialTabLoadsComplete";
264 SendInitialLoadMessage(); 256 SendInitialLoadMessage();
265 } 257 }
266 258
267 void AutomationProvider::OnNetworkLibraryInit() {
268 network_library_initialized_ = true;
269 VLOG(2) << "OnNetworkLibraryInit";
270 SendInitialLoadMessage();
271 }
272
273 void AutomationProvider::OnOOBEWebuiReady() { 259 void AutomationProvider::OnOOBEWebuiReady() {
274 login_webui_ready_ = true; 260 login_webui_ready_ = true;
275 VLOG(2) << "OnOOBEWebuiReady"; 261 VLOG(2) << "OnOOBEWebuiReady";
276 SendInitialLoadMessage(); 262 SendInitialLoadMessage();
277 } 263 }
278 264
279 void AutomationProvider::SendInitialLoadMessage() { 265 void AutomationProvider::SendInitialLoadMessage() {
280 if (is_connected_ && initial_tab_loads_complete_ && 266 if (is_connected_ && initial_tab_loads_complete_ && login_webui_ready_) {
281 network_library_initialized_ && login_webui_ready_) {
282 VLOG(2) << "Initial loads complete; sending initial loads message."; 267 VLOG(2) << "Initial loads complete; sending initial loads message.";
283 Send(new AutomationMsg_InitialLoadsComplete()); 268 Send(new AutomationMsg_InitialLoadsComplete());
284 } 269 }
285 } 270 }
286 271
287 void AutomationProvider::DisableInitialLoadObservers() { 272 void AutomationProvider::DisableInitialLoadObservers() {
288 use_initial_load_observers_ = false; 273 use_initial_load_observers_ = false;
289 OnInitialTabLoadsComplete(); 274 OnInitialTabLoadsComplete();
290 OnNetworkLibraryInit();
291 OnOOBEWebuiReady(); 275 OnOOBEWebuiReady();
292 } 276 }
293 277
294 int AutomationProvider::GetIndexForNavigationController( 278 int AutomationProvider::GetIndexForNavigationController(
295 const NavigationController* controller, const Browser* parent) const { 279 const NavigationController* controller, const Browser* parent) const {
296 DCHECK(parent); 280 DCHECK(parent);
297 return parent->tab_strip_model()->GetIndexOfWebContents( 281 return parent->tab_strip_model()->GetIndexOfWebContents(
298 controller->GetWebContents()); 282 controller->GetWebContents());
299 } 283 }
300 284
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 778
795 return NULL; 779 return NULL;
796 } 780 }
797 781
798 void AutomationProvider::SaveAsAsync(int tab_handle) { 782 void AutomationProvider::SaveAsAsync(int tab_handle) {
799 NavigationController* tab = NULL; 783 NavigationController* tab = NULL;
800 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); 784 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab);
801 if (web_contents) 785 if (web_contents)
802 web_contents->OnSavePage(); 786 web_contents->OnSavePage();
803 } 787 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider.h ('k') | chrome/browser/automation/automation_provider_observers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698