summaryrefslogtreecommitdiff
path: root/chromium/weblayer/public/navigation_controller.h
blob: c584c5d14324271336440d20e10c0529a4747de0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef WEBLAYER_PUBLIC_NAVIGATION_CONTROLLER_H_
#define WEBLAYER_PUBLIC_NAVIGATION_CONTROLLER_H_

#include <algorithm>
#include <string>

class GURL;

namespace weblayer {
class NavigationObserver;

class NavigationController {
 public:
  // The members of this struct and their defaults should be kept in sync with
  // |NavigationController::LoadURLParams|.
  struct NavigateParams {
    bool should_replace_current_entry = false;
  };

  virtual ~NavigationController() = default;

  virtual void AddObserver(NavigationObserver* observer) = 0;

  virtual void RemoveObserver(NavigationObserver* observer) = 0;

  virtual void Navigate(const GURL& url) = 0;

  virtual void Navigate(const GURL& url, const NavigateParams& params) = 0;

  virtual void GoBack() = 0;

  virtual void GoForward() = 0;

  virtual bool CanGoBack() = 0;

  virtual bool CanGoForward() = 0;

  // Navigates to the specified absolute index.
  virtual void GoToIndex(int index) = 0;

  virtual void Reload() = 0;

  virtual void Stop() = 0;

  // Gets the number of entries in the back/forward list.
  virtual int GetNavigationListSize() = 0;

  // Gets the index of the current entry in the back/forward list, or -1 if
  // there are no entries.
  virtual int GetNavigationListCurrentIndex() = 0;

  // Gets the URL of the given entry in the back/forward list, or an empty GURL
  // if there is no navigation entry at that index.
  virtual GURL GetNavigationEntryDisplayURL(int index) = 0;

  // Gets the page title of the given entry in the back/forward list, or an
  // empty string if there is no navigation entry at that index.
  virtual std::string GetNavigationEntryTitle(int index) = 0;

  // Returns whether this entry will be skipped on a call to GoBack() or
  // GoForward(). This will be true for navigations that were done without a
  // user gesture, including both client side redirects and history.pushState.
  virtual bool IsNavigationEntrySkippable(int index) = 0;
};

}  // namespace weblayer

#endif  // WEBLAYER_PUBLIC_NAVIGATION_CONTROLLER_H_