| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_COMPACT_NAV_COMPACT_LOCATION_BAR_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_COMPACT_NAV_COMPACT_LOCATION_BAR_VIEW_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 10 #include "chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h" |
| 11 #include "chrome/browser/ui/views/dropdown_bar_view.h" |
| 12 #include "views/controls/button/button.h" |
| 13 #include "views/view.h" |
| 14 |
| 15 class Browser; |
| 16 class BrowserView; |
| 17 class CompactLocationBarViewHost; |
| 18 class LocationBarView; |
| 19 class ReloadButton; |
| 20 class TabContents; |
| 21 |
| 22 namespace views { |
| 23 class ImageButton; |
| 24 class NativeViewHost; |
| 25 } // namespace views |
| 26 |
| 27 // CompactLocationBarView is a version of location bar that is shown under a tab |
| 28 // for short period of time when Chrome is in the compact navigation bar mode. |
| 29 class CompactLocationBarView : public DropdownBarView, |
| 30 public views::ButtonListener, |
| 31 public AutocompleteEditController { |
| 32 public: |
| 33 explicit CompactLocationBarView(CompactLocationBarViewHost* host); |
| 34 virtual ~CompactLocationBarView(); |
| 35 |
| 36 // Claims focus for the text field and optionally selects its contents. |
| 37 virtual void SetFocusAndSelection(bool select_all); |
| 38 |
| 39 // Update the contained location bar to |contents|. |
| 40 void Update(const TabContents* contents); |
| 41 |
| 42 // Overridden from AccessiblePaneView |
| 43 virtual bool SetPaneFocus(int view_storage_id, View* initial_focus) OVERRIDE; |
| 44 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 45 |
| 46 LocationBarView* location_bar_view() { return location_bar_view_; } |
| 47 ReloadButton* reload_button() { return reload_button_; } |
| 48 |
| 49 private: |
| 50 Browser* browser() const; |
| 51 |
| 52 // Called when the view is added to the tree to initialize the |
| 53 // CompactLocationBarView. |
| 54 void Init(); |
| 55 |
| 56 // Overridden from views::View. |
| 57 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 58 virtual void OnPaint(gfx::Canvas* canvas); |
| 59 virtual void Layout() OVERRIDE; |
| 60 virtual void Paint(gfx::Canvas* canvas) OVERRIDE; |
| 61 virtual void ViewHierarchyChanged(bool is_add, views::View* parent, |
| 62 views::View* child) OVERRIDE; |
| 63 |
| 64 // No focus border for the location bar, the caret is enough. |
| 65 virtual void Focus(); |
| 66 virtual void PaintFocusBorder(gfx::Canvas* canvas) { } |
| 67 |
| 68 // Overridden from views::ButtonListener: |
| 69 virtual void ButtonPressed(views::Button* sender, |
| 70 const views::Event& event) OVERRIDE; |
| 71 |
| 72 // AutocompleteEditController implementation. |
| 73 virtual void OnAutocompleteAccept(const GURL& url, |
| 74 WindowOpenDisposition disposition, |
| 75 PageTransition::Type transition, |
| 76 const GURL& alternate_nav_url) OVERRIDE; |
| 77 virtual void OnChanged() OVERRIDE; |
| 78 virtual void OnSelectionBoundsChanged() OVERRIDE; |
| 79 virtual void OnKillFocus() OVERRIDE; |
| 80 virtual void OnSetFocus() OVERRIDE; |
| 81 virtual SkBitmap GetFavicon() const OVERRIDE; |
| 82 virtual void OnInputInProgress(bool in_progress) OVERRIDE; |
| 83 virtual string16 GetTitle() const OVERRIDE; |
| 84 virtual InstantController* GetInstant() OVERRIDE; |
| 85 virtual TabContentsWrapper* GetTabContentsWrapper() const OVERRIDE; |
| 86 |
| 87 CompactLocationBarViewHost* clb_host() { |
| 88 return static_cast<CompactLocationBarViewHost*>(host()); |
| 89 } |
| 90 |
| 91 ReloadButton* reload_button_; |
| 92 LocationBarView* location_bar_view_; |
| 93 // TODO(stevet): Add the BrowserActionsContainer back. |
| 94 |
| 95 // Font used by edit and some of the hints. |
| 96 gfx::Font font_; |
| 97 |
| 98 // True if we have already been initialized. |
| 99 bool initialized_; |
| 100 |
| 101 DISALLOW_COPY_AND_ASSIGN(CompactLocationBarView); |
| 102 }; |
| 103 |
| 104 #endif // CHROME_BROWSER_UI_VIEWS_COMPACT_NAV_COMPACT_LOCATION_BAR_VIEW_H_ |
| OLD | NEW |