Molybden
Loading...
Searching...
No Matches
navigation.hpp
1// Copyright (c) 2000-2023 TeamDev Ltd. All rights reserved.
2// TeamDev PROPRIETARY and CONFIDENTIAL.
3// Use is subject to license terms.
4
5#ifndef MOLYBDEN_NAVIGATION_HPP
6#define MOLYBDEN_NAVIGATION_HPP
7
8#include <memory>
9#include <string>
10#include <vector>
11
12#include "molybden/browser/browser.hpp"
13#include "molybden/navigation/navigation_events.hpp"
14#include "molybden/navigation/navigation_delegates.hpp"
15#include "molybden/network/http_header.hpp"
16#include "molybden/network/upload_data.hpp"
17#include "molybden/time/timestamp.hpp"
18
19namespace molybden {
20
24constexpr int64_t kDefaultNavigationTimeoutInSeconds = 30;
25
33 std::shared_ptr<UploadData> upload_data;
34
48 std::vector<HttpHeader> extra_http_headers;
49};
50
54enum class PageType { kUnspecified, kNormal, kError };
55
63 std::string title;
64
68 std::string url;
69
74
78 HttpStatusCode http_status_code;
79
83 PageType page_type;
84
89 Timestamp timestamp;
90};
91
97 public NavigationDelegates {
98 public:
102 virtual std::shared_ptr<Browser> browser() = 0;
103
116 virtual void loadUrl(const std::string& url) = 0;
117
133 virtual void loadUrl(const std::string& url,
134 const LoadUrlOptions& options) = 0;
135
151 virtual bool loadUrlAndWait(const std::string& url) = 0;
152
167 virtual bool loadUrlAndWait(const std::string& url,
168 uint64_t timeout_in_seconds) = 0;
169
187 virtual bool loadUrlAndWait(const std::string& url,
188 const LoadUrlOptions& options) = 0;
189
206 virtual bool loadUrlAndWait(const std::string& url,
207 const LoadUrlOptions& options,
208 uint64_t timeout_in_seconds) = 0;
209
214 virtual void goBack() = 0;
215
219 virtual bool canGoBack() = 0;
220
225 virtual void goForward() = 0;
226
230 virtual bool canGoForward() = 0;
231
236 virtual void stop() = 0;
237
241 virtual void reload() = 0;
242
247 virtual void reloadIgnoringCache() = 0;
248
252 virtual void reloadAndCheckForRepost() = 0;
253
260
267 virtual void goToIndex(uint32_t index) = 0;
268
272 virtual uint32_t entryCount() = 0;
273
278 virtual int32_t currentEntryIndex() = 0;
279
286 virtual NavigationEntry entryAtIndex(uint32_t index) = 0;
287
295 virtual bool removeEntryAtIndex(uint32_t index) = 0;
296};
297
298} // namespace molybden
299
300#endif // MOLYBDEN_NAVIGATION_HPP
Objects implement this interface to get notified about changes in Navigation and to provide necessary...
Definition navigation_delegates.hpp:148
A class that contains all navigation events.
Definition navigation_events.hpp:225
Allows loading resources in the browser and working with the navigation history.
Definition navigation.hpp:97
virtual NavigationEntry entryAtIndex(uint32_t index)=0
Returns the navigation entry item at the given index in the back-forward list.
virtual void reloadIgnoringCache()=0
Reloads the currently loaded web page, but if the current web page has POST data, the user is prompte...
virtual void goForward()=0
Loads the next location in the back-forward list.
virtual int32_t currentEntryIndex()=0
Returns the index of the current item in the back-forward list or -1 if the list is empty.
virtual void stop()=0
Cancels any pending navigation or download operation and stops any dynamic page elements,...
virtual void loadUrl(const std::string &url)=0
Starts a navigation to the resource identified by the given url.
virtual bool canGoBack()=0
Checks if the previous location can be loaded.
virtual void goBack()=0
Loads the previous location in the back-forward list.
virtual bool loadUrlAndWait(const std::string &url, const LoadUrlOptions &options, uint64_t timeout_in_seconds)=0
Starts a navigation to the resource identified by the given options and blocks the current thread unt...
virtual void reloadIgnoringCacheAndCheckForRepost()=0
Reloads the currently loaded web page ignoring caches, but if the current web page has POST data,...
virtual void loadUrl(const std::string &url, const LoadUrlOptions &options)=0
Starts a navigation to the resource identified by the given url and options.
virtual void reload()=0
Reloads the currently loaded web page.
virtual bool loadUrlAndWait(const std::string &url)=0
Starts a navigation to the resource identified by the given url and blocks the current thread until t...
virtual void goToIndex(uint32_t index)=0
Navigates to the navigation entry item at the given index in the back-forward list.
virtual bool loadUrlAndWait(const std::string &url, const LoadUrlOptions &options)=0
Starts a navigation to the resource identified by the given options and blocks the current thread unt...
virtual std::shared_ptr< Browser > browser()=0
The browser instance of this navigation.
virtual bool removeEntryAtIndex(uint32_t index)=0
Removes the item at the given index in the back-forward list and returns true if it was removed succe...
virtual void reloadAndCheckForRepost()=0
Reloads the currently loaded web page ignoring caches.
virtual bool loadUrlAndWait(const std::string &url, uint64_t timeout_in_seconds)=0
Starts a navigation to the resource identified by the given url and blocks the current thread until t...
virtual uint32_t entryCount()=0
Returns the number of items in the back-forward list.
virtual bool canGoForward()=0
Checks if the next location can be loaded.
The optional parameters of the load URL request.
Definition navigation.hpp:29
std::shared_ptr< UploadData > upload_data
The upload data that will be sent with the request.
Definition navigation.hpp:33
std::vector< HttpHeader > extra_http_headers
The extra HTTP headers that will be sent with the request.
Definition navigation.hpp:48
The navigation history entry.
Definition navigation.hpp:59
std::string url
The actual URL of the web page.
Definition navigation.hpp:68
std::string title
The title as set by the web page or an empty string if there is no title.
Definition navigation.hpp:63
PageType page_type
The page type of this navigation entry.
Definition navigation.hpp:83
std::string original_request_url
The URL that caused this navigation entry to be created.
Definition navigation.hpp:73
HttpStatusCode http_status_code
The status code of the last known successful navigation.
Definition navigation.hpp:78
Timestamp timestamp
The time at which the last known navigation was completed.
Definition navigation.hpp:89