Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / components / toolbar / toolbar_model.h
blobb592f300d961b4f274164ff07ad489861db12079
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 COMPONENTS_TOOLBAR_TOOLBAR_MODEL_H_
6 #define COMPONENTS_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 virtual ~ToolbarModel();
25 // Returns the text to be displayed in the toolbar for the current page.
26 // This will have been formatted for display to the user.
27 // - If the current page's URL is a search URL for the user's default search
28 // engine, the query will be extracted and returned for display instead
29 // of the URL.
30 // - Otherwise, the text will contain the URL returned by GetFormattedURL().
31 virtual base::string16 GetText() const = 0;
33 // Returns a formatted URL for display in the toolbar. The formatting
34 // includes:
35 // - Some characters may be unescaped.
36 // - The scheme and/or trailing slash may be dropped.
37 // If |prefix_end| is non-NULL, it is set to the length of the pre-hostname
38 // portion of the resulting URL.
39 virtual base::string16 GetFormattedURL(size_t* prefix_end) const = 0;
41 // Some search URLs bundle a special "corpus" param that we can extract and
42 // display next to users' search terms in cases where we'd show the search
43 // terms instead of the URL anyway. For example, a Google image search might
44 // show the corpus "Images:" plus a search string. This is only used on
45 // mobile.
46 virtual base::string16 GetCorpusNameForMobile() const = 0;
48 // Returns the URL of the current navigation entry.
49 virtual GURL GetURL() const = 0;
51 // Returns true if a call to GetText() would successfully replace the URL
52 // with search terms. If |ignore_editing| is true, the result reflects the
53 // underlying state of the page without regard to any user edits that may be
54 // in progress in the omnibox.
55 virtual bool WouldPerformSearchTermReplacement(bool ignore_editing) const = 0;
57 // Returns true if a call to GetText() would return something other than the
58 // URL because of search term replacement.
59 bool WouldReplaceURL() const;
61 // Returns the resource_id of the icon to show to the left of the address,
62 // based on the current URL. When search term replacement is active, this
63 // returns a search icon. This doesn't cover specialized icons while the
64 // user is editing; see OmniboxView::GetIcon().
65 virtual int GetIcon() const = 0;
67 // Returns the name of the EV cert holder. This returns an empty string if
68 // the security level is not EV_SECURE.
69 virtual base::string16 GetEVCertName() const = 0;
71 // Returns whether the URL for the current navigation entry should be
72 // in the location bar.
73 virtual bool ShouldDisplayURL() const = 0;
75 // Whether the text in the omnibox is currently being edited.
76 void set_input_in_progress(bool input_in_progress) {
77 input_in_progress_ = input_in_progress;
79 bool input_in_progress() const { return input_in_progress_; }
81 // Whether URL replacement should be enabled.
82 void set_url_replacement_enabled(bool enabled) {
83 url_replacement_enabled_ = enabled;
85 bool url_replacement_enabled() const {
86 return url_replacement_enabled_;
89 protected:
90 ToolbarModel();
92 private:
93 bool input_in_progress_;
94 bool url_replacement_enabled_;
96 DISALLOW_COPY_AND_ASSIGN(ToolbarModel);
99 #endif // COMPONENTS_TOOLBAR_TOOLBAR_MODEL_H_