Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / toolbar / toolbar_model.h
blobcdc704355118827ab564b8c59dd32130d87ce6c6
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 "chrome/browser/ssl/connection_security_helper.h"
13 #include "url/gurl.h"
15 namespace net {
16 class X509Certificate;
19 // This class is the model used by the toolbar, location bar and autocomplete
20 // edit. It populates its states from the current navigation entry retrieved
21 // from the navigation controller returned by GetNavigationController().
22 class ToolbarModel {
23 public:
24 virtual ~ToolbarModel();
26 // Returns the text to be displayed in the toolbar for the current page.
27 // This will have been formatted for display to the user.
28 // - If the current page's URL is a search URL for the user's default search
29 // engine, the query will be extracted and returned for display instead
30 // of the URL.
31 // - Otherwise, the text will contain the URL returned by GetFormattedURL().
32 virtual base::string16 GetText() const = 0;
34 // Returns a formatted URL for display in the toolbar. The formatting
35 // includes:
36 // - Some characters may be unescaped.
37 // - The scheme and/or trailing slash may be dropped.
38 // If |prefix_end| is non-NULL, it is set to the length of the pre-hostname
39 // portion of the resulting URL.
40 virtual base::string16 GetFormattedURL(size_t* prefix_end) const = 0;
42 // Some search URLs bundle a special "corpus" param that we can extract and
43 // display next to users' search terms in cases where we'd show the search
44 // terms instead of the URL anyway. For example, a Google image search might
45 // show the corpus "Images:" plus a search string. This is only used on
46 // mobile.
47 virtual base::string16 GetCorpusNameForMobile() const = 0;
49 // Returns the URL of the current navigation entry.
50 virtual GURL GetURL() const = 0;
52 // Returns true if a call to GetText() would successfully replace the URL
53 // with search terms. If |ignore_editing| is true, the result reflects the
54 // underlying state of the page without regard to any user edits that may be
55 // in progress in the omnibox.
56 virtual bool WouldPerformSearchTermReplacement(bool ignore_editing) const = 0;
58 // Returns true if a call to GetText() would return something other than the
59 // URL because of search term replacement.
60 bool WouldReplaceURL() const;
62 // Returns the security level that the toolbar should display. If
63 // |ignore_editing| is true, the result reflects the underlying state of the
64 // page without regard to any user edits that may be in progress in the
65 // omnibox.
66 virtual ConnectionSecurityHelper::SecurityLevel GetSecurityLevel(
67 bool ignore_editing) const = 0;
69 // Returns the resource_id of the icon to show to the left of the address,
70 // based on the current URL. When search term replacement is active, this
71 // returns a search icon. This doesn't cover specialized icons while the
72 // user is editing; see OmniboxView::GetIcon().
73 virtual int GetIcon() const = 0;
75 // As |GetIcon()|, but returns the icon only taking into account the security
76 // |level| given, ignoring search term replacement state.
77 virtual int GetIconForSecurityLevel(
78 ConnectionSecurityHelper::SecurityLevel level) const = 0;
80 // Returns the name of the EV cert holder. This returns an empty string if
81 // the security level is not 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_;
102 protected:
103 ToolbarModel();
105 private:
106 bool input_in_progress_;
107 bool url_replacement_enabled_;
109 DISALLOW_COPY_AND_ASSIGN(ToolbarModel);
112 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_