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