File: location_bar_model.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (89 lines) | stat: -rw-r--r-- 3,644 bytes parent folder | download | duplicates (6)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_OMNIBOX_BROWSER_LOCATION_BAR_MODEL_H_
#define COMPONENTS_OMNIBOX_BROWSER_LOCATION_BAR_MODEL_H_

#include <stddef.h>

#include <string>

#include "components/omnibox/common/omnibox_focus_state.h"
#include "components/security_state/core/security_state.h"
#include "third_party/metrics_proto/omnibox_event.pb.h"
#include "url/gurl.h"

namespace gfx {
struct VectorIcon;
}

// This class provides information about the current navigation entry.
// Its methods always return data related to the current page, and does not
// account for the state of the omnibox, which is tracked by OmniboxEditModel.
class LocationBarModel {
 public:
  virtual ~LocationBarModel() = default;

  // Returns the formatted full URL for the toolbar. The formatting includes:
  //   - Some characters may be unescaped.
  //   - The scheme and/or trailing slash may be dropped.
  // This method specifically keeps the URL suitable for editing by not
  // applying any elisions that change the meaning of the URL.
  virtual std::u16string GetFormattedFullURL() const = 0;

  // Returns a simplified URL for display (but not editing) on the toolbar.
  // This formatting is generally a superset of GetFormattedFullURL, and may
  // include some destructive elisions that change the meaning of the URL.
  // The returned string is not suitable for editing, and is for display only.
  virtual std::u16string GetURLForDisplay() const = 0;

  // Returns the URL of the current navigation entry.
  virtual GURL GetURL() const = 0;

  // Returns the security level that the toolbar should display.
  virtual security_state::SecurityLevel GetSecurityLevel() const = 0;

  // Returns the cert status of the current navigation entry.
  virtual net::CertStatus GetCertStatus() const = 0;

  // Classify the current page being viewed as, for example, the new tab
  // page or a normal web page.  Used for logging omnibox events for
  // UMA opted-in users.  Examines the user's profile to determine if the
  // current page is the user's home page.
  virtual metrics::OmniboxEventProto::PageClassification GetPageClassification(
      bool is_prefetch = false) const = 0;

  // Returns the id of the icon to show to the left of the address, based on the
  // current URL.  When search term replacement is active, this returns a search
  // icon.
  virtual const gfx::VectorIcon& GetVectorIcon() const = 0;

  // Returns text for the omnibox secure verbose chip, displayed next to the
  // security icon on certain platforms.
  virtual std::u16string GetSecureDisplayText() const = 0;

  // Returns text describing the security state for accessibility.
  virtual std::u16string GetSecureAccessibilityText() const = 0;

  // Returns whether the URL for the current navigation entry should be
  // in the location bar.
  virtual bool ShouldDisplayURL() const = 0;

  // Returns whether the page is an offline page, sourced from a cache of
  // previously-downloaded content.
  virtual bool IsOfflinePage() const = 0;

  // Returns whether to prevent elision of the display URL, based on whether
  // user has a specified extension or pref enabled. If true, the only elisions
  // should be username/password and trailing slash on bare hostname.
  virtual bool ShouldPreventElision() const = 0;

 protected:
  LocationBarModel() = default;

  LocationBarModel(const LocationBarModel&) = delete;
  LocationBarModel& operator=(const LocationBarModel&) = delete;
};

#endif  // COMPONENTS_OMNIBOX_BROWSER_LOCATION_BAR_MODEL_H_