| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_TOOLBAR_MODEL_H__ | 5 #ifndef CHROME_BROWSER_TOOLBAR_MODEL_H__ |
| 6 #define CHROME_BROWSER_TOOLBAR_MODEL_H__ | 6 #define CHROME_BROWSER_TOOLBAR_MODEL_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 | 11 |
| 12 class Browser; | 12 class Browser; |
| 13 class NavigationController; | 13 class NavigationController; |
| 14 class NavigationEntry; | 14 class NavigationEntry; |
| 15 | 15 |
| 16 // This class is the model used by the toolbar, location bar and autocomplete | 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 | 17 // edit. It populates its states from the current navigation entry retrieved |
| 18 // from the navigation controller returned by GetNavigationController(). | 18 // from the navigation controller returned by GetNavigationController(). |
| 19 class ToolbarModel { | 19 class ToolbarModel { |
| 20 public: | 20 public: |
| 21 enum SecurityLevel { | 21 enum SecurityLevel { |
| 22 SECURE = 0, | 22 NONE = 0, // HTTP/no URL/user is editing |
| 23 NORMAL, | 23 EV_SECURE, // HTTPS with valid EV cert |
| 24 INSECURE | 24 SECURE, // HTTPS (non-EV) |
| 25 }; | 25 SECURITY_WARNING, // HTTPS, but with mixed content on the page |
| 26 | 26 SECURITY_ERROR, // Attempted HTTPS and failed, page not authenticated |
| 27 enum Icon { | 27 NUM_SECURITY_LEVELS, |
| 28 NO_ICON = 0, | |
| 29 LOCK_ICON, | |
| 30 WARNING_ICON | |
| 31 }; | |
| 32 | |
| 33 enum InfoTextType { | |
| 34 INFO_NO_INFO = 0, | |
| 35 INFO_EV_TEXT, | |
| 36 }; | 28 }; |
| 37 | 29 |
| 38 explicit ToolbarModel(Browser* browser); | 30 explicit ToolbarModel(Browser* browser); |
| 39 ~ToolbarModel(); | 31 ~ToolbarModel(); |
| 40 | 32 |
| 41 // Returns the text that should be displayed in the location bar. | 33 // Returns the text that should be displayed in the location bar. |
| 42 // Default value: empty string. | |
| 43 std::wstring GetText() const; | 34 std::wstring GetText() const; |
| 44 | 35 |
| 45 // Returns the security level that the toolbar should display. | 36 // Returns the security level that the toolbar should display. |
| 46 // Default value: NORMAL. | |
| 47 SecurityLevel GetSecurityLevel() const; | 37 SecurityLevel GetSecurityLevel() const; |
| 48 | 38 |
| 49 // Returns the security level that should be used in the scheme part of the | 39 // Returns the resource_id of the icon to show to the left of the address. |
| 50 // displayed URL. If SECURE, then the scheme is painted in green. If | 40 int GetSecurityIcon() const; |
| 51 // INSECURE, it is painted in red and stricken-out. | |
| 52 // Default value: NORMAL. | |
| 53 SecurityLevel GetSchemeSecurityLevel() const; | |
| 54 | |
| 55 // Returns the icon that should be displayed on the right of the location bar. | |
| 56 // Default value: NO_ICON. | |
| 57 Icon GetIcon() const; | |
| 58 | 41 |
| 59 // Sets the text displayed in the info bubble that appears when the user | 42 // Sets the text displayed in the info bubble that appears when the user |
| 60 // hovers the mouse over the icon. | 43 // hovers the mouse over the icon. |
| 61 // Default value: empty string. | |
| 62 void GetIconHoverText(std::wstring* text) const; | 44 void GetIconHoverText(std::wstring* text) const; |
| 63 | 45 |
| 64 // Sets |text| to contain the text that should be displayed on the right of | 46 // Returns the text, if any, that should be displayed on the right of the |
| 65 // the location bar, and |tooltip| to the tooltip text that should be shown | 47 // location bar. |
| 66 // when the mouse hover over that info label. | 48 std::wstring GetSecurityInfoText() const; |
| 67 // Default value: NO_INFO and empty string for |text| and |tooltip|. | |
| 68 InfoTextType GetInfoText(std::wstring* text, std::wstring* tooltip) const; | |
| 69 | 49 |
| 70 // Getter/setter of whether the text in location bar is currently being | 50 // Getter/setter of whether the text in location bar is currently being |
| 71 // edited. | 51 // edited. |
| 72 void set_input_in_progress(bool value) { input_in_progress_ = value; } | 52 void set_input_in_progress(bool value) { input_in_progress_ = value; } |
| 73 bool input_in_progress() const { return input_in_progress_; } | 53 bool input_in_progress() const { return input_in_progress_; } |
| 74 | 54 |
| 75 private: | 55 private: |
| 76 // Returns the navigation controller used to retrieve the navigation entry | 56 // Returns the navigation controller used to retrieve the navigation entry |
| 77 // from which the states are retrieved. | 57 // from which the states are retrieved. |
| 78 // If this returns NULL, default values are used. | 58 // If this returns NULL, default values are used. |
| 79 NavigationController* GetNavigationController() const; | 59 NavigationController* GetNavigationController() const; |
| 80 | 60 |
| 81 // Builds a short error message from the SSL status code found in |entry|. | 61 // Builds a short error message from the SSL status code found in |entry|. |
| 82 // The message is set in |text|. | 62 // The message is set in |text|. |
| 83 void CreateErrorText(NavigationEntry* entry, std::wstring* text) const; | 63 void CreateErrorText(NavigationEntry* entry, std::wstring* text) const; |
| 84 | 64 |
| 85 Browser* browser_; | 65 Browser* browser_; |
| 86 | 66 |
| 87 // Whether the text in the location bar is currently being edited. | 67 // Whether the text in the location bar is currently being edited. |
| 88 bool input_in_progress_; | 68 bool input_in_progress_; |
| 89 | 69 |
| 90 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarModel); | 70 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarModel); |
| 91 }; | 71 }; |
| 92 | 72 |
| 93 #endif // CHROME_BROWSER_TOOLBAR_MODEL_H__ | 73 #endif // CHROME_BROWSER_TOOLBAR_MODEL_H__ |
| OLD | NEW |