• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  // Copyright (c) 2010 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_H_
6  #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_
7  #pragma once
8  
9  #include <string>
10  
11  #include "base/basictypes.h"
12  
13  class Browser;
14  class NavigationController;
15  
16  // This class is the model used by the toolbar, location bar and autocomplete
17  // edit.  It populates its states from the current navigation entry retrieved
18  // from the navigation controller returned by GetNavigationController().
19  class ToolbarModel {
20   public:
21    // TODO(wtc): unify ToolbarModel::SecurityLevel with SecurityStyle.  We
22    // don't need two sets of security UI levels.  SECURITY_STYLE_AUTHENTICATED
23    // needs to be refined into three levels: warning, standard, and EV.
24    enum SecurityLevel {
25      NONE = 0,          // HTTP/no URL/user is editing
26      EV_SECURE,         // HTTPS with valid EV cert
27      SECURE,            // HTTPS (non-EV)
28      SECURITY_WARNING,  // HTTPS, but unable to check certificate revocation
29                         // status or with insecure content on the page
30      SECURITY_ERROR,    // Attempted HTTPS and failed, page not authenticated
31      NUM_SECURITY_LEVELS,
32    };
33  
34    explicit ToolbarModel(Browser* browser);
35    ~ToolbarModel();
36  
37    // Returns the text that should be displayed in the location bar.
38    std::wstring GetText() const;
39  
40    // Returns the security level that the toolbar should display.
41    SecurityLevel GetSecurityLevel() const;
42  
43    // Returns the resource_id of the icon to show to the left of the address,
44    // based on the current URL.  This doesn't cover specialized icons while the
45    // user is editing; see AutocompleteEditView::GetIcon().
46    int GetIcon() const;
47  
48    // Returns the name of the EV cert holder.  Only call this when the security
49    // level is EV_SECURE.
50    std::wstring GetEVCertName() const;
51  
52    // Getter/setter of whether the text in location bar is currently being
53    // edited.
set_input_in_progress(bool value)54    void set_input_in_progress(bool value) { input_in_progress_ = value; }
input_in_progress()55    bool input_in_progress() const { return input_in_progress_; }
56  
57   private:
58    // Returns the navigation controller used to retrieve the navigation entry
59    // from which the states are retrieved.
60    // If this returns NULL, default values are used.
61    NavigationController* GetNavigationController() const;
62  
63    Browser* browser_;
64  
65    // Whether the text in the location bar is currently being edited.
66    bool input_in_progress_;
67  
68    DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarModel);
69  };
70  
71  #endif  // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_
72