Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / ui / toolbar / toolbar_model.h
blobf4ecb749b7e6b18319fbd5d862175e64dc738d08
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
12 #include "url/gurl.h"
14 namespace net {
15 class X509Certificate;
18 // This class is the model used by the toolbar, location bar and autocomplete
19 // edit. It populates its states from the current navigation entry retrieved
20 // from the navigation controller returned by GetNavigationController().
21 class ToolbarModel {
22 public:
23 // TODO(wtc): unify ToolbarModel::SecurityLevel with SecurityStyle. We
24 // don't need two sets of security UI levels. SECURITY_STYLE_AUTHENTICATED
25 // needs to be refined into three levels: warning, standard, and EV.
26 enum SecurityLevel {
27 #define DEFINE_TOOLBAR_MODEL_SECURITY_LEVEL(name,value) name = value,
28 #include "chrome/browser/ui/toolbar/toolbar_model_security_level_list.h"
29 #undef DEFINE_TOOLBAR_MODEL_SECURITY_LEVEL
32 virtual ~ToolbarModel();
34 // Returns the text to be displayed in the toolbar for the current page.
35 // The text is formatted in various ways:
36 // - If the current page's URL is a search URL for the user's default search
37 // engine, the query will be extracted and returned for display instead
38 // of the URL.
39 // - If the origin chip is enabled and visible, the text will be empty.
40 // - Otherwise, the text will contain the URL returned by GetFormattedURL().
41 virtual base::string16 GetText() const = 0;
43 // Returns a formatted URL for display in the toolbar. The formatting
44 // includes:
45 // - Some characters may be unescaped.
46 // - The scheme and/or trailing slash may be dropped.
47 virtual base::string16 GetFormattedURL() const = 0;
49 // Some search URLs bundle a special "corpus" param that we can extract and
50 // display next to users' search terms in cases where we'd show the search
51 // terms instead of the URL anyway. For example, a Google image search might
52 // show the corpus "Images:" plus a search string. This is only used on
53 // mobile.
54 virtual base::string16 GetCorpusNameForMobile() const = 0;
56 // Returns the URL of the current navigation entry.
57 virtual GURL GetURL() const = 0;
59 // Returns true if a call to GetText() would successfully replace the URL
60 // with search terms. If |ignore_editing| is true, the result reflects the
61 // underlying state of the page without regard to any user edits that may be
62 // in progress in the omnibox.
63 virtual bool WouldPerformSearchTermReplacement(bool ignore_editing) const = 0;
65 // Returns true if a call to GetText() would return something other than the
66 // URL because of either search term replacement or URL omission in favor of
67 // the origin chip.
68 bool WouldReplaceURL() const;
70 // Returns the security level that the toolbar should display. If
71 // |ignore_editing| is true, the result reflects the underlying state of the
72 // page without regard to any user edits that may be in progress in the
73 // omnibox.
74 virtual SecurityLevel GetSecurityLevel(bool ignore_editing) const = 0;
76 // Returns the resource_id of the icon to show to the left of the address,
77 // based on the current URL. When search term replacement is active, this
78 // returns a search icon. This doesn't cover specialized icons while the
79 // user is editing; see OmniboxView::GetIcon().
80 virtual int GetIcon() const = 0;
82 // As |GetIcon()|, but returns the icon only taking into account the security
83 // |level| given, ignoring search term replacement state.
84 virtual int GetIconForSecurityLevel(SecurityLevel level) const = 0;
86 // Returns the name of the EV cert holder. Only call this when the security
87 // level is EV_SECURE.
88 virtual base::string16 GetEVCertName() const = 0;
90 // Returns whether the URL for the current navigation entry should be
91 // in the location bar.
92 virtual bool ShouldDisplayURL() const = 0;
94 // Returns true if a call to GetText() would return an empty string instead of
95 // the URL that would have otherwise been displayed because the host/origin is
96 // instead being displayed in the origin chip. This returns false when we
97 // wouldn't have displayed a URL to begin with (e.g. for the NTP).
98 virtual bool WouldOmitURLDueToOriginChip() const = 0;
100 // Whether the text in the omnibox is currently being edited.
101 void set_input_in_progress(bool input_in_progress) {
102 input_in_progress_ = input_in_progress;
104 bool input_in_progress() const { return input_in_progress_; }
106 // Whether the origin chip should be enabled.
107 void set_origin_chip_enabled(bool enabled) {
108 origin_chip_enabled_ = enabled;
110 bool origin_chip_enabled() const {
111 return origin_chip_enabled_;
114 // Whether URL replacement should be enabled.
115 void set_url_replacement_enabled(bool enabled) {
116 url_replacement_enabled_ = enabled;
118 bool url_replacement_enabled() const {
119 return url_replacement_enabled_;
122 protected:
123 ToolbarModel();
125 private:
126 bool input_in_progress_;
127 bool origin_chip_enabled_;
128 bool url_replacement_enabled_;
130 DISALLOW_COPY_AND_ASSIGN(ToolbarModel);
133 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_