blob: 3a6dff716ef4afb4dd40f93c44a478d12403e26a [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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.commit09911bf2008-07-26 23:55:294
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]4604d1f42009-03-13 21:52:3212#include "webkit/glue/feed.h"
initial.commit09911bf2008-07-26 23:55:2913
14class NavigationController;
15class 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().
21class 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]4604d1f42009-03-13 21:52:3256 // Returns an array of available feeds.
57 virtual scoped_refptr<FeedList> GetFeedList();
58
initial.commit09911bf2008-07-26 23:55:2959 // 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__