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

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

Issue 2805070: [Mac] First part of Omnibox decoration refactor. Enable ev bubble. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: comment clarification Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include <string> 8 #include <string>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
11 11
12 #import <Cocoa/Cocoa.h> 12 #import <Cocoa/Cocoa.h>
13 13
14 #include "base/scoped_nsobject.h" 14 #include "base/scoped_nsobject.h"
15 #include "base/scoped_ptr.h" 15 #include "base/scoped_ptr.h"
16 #include "base/scoped_vector.h" 16 #include "base/scoped_vector.h"
17 #include "chrome/browser/autocomplete/autocomplete_edit.h" 17 #include "chrome/browser/autocomplete/autocomplete_edit.h"
18 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" 18 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
19 #include "chrome/browser/extensions/image_loading_tracker.h" 19 #include "chrome/browser/extensions/image_loading_tracker.h"
20 #include "chrome/browser/first_run.h" 20 #include "chrome/browser/first_run.h"
21 #include "chrome/browser/location_bar.h" 21 #include "chrome/browser/location_bar.h"
22 #include "chrome/browser/toolbar_model.h" 22 #include "chrome/browser/toolbar_model.h"
23 #include "chrome/common/content_settings_types.h" 23 #include "chrome/common/content_settings_types.h"
24 #include "third_party/skia/include/core/SkBitmap.h" 24 #include "third_party/skia/include/core/SkBitmap.h"
25 25
26 @class AutocompleteTextField; 26 @class AutocompleteTextField;
27 class CommandUpdater; 27 class CommandUpdater;
28 class ContentSettingImageModel; 28 class ContentSettingImageModel;
29 class EVBubbleDecoration;
29 @class ExtensionPopupController; 30 @class ExtensionPopupController;
31 class LocationIconDecoration;
30 class Profile; 32 class Profile;
33 class SelectedKeywordDecoration;
31 class ToolbarModel; 34 class ToolbarModel;
32 35
33 // A C++ bridge class that represents the location bar UI element to 36 // A C++ bridge class that represents the location bar UI element to
34 // the portable code. Wires up an AutocompleteEditViewMac instance to 37 // the portable code. Wires up an AutocompleteEditViewMac instance to
35 // the location bar text field, which handles most of the work. 38 // the location bar text field, which handles most of the work.
36 39
37 class LocationBarViewMac : public AutocompleteEditController, 40 class LocationBarViewMac : public AutocompleteEditController,
38 public LocationBar, 41 public LocationBar,
39 public LocationBarTesting, 42 public LocationBarTesting,
40 public NotificationObserver { 43 public NotificationObserver {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void SetStarred(bool starred); 87 void SetStarred(bool starred);
85 88
86 // Get the point on the star for the bookmark bubble to aim at. 89 // Get the point on the star for the bookmark bubble to aim at.
87 NSPoint GetBookmarkBubblePoint() const; 90 NSPoint GetBookmarkBubblePoint() const;
88 91
89 // Updates the location bar. Resets the bar's permanent text and 92 // Updates the location bar. Resets the bar's permanent text and
90 // security style, and if |should_restore_state| is true, restores 93 // security style, and if |should_restore_state| is true, restores
91 // saved state from the tab (for tab switching). 94 // saved state from the tab (for tab switching).
92 void Update(const TabContents* tab, bool should_restore_state); 95 void Update(const TabContents* tab, bool should_restore_state);
93 96
97 // Layout the various decorations which live in the field.
98 void Layout();
99
94 // Returns the current TabContents. 100 // Returns the current TabContents.
95 TabContents* GetTabContents() const; 101 TabContents* GetTabContents() const;
96 102
97 // Sets preview_enabled_ for the PageActionImageView associated with this 103 // Sets preview_enabled_ for the PageActionImageView associated with this
98 // |page_action|. If |preview_enabled|, the location bar will display the 104 // |page_action|. If |preview_enabled|, the location bar will display the
99 // PageAction icon even if it has not been activated by the extension. 105 // PageAction icon even if it has not been activated by the extension.
100 // This is used by the ExtensionInstalledBubble to preview what the icon 106 // This is used by the ExtensionInstalledBubble to preview what the icon
101 // will look like for the user upon installation of the extension. 107 // will look like for the user upon installation of the extension.
102 void SetPreviewEnabledPageAction(ExtensionAction* page_action, 108 void SetPreviewEnabledPageAction(ExtensionAction* page_action,
103 bool preview_enabled); 109 bool preview_enabled);
(...skipping 19 matching lines...) Expand all
123 virtual void OnChanged(); 129 virtual void OnChanged();
124 virtual void OnInputInProgress(bool in_progress); 130 virtual void OnInputInProgress(bool in_progress);
125 virtual void OnKillFocus(); 131 virtual void OnKillFocus();
126 virtual void OnSetFocus(); 132 virtual void OnSetFocus();
127 virtual SkBitmap GetFavIcon() const; 133 virtual SkBitmap GetFavIcon() const;
128 virtual std::wstring GetTitle() const; 134 virtual std::wstring GetTitle() const;
129 135
130 NSImage* GetTabButtonImage(); 136 NSImage* GetTabButtonImage();
131 AutocompleteTextField* GetAutocompleteTextField() { return field_; } 137 AutocompleteTextField* GetAutocompleteTextField() { return field_; }
132 138
133 // Internals of OnChanged(), pulled out for purposes of unit
134 // testing. Sets up |field| based on the parameters, which are
135 // pulled from edit_view->model().
136 static void OnChangedImpl(AutocompleteTextField* field,
137 const std::wstring& keyword,
138 const std::wstring& short_name,
139 const bool is_keyword_hint,
140 const bool is_extension_keyword,
141 NSImage* image);
142
143 // Overridden from NotificationObserver. 139 // Overridden from NotificationObserver.
144 virtual void Observe(NotificationType type, 140 virtual void Observe(NotificationType type,
145 const NotificationSource& source, 141 const NotificationSource& source,
146 const NotificationDetails& details); 142 const NotificationDetails& details);
147 143
148 // Used to display a clickable icon in the location bar. 144 // Used to display a clickable icon in the location bar.
149 class LocationBarImageView { 145 class LocationBarImageView {
150 public: 146 public:
151 explicit LocationBarImageView() : image_(nil), 147 explicit LocationBarImageView() : image_(nil),
152 label_(nil), 148 label_(nil),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 scoped_nsobject<NSImage> image_; 192 scoped_nsobject<NSImage> image_;
197 193
198 // The label shown next to the icon, or nil if none. 194 // The label shown next to the icon, or nil if none.
199 scoped_nsobject<NSAttributedString> label_; 195 scoped_nsobject<NSAttributedString> label_;
200 196
201 bool visible_; 197 bool visible_;
202 198
203 DISALLOW_COPY_AND_ASSIGN(LocationBarImageView); 199 DISALLOW_COPY_AND_ASSIGN(LocationBarImageView);
204 }; 200 };
205 201
206 // LocationIconView is used to display an icon to the left of the address.
207 class LocationIconView : public LocationBarImageView {
208 public:
209 explicit LocationIconView(LocationBarViewMac* owner);
210 virtual ~LocationIconView();
211
212 // Is draggable if the autocomplete edit view has not be changed.
213 virtual bool IsDraggable();
214
215 // Drag the URL and title from the current tab.
216 virtual NSPasteboard* GetDragPasteboard();
217
218 // Shows the page info dialog.
219 virtual void OnMousePressed(NSRect bounds);
220
221 private:
222 // The location bar view that owns us.
223 LocationBarViewMac* owner_;
224
225 DISALLOW_COPY_AND_ASSIGN(LocationIconView);
226 };
227
228 // Used to display the bookmark star in the RHS. 202 // Used to display the bookmark star in the RHS.
229 class StarIconView : public LocationBarImageView { 203 class StarIconView : public LocationBarImageView {
230 public: 204 public:
231 explicit StarIconView(CommandUpdater* command_updater); 205 explicit StarIconView(CommandUpdater* command_updater);
232 virtual ~StarIconView() {} 206 virtual ~StarIconView() {}
233 207
234 // Shows the bookmark bubble. 208 // Shows the bookmark bubble.
235 virtual void OnMousePressed(NSRect bounds); 209 virtual void OnMousePressed(NSRect bounds);
236 210
237 // Set the image and tooltip based on |starred|. 211 // Set the image and tooltip based on |starred|.
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 // The location bar view that owns us. 385 // The location bar view that owns us.
412 LocationBarViewMac* owner_; 386 LocationBarViewMac* owner_;
413 387
414 Profile* profile_; 388 Profile* profile_;
415 ToolbarModel* toolbar_model_; 389 ToolbarModel* toolbar_model_;
416 390
417 DISALLOW_COPY_AND_ASSIGN(PageActionViewList); 391 DISALLOW_COPY_AND_ASSIGN(PageActionViewList);
418 }; 392 };
419 393
420 private: 394 private:
421 // Sets the location icon we should be showing.
422 void SetIcon(int resource_id);
423
424 // Sets the label for the SSL state.
425 void SetSecurityLabel();
426
427 // Posts |notification| to the default notification center. 395 // Posts |notification| to the default notification center.
428 void PostNotification(NSString* notification); 396 void PostNotification(NSString* notification);
429 397
430 // Updates visibility of the content settings icons based on the current 398 // Updates visibility of the content settings icons based on the current
431 // tab contents state. 399 // tab contents state.
432 void RefreshContentSettingsViews(); 400 void RefreshContentSettingsViews();
433 401
434 void ShowFirstRunBubbleInternal(FirstRun::BubbleType bubble_type); 402 void ShowFirstRunBubbleInternal(FirstRun::BubbleType bubble_type);
435 403
436 scoped_ptr<AutocompleteEditViewMac> edit_view_; 404 scoped_ptr<AutocompleteEditViewMac> edit_view_;
437 405
438 CommandUpdater* command_updater_; // Weak, owned by Browser. 406 CommandUpdater* command_updater_; // Weak, owned by Browser.
439 407
440 AutocompleteTextField* field_; // owned by tab controller 408 AutocompleteTextField* field_; // owned by tab controller
441 409
442 // When we get an OnAutocompleteAccept notification from the autocomplete 410 // When we get an OnAutocompleteAccept notification from the autocomplete
443 // edit, we save the input string so we can give it back to the browser on 411 // edit, we save the input string so we can give it back to the browser on
444 // the LocationBar interface via GetInputString(). 412 // the LocationBar interface via GetInputString().
445 std::wstring location_input_; 413 std::wstring location_input_;
446 414
447 // The user's desired disposition for how their input should be opened. 415 // The user's desired disposition for how their input should be opened.
448 WindowOpenDisposition disposition_; 416 WindowOpenDisposition disposition_;
449 417
450 // A view that shows an icon to the left of the address. 418 // A decoration that shows an icon to the left of the address.
451 LocationIconView location_icon_view_; 419 scoped_ptr<LocationIconDecoration> location_icon_decoration_;
452 420
453 // Security info as text which floats left of the page actions. 421 // A decoration that shows the keyword-search bubble on the left.
454 LocationBarImageView security_label_view_; 422 scoped_ptr<SelectedKeywordDecoration> selected_keyword_decoration_;
423
424 // A decoration that shows a lock icon and ev-cert label in a bubble
425 // on the left.
426 scoped_ptr<EVBubbleDecoration> ev_bubble_decoration_;
455 427
456 // Bookmark star right of page actions. 428 // Bookmark star right of page actions.
457 StarIconView star_icon_view_; 429 StarIconView star_icon_view_;
458 430
459 // Any installed Page Actions. 431 // Any installed Page Actions.
460 PageActionViewList page_action_views_; 432 PageActionViewList page_action_views_;
461 433
462 // The content blocked views. 434 // The content blocked views.
463 ContentSettingViews content_setting_views_; 435 ContentSettingViews content_setting_views_;
464 436
(...skipping 12 matching lines...) Expand all
477 // Used to register for notifications received by NotificationObserver. 449 // Used to register for notifications received by NotificationObserver.
478 NotificationRegistrar registrar_; 450 NotificationRegistrar registrar_;
479 451
480 // Used to schedule a task for the first run info bubble. 452 // Used to schedule a task for the first run info bubble.
481 ScopedRunnableMethodFactory<LocationBarViewMac> first_run_bubble_; 453 ScopedRunnableMethodFactory<LocationBarViewMac> first_run_bubble_;
482 454
483 DISALLOW_COPY_AND_ASSIGN(LocationBarViewMac); 455 DISALLOW_COPY_AND_ASSIGN(LocationBarViewMac);
484 }; 456 };
485 457
486 #endif // CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ 458 #endif // CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698