Molybden API
Loading...
Searching...
No Matches
navigation.hpp
1// Copyright (c) 2000-2024 TeamDev. 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_delegates.hpp"
14#include "molybden/navigation/navigation_events.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
96 public:
101
105 bool operator==(NetError error) const;
106
111 operator NetError() const;
112
116 operator bool() const;
117
118 private:
119 bool operator==(const NavigationResult& result) = delete;
120 explicit NavigationResult(NetError error, bool timed_out = false);
121
122 bool timed_out_;
123 NetError error_;
124
125 friend class NavigationImpl;
126};
127
133 public:
137 virtual std::shared_ptr<Browser> browser() = 0;
138
151 virtual void loadUrl(const std::string& url) = 0;
152
168 virtual void loadUrl(const std::string& url,
169 const LoadUrlOptions& options) = 0;
170
186 virtual NavigationResult loadUrlAndWait(const std::string& url) = 0;
187
202 virtual NavigationResult loadUrlAndWait(const std::string& url,
203 uint64_t timeout_in_seconds) = 0;
204
222 virtual NavigationResult loadUrlAndWait(const std::string& url,
223 const LoadUrlOptions& options) = 0;
224
241 virtual NavigationResult loadUrlAndWait(const std::string& url,
242 const LoadUrlOptions& options,
243 uint64_t timeout_in_seconds) = 0;
244
249 virtual void goBack() = 0;
250
254 virtual bool canGoBack() = 0;
255
260 virtual void goForward() = 0;
261
265 virtual bool canGoForward() = 0;
266
271 virtual void stop() = 0;
272
276 virtual void reload() = 0;
277
282 virtual void reloadAndCheckForRepost() = 0;
283
287 virtual void reloadIgnoringCache() = 0;
288
295
302 virtual void goToIndex(uint32_t index) = 0;
303
307 virtual uint32_t entryCount() = 0;
308
313 virtual int32_t currentEntryIndex() = 0;
314
321 virtual NavigationEntry entryAtIndex(uint32_t index) = 0;
322
330 virtual bool removeEntryAtIndex(uint32_t index) = 0;
331};
332
333} // namespace molybden
334
335#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:132
virtual NavigationResult 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 NavigationResult 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 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 ignoring caches.
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 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 NavigationResult 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 void reload()=0
Reloads the currently loaded web page.
virtual void goToIndex(uint32_t index)=0
Navigates to the navigation entry item at the given index in the back-forward list.
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 NavigationResult 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 reloadAndCheckForRepost()=0
Reloads the currently loaded web page, but if the current web page has POST data, the user is prompte...
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 result of the blocking navigation.
Definition navigation.hpp:95
bool operator==(NetError error) const
Compares the network error code with to the given error.
bool hasNavigationTimedOut() const
Indicates if the navigation has been timed out.
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