| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/remoting/page_load_notification_observer.h" | 5 #include "chrome/test/remoting/page_load_notification_observer.h" |
| 6 | 6 |
| 7 #include "content/public/browser/navigation_controller.h" | 7 #include "content/public/browser/navigation_controller.h" |
| 8 #include "content/public/browser/notification_types.h" | 8 #include "content/public/browser/notification_types.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 | 10 |
| 11 namespace remoting { | 11 namespace remoting { |
| 12 | 12 |
| 13 PageLoadNotificationObserver::PageLoadNotificationObserver(const GURL& target) | 13 PageLoadNotificationObserver::PageLoadNotificationObserver(const GURL& target) |
| 14 : WindowedNotificationObserver( | 14 : WindowedNotificationObserver( |
| 15 content::NOTIFICATION_LOAD_STOP, | 15 content::NOTIFICATION_LOAD_STOP, |
| 16 base::Bind(&PageLoadNotificationObserver::IsTargetLoaded, | 16 base::Bind(&PageLoadNotificationObserver::IsTargetLoaded, |
| 17 base::Unretained(this))), | 17 base::Unretained(this))), |
| 18 target_(target) { | 18 target_(target), |
| 19 ignore_url_parameters_(false) { |
| 19 } | 20 } |
| 20 | 21 |
| 21 PageLoadNotificationObserver::~PageLoadNotificationObserver() {} | 22 PageLoadNotificationObserver::~PageLoadNotificationObserver() {} |
| 22 | 23 |
| 23 bool PageLoadNotificationObserver::IsTargetLoaded() { | 24 bool PageLoadNotificationObserver::IsTargetLoaded() { |
| 24 content::NavigationController* controller = | 25 content::NavigationController* controller = |
| 25 content::Source<content::NavigationController>(source()).ptr(); | 26 content::Source<content::NavigationController>(source()).ptr(); |
| 26 return controller->GetWebContents()->GetURL() == target_; | 27 GURL current_url = controller->GetWebContents()->GetURL(); |
| 28 if (ignore_url_parameters_) { |
| 29 GURL::Replacements strip_query; |
| 30 strip_query.ClearQuery(); |
| 31 return current_url.ReplaceComponents(strip_query) == |
| 32 target_.ReplaceComponents(strip_query); |
| 33 } else { |
| 34 return current_url == target_; |
| 35 } |
| 27 } | 36 } |
| 28 | 37 |
| 29 } // namespace remoting | 38 } // namespace remoting |
| OLD | NEW |