| OLD | NEW |
| 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_observers.h" | 5 #include "chrome/browser/automation/automation_provider_observers.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 | 248 |
| 249 NavigationControllerRestoredObserver::~NavigationControllerRestoredObserver() { | 249 NavigationControllerRestoredObserver::~NavigationControllerRestoredObserver() { |
| 250 } | 250 } |
| 251 | 251 |
| 252 void NavigationControllerRestoredObserver::Observe( | 252 void NavigationControllerRestoredObserver::Observe( |
| 253 int type, const content::NotificationSource& source, | 253 int type, const content::NotificationSource& source, |
| 254 const content::NotificationDetails& details) { | 254 const content::NotificationDetails& details) { |
| 255 if (FinishedRestoring()) { | 255 if (FinishedRestoring()) { |
| 256 registrar_.RemoveAll(); |
| 256 SendDone(); | 257 SendDone(); |
| 257 registrar_.RemoveAll(); | |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| 261 bool NavigationControllerRestoredObserver::FinishedRestoring() { | 261 bool NavigationControllerRestoredObserver::FinishedRestoring() { |
| 262 return (!controller_->NeedsReload() && !controller_->GetPendingEntry() && | 262 return (!controller_->NeedsReload() && !controller_->GetPendingEntry() && |
| 263 !controller_->GetWebContents()->IsLoading()); | 263 !controller_->GetWebContents()->IsLoading()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void NavigationControllerRestoredObserver::SendDone() { | 266 void NavigationControllerRestoredObserver::SendDone() { |
| 267 if (!automation_) | 267 if (automation_) { |
| 268 return; | 268 AutomationJSONReply(automation_, reply_message_.release()) |
| 269 | 269 .SendSuccess(NULL); |
| 270 AutomationMsg_WaitForTabToBeRestored::WriteReplyParams(reply_message_.get(), | 270 } |
| 271 true); | 271 delete this; |
| 272 automation_->Send(reply_message_.release()); | |
| 273 } | 272 } |
| 274 | 273 |
| 275 NavigationNotificationObserver::NavigationNotificationObserver( | 274 NavigationNotificationObserver::NavigationNotificationObserver( |
| 276 NavigationController* controller, | 275 NavigationController* controller, |
| 277 AutomationProvider* automation, | 276 AutomationProvider* automation, |
| 278 IPC::Message* reply_message, | 277 IPC::Message* reply_message, |
| 279 int number_of_navigations, | 278 int number_of_navigations, |
| 280 bool include_current_navigation, | 279 bool include_current_navigation, |
| 281 bool use_json_interface) | 280 bool use_json_interface) |
| 282 : automation_(automation->AsWeakPtr()), | 281 : automation_(automation->AsWeakPtr()), |
| (...skipping 2871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3154 if (automation_) { | 3153 if (automation_) { |
| 3155 AutomationJSONReply(automation_, reply_message_.release()) | 3154 AutomationJSONReply(automation_, reply_message_.release()) |
| 3156 .SendSuccess(NULL); | 3155 .SendSuccess(NULL); |
| 3157 } | 3156 } |
| 3158 delete this; | 3157 delete this; |
| 3159 } | 3158 } |
| 3160 } else { | 3159 } else { |
| 3161 NOTREACHED(); | 3160 NOTREACHED(); |
| 3162 } | 3161 } |
| 3163 } | 3162 } |
| OLD | NEW |