OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_COCOA_LOCATION_BAR_LOCATION_BAR_VIEW_MAC_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_LOCATION_BAR_VIEW_MAC_H_ |
6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_LOCATION_BAR_VIEW_MAC_H_ | 6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_LOCATION_BAR_VIEW_MAC_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #import <Cocoa/Cocoa.h> | 10 #import <Cocoa/Cocoa.h> |
11 | 11 |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/prefs/pref_member.h" | 15 #include "base/prefs/pref_member.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 17 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
18 #include "chrome/browser/ui/location_bar/location_bar.h" | 18 #include "chrome/browser/ui/location_bar/location_bar.h" |
19 #include "chrome/browser/ui/omnibox/chrome_omnibox_edit_controller.h" | 19 #include "chrome/browser/ui/omnibox/chrome_omnibox_edit_controller.h" |
20 #include "chrome/browser/ui/search/search_model_observer.h" | |
21 #include "components/content_settings/core/common/content_settings_types.h" | 20 #include "components/content_settings/core/common/content_settings_types.h" |
22 #include "components/ui/zoom/zoom_event_manager_observer.h" | 21 #include "components/ui/zoom/zoom_event_manager_observer.h" |
23 | 22 |
24 @class AutocompleteTextField; | 23 @class AutocompleteTextField; |
25 class CommandUpdater; | 24 class CommandUpdater; |
26 class ContentSettingDecoration; | 25 class ContentSettingDecoration; |
27 class EVBubbleDecoration; | 26 class EVBubbleDecoration; |
28 class KeywordHintDecoration; | 27 class KeywordHintDecoration; |
29 class LocationBarDecoration; | 28 class LocationBarDecoration; |
30 class LocationIconDecoration; | 29 class LocationIconDecoration; |
31 class ManagePasswordsDecoration; | 30 class ManagePasswordsDecoration; |
32 class MicSearchDecoration; | |
33 class PageActionDecoration; | 31 class PageActionDecoration; |
34 class Profile; | 32 class Profile; |
35 class SelectedKeywordDecoration; | 33 class SelectedKeywordDecoration; |
36 class StarDecoration; | 34 class StarDecoration; |
37 class TranslateDecoration; | 35 class TranslateDecoration; |
38 class ZoomDecoration; | 36 class ZoomDecoration; |
39 class ZoomDecorationTest; | 37 class ZoomDecorationTest; |
40 | 38 |
41 // A C++ bridge class that represents the location bar UI element to | 39 // A C++ bridge class that represents the location bar UI element to |
42 // the portable code. Wires up an OmniboxViewMac instance to | 40 // the portable code. Wires up an OmniboxViewMac instance to |
43 // the location bar text field, which handles most of the work. | 41 // the location bar text field, which handles most of the work. |
44 | 42 |
45 class LocationBarViewMac : public LocationBar, | 43 class LocationBarViewMac : public LocationBar, |
46 public LocationBarTesting, | 44 public LocationBarTesting, |
47 public ChromeOmniboxEditController, | 45 public ChromeOmniboxEditController, |
48 public SearchModelObserver, | |
49 public ui_zoom::ZoomEventManagerObserver { | 46 public ui_zoom::ZoomEventManagerObserver { |
50 public: | 47 public: |
51 LocationBarViewMac(AutocompleteTextField* field, | 48 LocationBarViewMac(AutocompleteTextField* field, |
52 CommandUpdater* command_updater, | 49 CommandUpdater* command_updater, |
53 Profile* profile, | 50 Profile* profile, |
54 Browser* browser); | 51 Browser* browser); |
55 ~LocationBarViewMac() override; | 52 ~LocationBarViewMac() override; |
56 | 53 |
57 // Overridden from LocationBar: | 54 // Overridden from LocationBar: |
58 void ShowFirstRunBubble() override; | 55 void ShowFirstRunBubble() override; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 content::WebContents* GetWebContents() override; | 162 content::WebContents* GetWebContents() override; |
166 | 163 |
167 NSImage* GetKeywordImage(const base::string16& keyword); | 164 NSImage* GetKeywordImage(const base::string16& keyword); |
168 | 165 |
169 AutocompleteTextField* GetAutocompleteTextField() { return field_; } | 166 AutocompleteTextField* GetAutocompleteTextField() { return field_; } |
170 | 167 |
171 ManagePasswordsDecoration* manage_passwords_decoration() { | 168 ManagePasswordsDecoration* manage_passwords_decoration() { |
172 return manage_passwords_decoration_.get(); | 169 return manage_passwords_decoration_.get(); |
173 } | 170 } |
174 | 171 |
175 // SearchModelObserver: | |
176 void ModelChanged(const SearchModel::State& old_state, | |
177 const SearchModel::State& new_state) override; | |
178 | |
179 Browser* browser() const { return browser_; } | 172 Browser* browser() const { return browser_; } |
180 | 173 |
181 // ZoomManagerObserver: | 174 // ZoomManagerObserver: |
182 // Updates the view for the zoom icon when default zoom levels change. | 175 // Updates the view for the zoom icon when default zoom levels change. |
183 void OnDefaultZoomLevelChanged() override; | 176 void OnDefaultZoomLevelChanged() override; |
184 | 177 |
185 private: | 178 private: |
186 friend ZoomDecorationTest; | 179 friend ZoomDecorationTest; |
187 | 180 |
188 // Posts |notification| to the default notification center. | 181 // Posts |notification| to the default notification center. |
(...skipping 23 matching lines...) Expand all Loading... |
212 void ShowFirstRunBubbleInternal(); | 205 void ShowFirstRunBubbleInternal(); |
213 | 206 |
214 // Updates the translate decoration in the omnibox with the current translate | 207 // Updates the translate decoration in the omnibox with the current translate |
215 // state. | 208 // state. |
216 void UpdateTranslateDecoration(); | 209 void UpdateTranslateDecoration(); |
217 | 210 |
218 // Updates the zoom decoration in the omnibox with the current zoom level. | 211 // Updates the zoom decoration in the omnibox with the current zoom level. |
219 // Returns whether any updates were made. | 212 // Returns whether any updates were made. |
220 bool UpdateZoomDecoration(bool default_zoom_changed); | 213 bool UpdateZoomDecoration(bool default_zoom_changed); |
221 | 214 |
222 // Updates the voice search decoration. Returns true if the visible state was | |
223 // changed. | |
224 bool UpdateMicSearchDecorationVisibility(); | |
225 | |
226 scoped_ptr<OmniboxViewMac> omnibox_view_; | 215 scoped_ptr<OmniboxViewMac> omnibox_view_; |
227 | 216 |
228 AutocompleteTextField* field_; // owned by tab controller | 217 AutocompleteTextField* field_; // owned by tab controller |
229 | 218 |
230 // A decoration that shows an icon to the left of the address. | 219 // A decoration that shows an icon to the left of the address. |
231 scoped_ptr<LocationIconDecoration> location_icon_decoration_; | 220 scoped_ptr<LocationIconDecoration> location_icon_decoration_; |
232 | 221 |
233 // A decoration that shows the keyword-search bubble on the left. | 222 // A decoration that shows the keyword-search bubble on the left. |
234 scoped_ptr<SelectedKeywordDecoration> selected_keyword_decoration_; | 223 scoped_ptr<SelectedKeywordDecoration> selected_keyword_decoration_; |
235 | 224 |
(...skipping 13 matching lines...) Expand all Loading... |
249 | 238 |
250 // Decorations for the installed Page Actions. | 239 // Decorations for the installed Page Actions. |
251 ScopedVector<PageActionDecoration> page_action_decorations_; | 240 ScopedVector<PageActionDecoration> page_action_decorations_; |
252 | 241 |
253 // The content blocked decorations. | 242 // The content blocked decorations. |
254 ScopedVector<ContentSettingDecoration> content_setting_decorations_; | 243 ScopedVector<ContentSettingDecoration> content_setting_decorations_; |
255 | 244 |
256 // Keyword hint decoration displayed on the right-hand side. | 245 // Keyword hint decoration displayed on the right-hand side. |
257 scoped_ptr<KeywordHintDecoration> keyword_hint_decoration_; | 246 scoped_ptr<KeywordHintDecoration> keyword_hint_decoration_; |
258 | 247 |
259 // The voice search icon. | |
260 scoped_ptr<MicSearchDecoration> mic_search_decoration_; | |
261 | |
262 // The right-hand-side button to manage passwords associated with a page. | 248 // The right-hand-side button to manage passwords associated with a page. |
263 scoped_ptr<ManagePasswordsDecoration> manage_passwords_decoration_; | 249 scoped_ptr<ManagePasswordsDecoration> manage_passwords_decoration_; |
264 | 250 |
265 Browser* browser_; | 251 Browser* browser_; |
266 | 252 |
267 // Used to change the visibility of the star decoration. | 253 // Used to change the visibility of the star decoration. |
268 BooleanPrefMember edit_bookmarks_enabled_; | 254 BooleanPrefMember edit_bookmarks_enabled_; |
269 | 255 |
270 // Indicates whether or not the location bar is currently visible. | 256 // Indicates whether or not the location bar is currently visible. |
271 bool location_bar_visible_; | 257 bool location_bar_visible_; |
272 | 258 |
273 // Used to schedule a task for the first run info bubble. | 259 // Used to schedule a task for the first run info bubble. |
274 base::WeakPtrFactory<LocationBarViewMac> weak_ptr_factory_; | 260 base::WeakPtrFactory<LocationBarViewMac> weak_ptr_factory_; |
275 | 261 |
276 DISALLOW_COPY_AND_ASSIGN(LocationBarViewMac); | 262 DISALLOW_COPY_AND_ASSIGN(LocationBarViewMac); |
277 }; | 263 }; |
278 | 264 |
279 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_LOCATION_BAR_VIEW_MAC_H_ | 265 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_LOCATION_BAR_VIEW_MAC_H_ |
OLD | NEW |