OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H_ | 5 #ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H_ |
6 #define WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H_ | 6 #define WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
17 | 17 |
18 class GURL; | 18 class GURL; |
19 class TestShell; | 19 class TestShell; |
20 | 20 |
21 // Associated with browser-initated navigations to hold tracking data. | 21 // Associated with browser-initated navigations to hold tracking data. |
22 class TestShellExtraData : public WebKit::WebDataSource::ExtraData { | 22 class TestShellExtraData : public WebKit::WebDataSource::ExtraData { |
23 public: | 23 public: |
24 TestShellExtraData(int32 pending_page_id) | 24 TestShellExtraData(int32 pending_page_id) |
25 : pending_page_id(pending_page_id), | 25 : pending_page_id(pending_page_id), |
26 request_committed(false) { | 26 request_committed(false) { |
27 } | 27 } |
28 | 28 |
29 // Contains the page_id for this navigation or -1 if there is none yet. | 29 // Contains the page_id for this navigation or -1 if there is none yet. |
30 int32 pending_page_id; | 30 int32 pending_page_id; |
31 | 31 |
32 // True if we have already processed the "DidCommitLoad" event for this | 32 // True if we have already processed the "DidCommitLoad" event for this |
33 // request. Used by session history. | 33 // request. Used by session history. |
34 bool request_committed; | 34 bool request_committed; |
35 }; | 35 }; |
36 | 36 |
37 // Stores one back/forward navigation state for the test shell. | 37 // Stores one back/forward navigation state for the test shell. |
38 class TestNavigationEntry { | 38 class TestNavigationEntry { |
39 public: | 39 public: |
40 TestNavigationEntry(); | 40 TestNavigationEntry(); |
41 TestNavigationEntry(int page_id, | 41 TestNavigationEntry(int page_id, |
42 const GURL& url, | 42 const GURL& url, |
43 const string16& target_frame); | 43 const base::string16& target_frame); |
44 | 44 |
45 // Virtual to allow test_shell to extend the class. | 45 // Virtual to allow test_shell to extend the class. |
46 ~TestNavigationEntry(); | 46 ~TestNavigationEntry(); |
47 | 47 |
48 // Set / Get the URI | 48 // Set / Get the URI |
49 void SetURL(const GURL& url) { url_ = url; } | 49 void SetURL(const GURL& url) { url_ = url; } |
50 const GURL& GetURL() const { return url_; } | 50 const GURL& GetURL() const { return url_; } |
51 | 51 |
52 // Set / Get opaque state. | 52 // Set / Get opaque state. |
53 // WARNING: This state is saved to the database and used to restore previous | 53 // WARNING: This state is saved to the database and used to restore previous |
54 // states. If you use write a custom TabContents and provide your own | 54 // states. If you use write a custom TabContents and provide your own |
55 // state make sure you have the ability to modify the format in the future | 55 // state make sure you have the ability to modify the format in the future |
56 // while being able to deal with older versions. | 56 // while being able to deal with older versions. |
57 void SetContentState(const std::string& state); | 57 void SetContentState(const std::string& state); |
58 const std::string& GetContentState() const { return state_; } | 58 const std::string& GetContentState() const { return state_; } |
59 | 59 |
60 // Get the page id corresponding to the tab's state. | 60 // Get the page id corresponding to the tab's state. |
61 void SetPageID(int page_id) { page_id_ = page_id; } | 61 void SetPageID(int page_id) { page_id_ = page_id; } |
62 int32 GetPageID() const { return page_id_; } | 62 int32 GetPageID() const { return page_id_; } |
63 | 63 |
64 const string16& GetTargetFrame() const { return target_frame_; } | 64 const base::string16& GetTargetFrame() const { return target_frame_; } |
65 | 65 |
66 private: | 66 private: |
67 // Describes the current page that the tab represents. This is not relevant | 67 // Describes the current page that the tab represents. This is not relevant |
68 // for all tab contents types. | 68 // for all tab contents types. |
69 int32 page_id_; | 69 int32 page_id_; |
70 | 70 |
71 GURL url_; | 71 GURL url_; |
72 std::string state_; | 72 std::string state_; |
73 | 73 |
74 string16 target_frame_; | 74 base::string16 target_frame_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(TestNavigationEntry); | 76 DISALLOW_COPY_AND_ASSIGN(TestNavigationEntry); |
77 }; | 77 }; |
78 | 78 |
79 // Test shell's NavigationController. The goal is to be as close to the Chrome | 79 // Test shell's NavigationController. The goal is to be as close to the Chrome |
80 // version as possible. | 80 // version as possible. |
81 class TestNavigationController { | 81 class TestNavigationController { |
82 public: | 82 public: |
83 TestNavigationController(TestShell* shell); | 83 TestNavigationController(TestShell* shell); |
84 ~TestNavigationController(); | 84 ~TestNavigationController(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // new entry (created by LoadURL). | 175 // new entry (created by LoadURL). |
176 int pending_entry_index_; | 176 int pending_entry_index_; |
177 | 177 |
178 TestShell* shell_; | 178 TestShell* shell_; |
179 int max_page_id_; | 179 int max_page_id_; |
180 | 180 |
181 DISALLOW_COPY_AND_ASSIGN(TestNavigationController); | 181 DISALLOW_COPY_AND_ASSIGN(TestNavigationController); |
182 }; | 182 }; |
183 | 183 |
184 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H_ | 184 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H_ |
OLD | NEW |