OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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. |
| 4 |
| 5 #ifndef CONTENT_PUBLIC_TEST_NAVIGATION_HANDLE_OBSERVER_H_ |
| 6 #define CONTENT_PUBLIC_TEST_NAVIGATION_HANDLE_OBSERVER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "content/public/browser/web_contents_observer.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 // Gathers data from the NavigationHandle assigned to navigations that start |
| 14 // with the expected URL. |
| 15 class NavigationHandleObserver : public WebContentsObserver { |
| 16 public: |
| 17 NavigationHandleObserver(WebContents* web_contents, |
| 18 const GURL& expected_start_url); |
| 19 |
| 20 void DidStartNavigation(NavigationHandle* navigation_handle) override; |
| 21 void DidFinishNavigation(NavigationHandle* navigation_handle) override; |
| 22 |
| 23 bool has_committed() { return has_committed_; } |
| 24 bool is_error() { return is_error_; } |
| 25 bool is_main_frame() { return is_main_frame_; } |
| 26 bool is_parent_main_frame() { return is_parent_main_frame_; } |
| 27 bool is_renderer_initiated() { return is_renderer_initiated_; } |
| 28 bool is_same_document() { return is_same_document_; } |
| 29 bool was_redirected() { return was_redirected_; } |
| 30 int frame_tree_node_id() { return frame_tree_node_id_; } |
| 31 const GURL& last_committed_url() { return last_committed_url_; } |
| 32 ui::PageTransition page_transition() { return page_transition_; } |
| 33 net::Error net_error_code() { return net_error_code_; } |
| 34 |
| 35 private: |
| 36 // A reference to the NavigationHandle so this class will track only |
| 37 // one navigation at a time. It is set at DidStartNavigation and cleared |
| 38 // at DidFinishNavigation before the NavigationHandle is destroyed. |
| 39 NavigationHandle* handle_ = nullptr; |
| 40 bool has_committed_ = false; |
| 41 bool is_error_ = false; |
| 42 bool is_main_frame_ = false; |
| 43 bool is_parent_main_frame_ = false; |
| 44 bool is_renderer_initiated_ = true; |
| 45 bool is_same_document_ = false; |
| 46 bool was_redirected_ = false; |
| 47 int frame_tree_node_id_ = -1; |
| 48 ui::PageTransition page_transition_ = ui::PAGE_TRANSITION_LINK; |
| 49 GURL expected_start_url_; |
| 50 GURL last_committed_url_; |
| 51 net::Error net_error_code_ = net::OK; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(NavigationHandleObserver); |
| 54 }; |
| 55 |
| 56 } // namespace content |
| 57 |
| 58 #endif // CONTENT_PUBLIC_TEST_NAVIGATION_HANDLE_OBSERVER_H_ |
OLD | NEW |