OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
9 #include "chrome/browser/automation/automation_provider.h" | 9 #include "chrome/browser/automation/automation_provider.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 controller_(controller), | 130 controller_(controller), |
131 navigations_remaining_(number_of_navigations), | 131 navigations_remaining_(number_of_navigations), |
132 navigation_started_(false) { | 132 navigation_started_(false) { |
133 DCHECK_LT(0, navigations_remaining_); | 133 DCHECK_LT(0, navigations_remaining_); |
134 Source<NavigationController> source(controller_); | 134 Source<NavigationController> source(controller_); |
135 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, source); | 135 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, source); |
136 registrar_.Add(this, NotificationType::LOAD_START, source); | 136 registrar_.Add(this, NotificationType::LOAD_START, source); |
137 registrar_.Add(this, NotificationType::LOAD_STOP, source); | 137 registrar_.Add(this, NotificationType::LOAD_STOP, source); |
138 registrar_.Add(this, NotificationType::AUTH_NEEDED, source); | 138 registrar_.Add(this, NotificationType::AUTH_NEEDED, source); |
139 registrar_.Add(this, NotificationType::AUTH_SUPPLIED, source); | 139 registrar_.Add(this, NotificationType::AUTH_SUPPLIED, source); |
| 140 registrar_.Add(this, NotificationType::AUTH_CANCELLED, source); |
140 | 141 |
141 if (include_current_navigation && controller->tab_contents()->is_loading()) | 142 if (include_current_navigation && controller->tab_contents()->is_loading()) |
142 navigation_started_ = true; | 143 navigation_started_ = true; |
143 } | 144 } |
144 | 145 |
145 NavigationNotificationObserver::~NavigationNotificationObserver() { | 146 NavigationNotificationObserver::~NavigationNotificationObserver() { |
146 if (reply_message_) { | 147 if (reply_message_) { |
147 // This means we did not receive a notification for this navigation. | 148 // This means we did not receive a notification for this navigation. |
148 // Send over a failed navigation status back to the caller to ensure that | 149 // Send over a failed navigation status back to the caller to ensure that |
149 // the caller does not hang waiting for the response. | 150 // the caller does not hang waiting for the response. |
(...skipping 18 matching lines...) Expand all Loading... |
168 // we need the NotificationType::LOAD_START. | 169 // we need the NotificationType::LOAD_START. |
169 if (type == NotificationType::NAV_ENTRY_COMMITTED || | 170 if (type == NotificationType::NAV_ENTRY_COMMITTED || |
170 type == NotificationType::LOAD_START) { | 171 type == NotificationType::LOAD_START) { |
171 navigation_started_ = true; | 172 navigation_started_ = true; |
172 } else if (type == NotificationType::LOAD_STOP) { | 173 } else if (type == NotificationType::LOAD_STOP) { |
173 if (navigation_started_) { | 174 if (navigation_started_) { |
174 navigation_started_ = false; | 175 navigation_started_ = false; |
175 if (--navigations_remaining_ == 0) | 176 if (--navigations_remaining_ == 0) |
176 ConditionMet(AUTOMATION_MSG_NAVIGATION_SUCCESS); | 177 ConditionMet(AUTOMATION_MSG_NAVIGATION_SUCCESS); |
177 } | 178 } |
178 } else if (type == NotificationType::AUTH_SUPPLIED) { | 179 } else if (type == NotificationType::AUTH_SUPPLIED || |
| 180 type == NotificationType::AUTH_CANCELLED) { |
179 // The LoginHandler for this tab is no longer valid. | 181 // The LoginHandler for this tab is no longer valid. |
180 automation_->RemoveLoginHandler(controller_); | 182 automation_->RemoveLoginHandler(controller_); |
181 | 183 |
182 // Treat this as if navigation started again, since load start/stop don't | 184 // Treat this as if navigation started again, since load start/stop don't |
183 // occur while authentication is ongoing. | 185 // occur while authentication is ongoing. |
184 navigation_started_ = true; | 186 navigation_started_ = true; |
185 } else if (type == NotificationType::AUTH_NEEDED) { | 187 } else if (type == NotificationType::AUTH_NEEDED) { |
186 // Remember the login handler that wants authentication. | 188 // Remember the login handler that wants authentication. |
187 // We do this in all cases (not just when navigation_started_ == true) so | 189 // We do this in all cases (not just when navigation_started_ == true) so |
188 // tests can still wait for auth dialogs outside of navigation. | 190 // tests can still wait for auth dialogs outside of navigation. |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 AutomationProviderBookmarkModelObserver::~AutomationProviderBookmarkModelObserve
r() { | 760 AutomationProviderBookmarkModelObserver::~AutomationProviderBookmarkModelObserve
r() { |
759 model_->RemoveObserver(this); | 761 model_->RemoveObserver(this); |
760 } | 762 } |
761 | 763 |
762 void AutomationProviderBookmarkModelObserver::ReplyAndDelete(bool success) { | 764 void AutomationProviderBookmarkModelObserver::ReplyAndDelete(bool success) { |
763 AutomationMsg_WaitForBookmarkModelToLoad::WriteReplyParams( | 765 AutomationMsg_WaitForBookmarkModelToLoad::WriteReplyParams( |
764 reply_message_, success); | 766 reply_message_, success); |
765 automation_provider_->Send(reply_message_); | 767 automation_provider_->Send(reply_message_); |
766 delete this; | 768 delete this; |
767 } | 769 } |
OLD | NEW |