OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_NAVIGATION_TRACKER_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_NAVIGATION_TRACKER_H_ |
6 #define CHROME_TEST_CHROMEDRIVER_CHROME_NAVIGATION_TRACKER_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_CHROME_NAVIGATION_TRACKER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h" | 14 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h" |
| 15 #include "chrome/test/chromedriver/chrome/page_loading_strategy.h" |
15 #include "chrome/test/chromedriver/chrome/status.h" | 16 #include "chrome/test/chromedriver/chrome/status.h" |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class DictionaryValue; | 19 class DictionaryValue; |
19 } | 20 } |
20 | 21 |
21 struct BrowserInfo; | 22 struct BrowserInfo; |
22 class DevToolsClient; | 23 class DevToolsClient; |
23 class JavaScriptDialogManager; | 24 class JavaScriptDialogManager; |
24 class Status; | 25 class Status; |
25 class Timeout; | 26 class Timeout; |
26 | 27 |
27 // Tracks the navigation state of the page. | 28 // Tracks the navigation state of the page. |
28 class NavigationTracker : public DevToolsEventListener { | 29 class NavigationTracker : public DevToolsEventListener, |
| 30 public PageLoadingStrategy { |
29 public: | 31 public: |
30 enum LoadingState { | |
31 kUnknown, | |
32 kLoading, | |
33 kNotLoading, | |
34 }; | |
35 | 32 |
36 NavigationTracker(DevToolsClient* client, | 33 NavigationTracker(DevToolsClient* client, |
37 const BrowserInfo* browser_info, | 34 const BrowserInfo* browser_info, |
38 const JavaScriptDialogManager* dialog_manager); | 35 const JavaScriptDialogManager* dialog_manager); |
39 | 36 |
40 NavigationTracker(DevToolsClient* client, | 37 NavigationTracker(DevToolsClient* client, |
41 LoadingState known_state, | 38 LoadingState known_state, |
42 const BrowserInfo* browser_info, | 39 const BrowserInfo* browser_info, |
43 const JavaScriptDialogManager* dialog_manager); | 40 const JavaScriptDialogManager* dialog_manager); |
44 | 41 |
45 ~NavigationTracker() override; | 42 ~NavigationTracker() override; |
46 | 43 |
| 44 // Overriden from PageLoadingStrategy: |
47 // Gets whether a navigation is pending for the specified frame. |frame_id| | 45 // Gets whether a navigation is pending for the specified frame. |frame_id| |
48 // may be empty to signify the main frame. | 46 // may be empty to signify the main frame. |
49 Status IsPendingNavigation(const std::string& frame_id, | 47 Status IsPendingNavigation(const std::string& frame_id, |
50 const Timeout* timeout, | 48 const Timeout* timeout, |
51 bool* is_pending); | 49 bool* is_pending) override; |
| 50 void set_timed_out(bool timed_out) override; |
52 | 51 |
53 Status CheckFunctionExists(const Timeout* timeout, bool* exists); | 52 Status CheckFunctionExists(const Timeout* timeout, bool* exists); |
54 | 53 |
55 void set_timed_out(bool timed_out); | |
56 | |
57 // Overridden from DevToolsEventListener: | 54 // Overridden from DevToolsEventListener: |
58 Status OnConnected(DevToolsClient* client) override; | 55 Status OnConnected(DevToolsClient* client) override; |
59 Status OnEvent(DevToolsClient* client, | 56 Status OnEvent(DevToolsClient* client, |
60 const std::string& method, | 57 const std::string& method, |
61 const base::DictionaryValue& params) override; | 58 const base::DictionaryValue& params) override; |
62 Status OnCommandSuccess(DevToolsClient* client, | 59 Status OnCommandSuccess(DevToolsClient* client, |
63 const std::string& method, | 60 const std::string& method, |
64 const base::DictionaryValue& result, | 61 const base::DictionaryValue& result, |
65 const Timeout& command_timeout) override; | 62 const Timeout& command_timeout) override; |
66 | 63 |
(...skipping 11 matching lines...) Loading... |
78 bool timed_out_; | 75 bool timed_out_; |
79 | 76 |
80 void ResetLoadingState(LoadingState loading_state); | 77 void ResetLoadingState(LoadingState loading_state); |
81 bool IsExpectingFrameLoadingEvents(); | 78 bool IsExpectingFrameLoadingEvents(); |
82 bool IsEventLoopPausedByDialogs(); | 79 bool IsEventLoopPausedByDialogs(); |
83 | 80 |
84 DISALLOW_COPY_AND_ASSIGN(NavigationTracker); | 81 DISALLOW_COPY_AND_ASSIGN(NavigationTracker); |
85 }; | 82 }; |
86 | 83 |
87 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_NAVIGATION_TRACKER_H_ | 84 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_NAVIGATION_TRACKER_H_ |
OLD | NEW |