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

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

Issue 9301025: Refactor AutomationProvider::InitialLoadsComplete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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
« no previous file with comments | « chrome/browser/automation/automation_provider.h ('k') | no next file » | 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) 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 void AutomationProvider::SetExpectedTabCount(size_t expected_tabs) { 264 void AutomationProvider::SetExpectedTabCount(size_t expected_tabs) {
265 if (expected_tabs == 0) 265 if (expected_tabs == 0)
266 OnInitialTabLoadsComplete(); 266 OnInitialTabLoadsComplete();
267 else 267 else
268 initial_load_observer_.reset(new InitialLoadObserver(expected_tabs, this)); 268 initial_load_observer_.reset(new InitialLoadObserver(expected_tabs, this));
269 } 269 }
270 270
271 void AutomationProvider::OnInitialTabLoadsComplete() { 271 void AutomationProvider::OnInitialTabLoadsComplete() {
272 initial_tab_loads_complete_ = true; 272 initial_tab_loads_complete_ = true;
273 VLOG(2) << "OnInitialTabLoadsComplete"; 273 VLOG(2) << "OnInitialTabLoadsComplete";
274 if (is_connected_ && network_library_initialized_ && login_webui_ready_) 274 SendInitialLoadMessage();
275 Send(new AutomationMsg_InitialLoadsComplete());
276 } 275 }
277 276
278 void AutomationProvider::OnNetworkLibraryInit() { 277 void AutomationProvider::OnNetworkLibraryInit() {
279 network_library_initialized_ = true; 278 network_library_initialized_ = true;
280 VLOG(2) << "OnNetworkLibraryInit"; 279 VLOG(2) << "OnNetworkLibraryInit";
281 if (is_connected_ && initial_tab_loads_complete_ && login_webui_ready_) 280 SendInitialLoadMessage();
282 Send(new AutomationMsg_InitialLoadsComplete());
283 } 281 }
284 282
285 void AutomationProvider::OnLoginWebuiReady() { 283 void AutomationProvider::OnLoginWebuiReady() {
286 login_webui_ready_ = true; 284 login_webui_ready_ = true;
287 VLOG(2) << "OnLoginWebuiReady"; 285 VLOG(2) << "OnLoginWebuiReady";
286 SendInitialLoadMessage();
287 }
288
289 void AutomationProvider::SendInitialLoadMessage() {
288 if (is_connected_ && initial_tab_loads_complete_ && 290 if (is_connected_ && initial_tab_loads_complete_ &&
289 network_library_initialized_) 291 network_library_initialized_ && login_webui_ready_) {
292 LOG(INFO) << "Initial loads complete; sending initial loads message.";
290 Send(new AutomationMsg_InitialLoadsComplete()); 293 Send(new AutomationMsg_InitialLoadsComplete());
294 }
291 } 295 }
292 296
293 void AutomationProvider::AddLoginHandler(NavigationController* tab, 297 void AutomationProvider::AddLoginHandler(NavigationController* tab,
294 LoginHandler* handler) { 298 LoginHandler* handler) {
295 login_handler_map_[tab] = handler; 299 login_handler_map_[tab] = handler;
296 } 300 }
297 301
298 void AutomationProvider::RemoveLoginHandler(NavigationController* tab) { 302 void AutomationProvider::RemoveLoginHandler(NavigationController* tab) {
299 DCHECK(login_handler_map_[tab]); 303 DCHECK(login_handler_map_[tab]);
300 login_handler_map_.erase(tab); 304 login_handler_map_.erase(tab);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 ExtensionService* service = profile_->GetExtensionService(); 373 ExtensionService* service = profile_->GetExtensionService();
370 if (extension && service && 374 if (extension && service &&
371 service->GetExtensionById(extension->id(), true) && 375 service->GetExtensionById(extension->id(), true) &&
372 !service->GetExtensionById(extension->id(), false)) 376 !service->GetExtensionById(extension->id(), false))
373 return extension; 377 return extension;
374 return NULL; 378 return NULL;
375 } 379 }
376 380
377 void AutomationProvider::OnChannelConnected(int pid) { 381 void AutomationProvider::OnChannelConnected(int pid) {
378 is_connected_ = true; 382 is_connected_ = true;
379 LOG(INFO) << "Testing channel connected, sending hello message";
380 383
381 // Send a hello message with our current automation protocol version. 384 // Send a hello message with our current automation protocol version.
385 LOG(INFO) << "Testing channel connected, sending hello message";
382 channel_->Send(new AutomationMsg_Hello(GetProtocolVersion())); 386 channel_->Send(new AutomationMsg_Hello(GetProtocolVersion()));
383 if (initial_tab_loads_complete_ && network_library_initialized_ && 387
384 login_webui_ready_) 388 SendInitialLoadMessage();
385 Send(new AutomationMsg_InitialLoadsComplete());
386 } 389 }
387 390
388 void AutomationProvider::OnEndTracingComplete() { 391 void AutomationProvider::OnEndTracingComplete() {
389 IPC::Message* reply_message = tracing_data_.reply_message.release(); 392 IPC::Message* reply_message = tracing_data_.reply_message.release();
390 if (reply_message) { 393 if (reply_message) {
391 AutomationMsg_EndTracing::WriteReplyParams( 394 AutomationMsg_EndTracing::WriteReplyParams(
392 reply_message, tracing_data_.trace_output.size(), true); 395 reply_message, tracing_data_.trace_output.size(), true);
393 Send(reply_message); 396 Send(reply_message);
394 } 397 }
395 } 398 }
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 } 1003 }
1001 } 1004 }
1002 } 1005 }
1003 1006
1004 void AutomationProvider::SaveAsAsync(int tab_handle) { 1007 void AutomationProvider::SaveAsAsync(int tab_handle) {
1005 NavigationController* tab = NULL; 1008 NavigationController* tab = NULL;
1006 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); 1009 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab);
1007 if (web_contents) 1010 if (web_contents)
1008 web_contents->OnSavePage(); 1011 web_contents->OnSavePage();
1009 } 1012 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698