Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / remoting / page_load_notification_observer.cc
blob51ec300bddcecd434e3ae68ff7bfe7b157628302
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
3 // found in the LICENSE file.
5 #include "chrome/test/remoting/page_load_notification_observer.h"
7 #include "content/public/browser/navigation_controller.h"
8 #include "content/public/browser/notification_types.h"
9 #include "content/public/browser/web_contents.h"
11 namespace remoting {
13 PageLoadNotificationObserver::PageLoadNotificationObserver(const GURL& target)
14 : WindowedNotificationObserver(
15 content::NOTIFICATION_LOAD_STOP,
16 base::Bind(&PageLoadNotificationObserver::IsTargetLoaded,
17 base::Unretained(this))),
18 target_(target),
19 ignore_url_parameters_(false) {
22 PageLoadNotificationObserver::~PageLoadNotificationObserver() {}
24 bool PageLoadNotificationObserver::IsTargetLoaded() {
25 content::NavigationController* controller =
26 content::Source<content::NavigationController>(source()).ptr();
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_;
38 } // namespace remoting