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_IMPL_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_IMPL_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/strings/string16.h"
13 #include "chrome/browser/ui/toolbar/chrome_toolbar_model.h"
17 class ToolbarModelDelegate
;
20 class NavigationController
;
25 class X509Certificate
;
28 // This class is the model used by the toolbar, location bar and autocomplete
29 // edit. It populates its states from the current navigation entry retrieved
30 // from the navigation controller returned by GetNavigationController().
31 class ToolbarModelImpl
: public ChromeToolbarModel
{
33 explicit ToolbarModelImpl(ToolbarModelDelegate
* delegate
);
34 ~ToolbarModelImpl() override
;
38 base::string16
GetText() const override
;
39 base::string16
GetFormattedURL(size_t* prefix_end
) const override
;
40 base::string16
GetCorpusNameForMobile() const override
;
41 GURL
GetURL() const override
;
42 bool WouldPerformSearchTermReplacement(bool ignore_editing
) const override
;
43 SecurityStateModel::SecurityLevel
GetSecurityLevel(
44 bool ignore_editing
) const override
;
45 int GetIcon() const override
;
46 base::string16
GetEVCertName() const override
;
47 bool ShouldDisplayURL() const override
;
49 // As |GetIcon()|, but returns the icon only taking into account the security
50 // level| given, ignoring search term replacement state.
51 int GetIconForSecurityLevel(SecurityStateModel::SecurityLevel level
) const;
53 // Returns the navigation controller used to retrieve the navigation entry
54 // from which the states are retrieved.
55 // If this returns NULL, default values are used.
56 content::NavigationController
* GetNavigationController() const;
58 // Helper method to extract the profile from the navigation controller.
59 Profile
* GetProfile() const;
61 // Returns search terms as in search::GetSearchTerms() if such terms should
62 // appear in the omnibox (i.e. the page is sufficiently secure, search term
63 // replacement is enabled, editing is not in progress, etc.). If
64 // |ignore_editing| is true, the "editing not in progress" check is skipped.
65 base::string16
GetSearchTerms(bool ignore_editing
) const;
67 ToolbarModelDelegate
* delegate_
;
69 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarModelImpl
);
72 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_IMPL_H_