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_
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
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().
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.
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 for the current page's URL. This will have been formatted
35 // for display to the user:
36 // - Some characters may be unescaped.
37 // - The scheme and/or trailing slash may be dropped.
38 // - If the current page's URL is a search URL for the user's default search
39 // engine, the query will be extracted and returned for display instead
41 virtual base::string16
GetText() const = 0;
43 // Some search URLs bundle a special "corpus" param that we can extract and
44 // display next to users' search terms in cases where we'd show the search
45 // terms instead of the URL anyway. For example, a Google image search might
46 // show the corpus "Images:" plus a search string. This is only used on
48 virtual base::string16
GetCorpusNameForMobile() const = 0;
50 // Returns the URL of the current navigation entry.
51 virtual GURL
GetURL() const = 0;
53 // Returns true if a call to GetText() would successfully replace the URL
54 // with search terms. If |ignore_editing| is true, the result reflects the
55 // underlying state of the page without regard to any user edits that may be
56 // in progress in the omnibox.
57 virtual bool WouldPerformSearchTermReplacement(bool ignore_editing
) const = 0;
59 // Returns true if a call to GetText() would return something other than the
60 // URL because of either search term replacement or URL omission in favor of
62 bool WouldReplaceURL() const;
64 // Returns the security level that the toolbar should display. If
65 // |ignore_editing| is true, the result reflects the underlying state of the
66 // page without regard to any user edits that may be in progress in the
68 virtual SecurityLevel
GetSecurityLevel(bool ignore_editing
) const = 0;
70 // Returns the resource_id of the icon to show to the left of the address,
71 // based on the current URL. When search term replacement is active, this
72 // returns a search icon. This doesn't cover specialized icons while the
73 // user is editing; see OmniboxView::GetIcon().
74 virtual int GetIcon() const = 0;
76 // As |GetIcon()|, but returns the icon only taking into account the security
77 // |level| given, ignoring search term replacement state.
78 virtual int GetIconForSecurityLevel(SecurityLevel level
) const = 0;
80 // Returns the name of the EV cert holder. Only call this when the security
81 // level is EV_SECURE.
82 virtual base::string16
GetEVCertName() const = 0;
84 // Returns whether the URL for the current navigation entry should be
85 // in the location bar.
86 virtual bool ShouldDisplayURL() const = 0;
88 // Whether the text in the omnibox is currently being edited.
89 void set_input_in_progress(bool input_in_progress
) {
90 input_in_progress_
= input_in_progress
;
92 bool input_in_progress() const { return input_in_progress_
; }
94 // Whether URL replacement should be enabled.
95 void set_url_replacement_enabled(bool enabled
) {
96 url_replacement_enabled_
= enabled
;
98 bool url_replacement_enabled() const {
99 return url_replacement_enabled_
;
106 // Returns true if a call to GetText() would return an empty string instead of
107 // the URL that would have otherwise been displayed because the host/origin is
108 // instead being displayed in the origin chip. This returns false when we
109 // wouldn't have displayed a URL to begin with (e.g. for the NTP).
110 virtual bool WouldOmitURLDueToOriginChip() const = 0;
112 bool input_in_progress_
;
113 bool url_replacement_enabled_
;
115 DISALLOW_COPY_AND_ASSIGN(ToolbarModel
);
118 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_