Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: chrome/browser/cocoa/location_bar_view_mac.h

Issue 264037: Refactor security-icon code to a more general form (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_COCOA_LOCATION_BAR_VIEW_MAC_H_ 5 #ifndef CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_
6 #define CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ 6 #define CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/scoped_nsobject.h" 10 #include "base/scoped_nsobject.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Internals of OnChanged(), pulled out for purposes of unit 77 // Internals of OnChanged(), pulled out for purposes of unit
78 // testing. Sets up |field| based on the parameters, which are 78 // testing. Sets up |field| based on the parameters, which are
79 // pulled from edit_view->model(). 79 // pulled from edit_view->model().
80 static void OnChangedImpl(AutocompleteTextField* field, 80 static void OnChangedImpl(AutocompleteTextField* field,
81 const std::wstring& keyword, 81 const std::wstring& keyword,
82 const std::wstring& short_name, 82 const std::wstring& short_name,
83 const bool is_keyword_hint, 83 const bool is_keyword_hint,
84 const bool show_search_hint, 84 const bool show_search_hint,
85 NSImage* image); 85 NSImage* image);
86 86
87 // Used to display a clickable icon in the location bar.
88 class LocationBarImageView {
89 public:
90 explicit LocationBarImageView() : image_(nil),
91 label_(nil),
92 visible_(false) {}
93 virtual ~LocationBarImageView() {}
94
95 // Sets the image.
96 void SetImage(NSImage* image);
97
98 // Sets the label text, font, and color. |text| may be nil; |color| and
99 // |font| are ignored if |text| is nil.
100 void SetLabel(NSString* text, NSFont* baseFont, NSColor* color);
101
102 // Sets the visibility. SetImage() should be called with a valid image
103 // before the visibility is set to |true|.
104 void SetVisible(bool visible);
105
106 const NSImage* GetImage() const { return image_; }
107 const NSAttributedString* GetLabel() const { return label_; }
108 bool IsVisible() const { return visible_; }
109
110 virtual bool OnMousePressed() = 0;
111
112 private:
113 scoped_nsobject<NSImage> image_;
114
115 // The label shown next to the icon, or nil if none.
116 scoped_nsobject<NSAttributedString> label_;
117
118 bool visible_;
119
120 DISALLOW_COPY_AND_ASSIGN(LocationBarImageView);
121 };
122
123 // SecurityImageView is used to display the lock or warning icon when the
124 // current URL's scheme is https.
125 class SecurityImageView : public LocationBarImageView {
126 public:
127 enum Image {
128 LOCK = 0,
129 WARNING
130 };
131
132 SecurityImageView(Profile* profile, ToolbarModel* model);
133 virtual ~SecurityImageView();
134
135 // Sets the image to the appropriate icon.
136 void SetImageShown(Image image);
137
138 // Shows the page info dialog.
139 virtual bool OnMousePressed();
140
141 private:
142 // The lock icon shown when using HTTPS. Loaded lazily, the first time it's
143 // needed.
144 scoped_nsobject<NSImage> lock_icon_;
145
146 // The warning icon shown when HTTPS is broken. Loaded lazily, the first
147 // time it's needed.
148 scoped_nsobject<NSImage> warning_icon_;
149
150 Profile* profile_;
151 ToolbarModel* model_;
152
153 DISALLOW_COPY_AND_ASSIGN(SecurityImageView);
154 };
155
87 private: 156 private:
88 // Set the SSL icon we should be showing. 157 // Sets the SSL icon we should be showing.
89 void SetSecurityIcon(ToolbarModel::Icon icon); 158 void SetSecurityIcon(ToolbarModel::Icon icon);
90 159
160 // Sets the label for the SSL icon.
161 void SetSecurityIconLabel();
162
91 scoped_ptr<AutocompleteEditViewMac> edit_view_; 163 scoped_ptr<AutocompleteEditViewMac> edit_view_;
92 164
93 CommandUpdater* command_updater_; // Weak, owned by Browser. 165 CommandUpdater* command_updater_; // Weak, owned by Browser.
94 166
95 AutocompleteTextField* field_; // owned by tab controller 167 AutocompleteTextField* field_; // owned by tab controller
96 168
97 // When we get an OnAutocompleteAccept notification from the autocomplete 169 // When we get an OnAutocompleteAccept notification from the autocomplete
98 // edit, we save the input string so we can give it back to the browser on 170 // edit, we save the input string so we can give it back to the browser on
99 // the LocationBar interface via GetInputString(). 171 // the LocationBar interface via GetInputString().
100 std::wstring location_input_; 172 std::wstring location_input_;
101 173
102 // The user's desired disposition for how their input should be opened. 174 // The user's desired disposition for how their input should be opened.
103 WindowOpenDisposition disposition_; 175 WindowOpenDisposition disposition_;
104 176
177 // The view that shows the lock/warning when in HTTPS mode.
178 SecurityImageView security_image_view_;
179
105 Profile* profile_; 180 Profile* profile_;
106 181
107 ToolbarModel* toolbar_model_; // Weak, owned by Browser. 182 ToolbarModel* toolbar_model_; // Weak, owned by Browser.
108 183
109 // Image used in drawing keyword hint. 184 // Image used in drawing keyword hint.
110 scoped_nsobject<NSImage> tab_button_image_; 185 scoped_nsobject<NSImage> tab_button_image_;
111 186
112 // The transition type to use for the navigation. 187 // The transition type to use for the navigation.
113 PageTransition::Type transition_; 188 PageTransition::Type transition_;
114 189
115 DISALLOW_COPY_AND_ASSIGN(LocationBarViewMac); 190 DISALLOW_COPY_AND_ASSIGN(LocationBarViewMac);
116 }; 191 };
117 192
118 #endif // CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ 193 #endif // CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/autocomplete_text_field_unittest_helper.h ('k') | chrome/browser/cocoa/location_bar_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698