license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 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. |
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__ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "base/basictypes.h" |
| 11 | #include "skia/include/SkColor.h" |
[email protected] | 4604d1f4 | 2009-03-13 21:52:32 | [diff] [blame] | 12 | #include "webkit/glue/feed.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | |
| 14 | class NavigationController; |
| 15 | class NavigationEntry; |
| 16 | |
| 17 | // This class is the model used by the toolbar, location bar and autocomplete |
| 18 | // edit. It populates its states from the current navigation entry retrieved |
| 19 | // from the navigation controller returned by GetNavigationController(). |
| 20 | // Sub-classes have only need to implement GetNavigationController(). |
| 21 | class ToolbarModel { |
| 22 | public: |
| 23 | enum SecurityLevel { |
| 24 | SECURE = 0, |
| 25 | NORMAL, |
| 26 | INSECURE |
| 27 | }; |
| 28 | |
| 29 | enum Icon { |
| 30 | NO_ICON = 0, |
| 31 | LOCK_ICON, |
| 32 | WARNING_ICON |
| 33 | }; |
| 34 | |
| 35 | ToolbarModel(); |
| 36 | ~ToolbarModel(); |
| 37 | |
| 38 | // Returns the text that should be displayed in the location bar. |
| 39 | // Default value: empty string. |
| 40 | virtual std::wstring GetText(); |
| 41 | |
| 42 | // Returns the security level that the toolbar should display. |
| 43 | // Default value: NORMAL. |
| 44 | virtual SecurityLevel GetSecurityLevel(); |
| 45 | |
| 46 | // Returns the security level that should be used in the scheme part of the |
| 47 | // displayed URL. If SECURE, then the scheme is painted in green. If |
| 48 | // INSECURE, it is painted in red and stricken-out. |
| 49 | // Default value: NORMAL. |
| 50 | virtual SecurityLevel GetSchemeSecurityLevel(); |
| 51 | |
| 52 | // Returns the icon that should be displayed on the right of the location bar. |
| 53 | // Default value: NO_ICON. |
| 54 | virtual Icon GetIcon(); |
| 55 | |
[email protected] | 4604d1f4 | 2009-03-13 21:52:32 | [diff] [blame] | 56 | // Returns an array of available feeds. |
| 57 | virtual scoped_refptr<FeedList> GetFeedList(); |
| 58 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 59 | // Sets the text and color of the text displayed in the info bubble that |
| 60 | // appears when the user hovers the mouse over the icon. |
| 61 | // Default value: empty string. |
| 62 | virtual void GetIconHoverText(std::wstring* text, SkColor* text_color); |
| 63 | |
| 64 | // Sets |text| to contain the text that should be displayed on the right of |
| 65 | // the location bar, and |tooltip| to the tooltip text that should be shown |
| 66 | // when the mouse hover over that info label. |
| 67 | // Default value: empty string. |
| 68 | virtual void GetInfoText(std::wstring* text, |
| 69 | SkColor* text_color, |
| 70 | std::wstring* tooltip); |
| 71 | |
| 72 | // Getter/setter of whether the text in location bar is currently being |
| 73 | // edited. |
| 74 | virtual void set_input_in_progress(bool value) { input_in_progress_ = value; } |
| 75 | virtual bool input_in_progress() const { return input_in_progress_; } |
| 76 | |
| 77 | protected: |
| 78 | // Returns the navigation controller used to retrieve the navigation entry |
| 79 | // from which the states are retrieved. |
| 80 | // If this returns NULL, default values are used. |
| 81 | virtual NavigationController* GetNavigationController() = 0; |
| 82 | |
| 83 | private: |
| 84 | // Builds a short error message from the SSL status code found in |entry|. |
| 85 | // The message is set in |text|. |
| 86 | void CreateErrorText(NavigationEntry* entry, std::wstring* text); |
| 87 | |
| 88 | // Whether the text in the location bar is currently being edited. |
| 89 | bool input_in_progress_; |
| 90 | |
| 91 | DISALLOW_EVIL_CONSTRUCTORS(ToolbarModel); |
| 92 | }; |
| 93 | |
| 94 | #endif // CHROME_BROWSER_TOOLBAR_MODEL_H__ |