• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_IMPL_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_IMPL_H_
7 
8 #include <string>
9 
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/strings/string16.h"
13 #include "chrome/browser/ui/toolbar/toolbar_model.h"
14 #include "url/gurl.h"
15 
16 class Profile;
17 class ToolbarModelDelegate;
18 
19 namespace content {
20 class NavigationController;
21 class WebContents;
22 }
23 
24 namespace net {
25 class X509Certificate;
26 }
27 
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 ToolbarModel {
32  public:
33   explicit ToolbarModelImpl(ToolbarModelDelegate* delegate);
34   virtual ~ToolbarModelImpl();
35 
36   static SecurityLevel GetSecurityLevelForWebContents(
37       content::WebContents* web_contents);
38 
39   // Returns "<organization_name> [<country>]".
40   static base::string16 GetEVCertName(const net::X509Certificate& cert);
41 
42  private:
43   // ToolbarModel:
44   virtual base::string16 GetText() const OVERRIDE;
45   virtual base::string16 GetCorpusNameForMobile() const OVERRIDE;
46   virtual GURL GetURL() const OVERRIDE;
47   virtual bool WouldOmitURLDueToOriginChip() const OVERRIDE;
48   virtual bool WouldPerformSearchTermReplacement(
49       bool ignore_editing) const OVERRIDE;
50   virtual SecurityLevel GetSecurityLevel(bool ignore_editing) const OVERRIDE;
51   virtual int GetIcon() const OVERRIDE;
52   virtual int GetIconForSecurityLevel(SecurityLevel level) const OVERRIDE;
53   virtual base::string16 GetEVCertName() const OVERRIDE;
54   virtual bool ShouldDisplayURL() const OVERRIDE;
55 
56   // Returns the navigation controller used to retrieve the navigation entry
57   // from which the states are retrieved.
58   // If this returns NULL, default values are used.
59   content::NavigationController* GetNavigationController() const;
60 
61   // Helper method to extract the profile from the navigation controller.
62   Profile* GetProfile() const;
63 
64   // Returns search terms as in chrome::GetSearchTerms() if such terms should
65   // appear in the omnibox (i.e. the page is sufficiently secure, search term
66   // replacement is enabled, editing is not in progress, etc.).  If
67   // |ignore_editing| is true, the "editing not in progress" check is skipped.
68   base::string16 GetSearchTerms(bool ignore_editing) const;
69 
70   ToolbarModelDelegate* delegate_;
71 
72   DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarModelImpl);
73 };
74 
75 #endif  // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_IMPL_H_
76