Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_model.h

Issue 731423002: Remove OriginChip code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gyp file and bad merge Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 // Attempted HTTPS and failed, page not authenticated 48 // Attempted HTTPS and failed, page not authenticated
49 SECURITY_ERROR = 5, 49 SECURITY_ERROR = 5,
50 50
51 NUM_SECURITY_LEVELS = 6, 51 NUM_SECURITY_LEVELS = 6,
52 }; 52 };
53 53
54 virtual ~ToolbarModel(); 54 virtual ~ToolbarModel();
55 55
56 // Returns the text to be displayed in the toolbar for the current page. 56 // Returns the text to be displayed in the toolbar for the current page.
57 // The text is formatted in various ways: 57 // This will have been formatted for display to the user.
58 // - If the current page's URL is a search URL for the user's default search 58 // - If the current page's URL is a search URL for the user's default search
59 // engine, the query will be extracted and returned for display instead 59 // engine, the query will be extracted and returned for display instead
60 // of the URL. 60 // of the URL.
61 // - If the origin chip is enabled and visible, the text will be empty.
62 // - Otherwise, the text will contain the URL returned by GetFormattedURL(). 61 // - Otherwise, the text will contain the URL returned by GetFormattedURL().
63 virtual base::string16 GetText() const = 0; 62 virtual base::string16 GetText() const = 0;
64 63
65 // Returns a formatted URL for display in the toolbar. The formatting 64 // Returns a formatted URL for display in the toolbar. The formatting
66 // includes: 65 // includes:
67 // - Some characters may be unescaped. 66 // - Some characters may be unescaped.
68 // - The scheme and/or trailing slash may be dropped. 67 // - The scheme and/or trailing slash may be dropped.
69 // If |prefix_end| is non-NULL, it is set to the length of the pre-hostname 68 // If |prefix_end| is non-NULL, it is set to the length of the pre-hostname
70 // portion of the resulting URL. 69 // portion of the resulting URL.
71 virtual base::string16 GetFormattedURL(size_t* prefix_end) const = 0; 70 virtual base::string16 GetFormattedURL(size_t* prefix_end) const = 0;
72 71
73 // Some search URLs bundle a special "corpus" param that we can extract and 72 // Some search URLs bundle a special "corpus" param that we can extract and
74 // display next to users' search terms in cases where we'd show the search 73 // display next to users' search terms in cases where we'd show the search
75 // terms instead of the URL anyway. For example, a Google image search might 74 // terms instead of the URL anyway. For example, a Google image search might
76 // show the corpus "Images:" plus a search string. This is only used on 75 // show the corpus "Images:" plus a search string. This is only used on
77 // mobile. 76 // mobile.
78 virtual base::string16 GetCorpusNameForMobile() const = 0; 77 virtual base::string16 GetCorpusNameForMobile() const = 0;
79 78
80 // Returns the URL of the current navigation entry. 79 // Returns the URL of the current navigation entry.
81 virtual GURL GetURL() const = 0; 80 virtual GURL GetURL() const = 0;
82 81
83 // Returns true if a call to GetText() would successfully replace the URL 82 // Returns true if a call to GetText() would successfully replace the URL
84 // with search terms. If |ignore_editing| is true, the result reflects the 83 // with search terms. If |ignore_editing| is true, the result reflects the
85 // underlying state of the page without regard to any user edits that may be 84 // underlying state of the page without regard to any user edits that may be
86 // in progress in the omnibox. 85 // in progress in the omnibox.
87 virtual bool WouldPerformSearchTermReplacement(bool ignore_editing) const = 0; 86 virtual bool WouldPerformSearchTermReplacement(bool ignore_editing) const = 0;
88 87
89 // Returns true if a call to GetText() would return something other than the 88 // Returns true if a call to GetText() would return something other than the
90 // URL because of either search term replacement or URL omission in favor of 89 // URL because of search term replacement.
91 // the origin chip.
92 bool WouldReplaceURL() const; 90 bool WouldReplaceURL() const;
93 91
94 // Returns the security level that the toolbar should display. If 92 // Returns the security level that the toolbar should display. If
95 // |ignore_editing| is true, the result reflects the underlying state of the 93 // |ignore_editing| is true, the result reflects the underlying state of the
96 // page without regard to any user edits that may be in progress in the 94 // page without regard to any user edits that may be in progress in the
97 // omnibox. 95 // omnibox.
98 virtual SecurityLevel GetSecurityLevel(bool ignore_editing) const = 0; 96 virtual SecurityLevel GetSecurityLevel(bool ignore_editing) const = 0;
99 97
100 // Returns the resource_id of the icon to show to the left of the address, 98 // Returns the resource_id of the icon to show to the left of the address,
101 // based on the current URL. When search term replacement is active, this 99 // based on the current URL. When search term replacement is active, this
102 // returns a search icon. This doesn't cover specialized icons while the 100 // returns a search icon. This doesn't cover specialized icons while the
103 // user is editing; see OmniboxView::GetIcon(). 101 // user is editing; see OmniboxView::GetIcon().
104 virtual int GetIcon() const = 0; 102 virtual int GetIcon() const = 0;
105 103
106 // As |GetIcon()|, but returns the icon only taking into account the security 104 // As |GetIcon()|, but returns the icon only taking into account the security
107 // |level| given, ignoring search term replacement state. 105 // |level| given, ignoring search term replacement state.
108 virtual int GetIconForSecurityLevel(SecurityLevel level) const = 0; 106 virtual int GetIconForSecurityLevel(SecurityLevel level) const = 0;
109 107
110 // Returns the name of the EV cert holder. This returns an empty string if 108 // Returns the name of the EV cert holder. This returns an empty string if
111 // the security level is not EV_SECURE. 109 // the security level is not EV_SECURE.
112 virtual base::string16 GetEVCertName() const = 0; 110 virtual base::string16 GetEVCertName() const = 0;
113 111
114 // Returns whether the URL for the current navigation entry should be 112 // Returns whether the URL for the current navigation entry should be
115 // in the location bar. 113 // in the location bar.
116 virtual bool ShouldDisplayURL() const = 0; 114 virtual bool ShouldDisplayURL() const = 0;
117 115
118 // Returns true if a call to GetText() would return an empty string instead of
119 // the URL that would have otherwise been displayed because the host/origin is
120 // instead being displayed in the origin chip. This returns false when we
121 // wouldn't have displayed a URL to begin with (e.g. for the NTP).
122 virtual bool WouldOmitURLDueToOriginChip() const = 0;
123
124 // Returns true if the origin should be shown based on the current state of
125 // the ToolbarModel.
126 bool ShouldShowOriginChip() const;
127
128 // Whether the text in the omnibox is currently being edited. 116 // Whether the text in the omnibox is currently being edited.
129 void set_input_in_progress(bool input_in_progress) { 117 void set_input_in_progress(bool input_in_progress) {
130 input_in_progress_ = input_in_progress; 118 input_in_progress_ = input_in_progress;
131 } 119 }
132 bool input_in_progress() const { return input_in_progress_; } 120 bool input_in_progress() const { return input_in_progress_; }
133 121
134 // Whether the origin chip should be enabled.
135 void set_origin_chip_enabled(bool enabled) {
136 origin_chip_enabled_ = enabled;
137 }
138 bool origin_chip_enabled() const {
139 return origin_chip_enabled_;
140 }
141
142 // Whether URL replacement should be enabled. 122 // Whether URL replacement should be enabled.
143 void set_url_replacement_enabled(bool enabled) { 123 void set_url_replacement_enabled(bool enabled) {
144 url_replacement_enabled_ = enabled; 124 url_replacement_enabled_ = enabled;
145 } 125 }
146 bool url_replacement_enabled() const { 126 bool url_replacement_enabled() const {
147 return url_replacement_enabled_; 127 return url_replacement_enabled_;
148 } 128 }
149 129
150 protected: 130 protected:
151 ToolbarModel(); 131 ToolbarModel();
152 132
153 private: 133 private:
154 bool input_in_progress_; 134 bool input_in_progress_;
155 bool origin_chip_enabled_;
156 bool url_replacement_enabled_; 135 bool url_replacement_enabled_;
157 136
158 DISALLOW_COPY_AND_ASSIGN(ToolbarModel); 137 DISALLOW_COPY_AND_ASSIGN(ToolbarModel);
159 }; 138 };
160 139
161 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ 140 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/test_toolbar_model.cc ('k') | chrome/browser/ui/toolbar/toolbar_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698