[email protected] | 69c579e | 2010-04-23 20:01:00 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
| 5 | #ifndef CHROME_BROWSER_TOOLBAR_MODEL_H__ |
| 6 | #define CHROME_BROWSER_TOOLBAR_MODEL_H__ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 8 | |
| 9 | #include <string> |
| 10 | |
| 11 | #include "base/basictypes.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 12 | |
[email protected] | b023ab0 | 2010-01-28 22:25:45 | [diff] [blame] | 13 | class Browser; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 14 | class NavigationController; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 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(). |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 19 | class ToolbarModel { |
| 20 | public: |
[email protected] | 69c579e | 2010-04-23 20:01:00 | [diff] [blame] | 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. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 24 | enum SecurityLevel { |
[email protected] | 69c579e | 2010-04-23 20:01:00 | [diff] [blame] | 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 |
[email protected] | b4e75c1 | 2010-05-18 18:28:48 | [diff] [blame] | 29 | // status or with insecure content on the page |
[email protected] | 69c579e | 2010-04-23 20:01:00 | [diff] [blame] | 30 | SECURITY_ERROR, // Attempted HTTPS and failed, page not authenticated |
| 31 | NUM_SECURITY_LEVELS, |
[email protected] | d4cafaf | 2009-06-25 03:06:28 | [diff] [blame] | 32 | }; |
| 33 | |
[email protected] | b023ab0 | 2010-01-28 22:25:45 | [diff] [blame] | 34 | explicit ToolbarModel(Browser* browser); |
| 35 | ~ToolbarModel(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 36 | |
| 37 | // Returns the text that should be displayed in the location bar. |
[email protected] | b023ab0 | 2010-01-28 22:25:45 | [diff] [blame] | 38 | std::wstring GetText() const; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 39 | |
| 40 | // Returns the security level that the toolbar should display. |
[email protected] | b023ab0 | 2010-01-28 22:25:45 | [diff] [blame] | 41 | SecurityLevel GetSecurityLevel() const; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 42 | |
[email protected] | 69c579e | 2010-04-23 20:01:00 | [diff] [blame] | 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; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 47 | |
[email protected] | 69c579e | 2010-04-23 20:01:00 | [diff] [blame] | 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; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 51 | |
| 52 | // Getter/setter of whether the text in location bar is currently being |
| 53 | // edited. |
[email protected] | b023ab0 | 2010-01-28 22:25:45 | [diff] [blame] | 54 | void set_input_in_progress(bool value) { input_in_progress_ = value; } |
| 55 | bool input_in_progress() const { return input_in_progress_; } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 56 | |
[email protected] | b023ab0 | 2010-01-28 22:25:45 | [diff] [blame] | 57 | private: |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 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. |
[email protected] | b023ab0 | 2010-01-28 22:25:45 | [diff] [blame] | 61 | NavigationController* GetNavigationController() const; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 62 | |
[email protected] | b023ab0 | 2010-01-28 22:25:45 | [diff] [blame] | 63 | Browser* browser_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 64 | |
| 65 | // Whether the text in the location bar is currently being edited. |
| 66 | bool input_in_progress_; |
| 67 | |
[email protected] | b023ab0 | 2010-01-28 22:25:45 | [diff] [blame] | 68 | DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarModel); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | #endif // CHROME_BROWSER_TOOLBAR_MODEL_H__ |