Chromium Code Reviews

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

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