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

Unified Diff: chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h

Issue 6913026: Compact Navigation prototype (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h
diff --git a/chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h b/chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h
new file mode 100755
index 0000000000000000000000000000000000000000..60ebb719a48867234e116467586f7ee66efb9123
--- /dev/null
+++ b/chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h
@@ -0,0 +1,136 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_COMPACT_NAV_COMPACT_LOCATION_BAR_VIEW_HOST_H_
+#define CHROME_BROWSER_UI_VIEWS_COMPACT_NAV_COMPACT_LOCATION_BAR_VIEW_HOST_H_
+
+#include "base/timer.h"
+#include "chrome/browser/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/views/dropdown_bar_host.h"
+#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
+#include "content/common/notification_observer.h"
+#include "content/common/notification_registrar.h"
+#include "ui/base/animation/animation.h"
+#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/rect.h"
+#include "views/controls/textfield/textfield.h"
sky 2011/05/03 18:38:32 Looks like some of your includes aren't needed (at
SteveT 2011/05/06 18:48:43 Done.
+
+class BrowserView;
+class CompactLocationBarView;
+class MouseObserver;
+class TabContents;
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// The CompactLocationBarViewHost implements the container window for the
+// floating location bar. It uses the appropriate implementation from
+// compact_location_bar_view_host.cc to draw its content and is
sky 2011/05/03 18:38:32 Nuke the part about compact_location_bar_view.cc.
SteveT 2011/05/06 18:48:43 Done.
+// responsible for showing, hiding, closing, and moving the window.
+//
+// There is one CompactLocationBarViewHost per BrowserView, and its state
+// is updated whenever the selected Tab is changed. The
+// CompactLocationBarViewHost is created when the BrowserView is attached
+// to the frame's Widget for the first time, and enabled/disabled
+// when the compact navigation bar is toggled.
+//
+////////////////////////////////////////////////////////////////////////////////
+class CompactLocationBarViewHost : public DropdownBarHost,
+ public TabStripModelObserver,
sky 2011/05/03 18:38:32 indentation is off.
SteveT 2011/05/06 18:48:43 Done.
+ public NotificationObserver,
+ public LocationBarView::Delegate {
+ public:
+ explicit CompactLocationBarViewHost(::BrowserView* browser_view);
sky 2011/05/03 18:38:32 Is the :: really needed there?
SteveT 2011/05/06 18:48:43 Nope. Sorry, that was a missed artifact from the o
+ virtual ~CompactLocationBarViewHost();
+
+ // LocationBarView::Delegate overrides
+ virtual TabContentsWrapper* GetTabContentsWrapper() const OVERRIDE;
+ virtual InstantController* GetInstant() OVERRIDE;
+ virtual void OnInputInProgress(bool in_progress) OVERRIDE;
+
+ // Returns the bounds to locale the compact location bar under the tab.
sky 2011/05/03 18:38:32 locale -> locate Also, document what coordinate sy
SteveT 2011/05/06 18:48:43 Done.
+ gfx::Rect GetBoundsUnderTab(int model_index) const;
+
+ // Updates the content and the position of the compact location bar.
+ // |model_index| is the index of the tab the compact location bar
+ // will be attached to and |animate| specifies if the location bar
+ // should animate when shown. The second version gets the actual |contents|
+ // instead of the |model_index|.
+ void Update(int model_index, bool animate);
sky 2011/05/03 18:38:32 Do these really need to be public? They seem like
SteveT 2011/05/06 18:48:43 Yeah - Update is called by BrowserView when it get
+ void Update(TabContents* contents, bool animate);
+
+ // (Re)Starts the popup timer that hides the popup after X seconds.
+ void StartAutoHideTimer();
+
+ // Cancels the popup timer.
+ void CancelAutoHideTimer();
+
+ // Enable/disable the compact location bar.
+ void SetEnabled(bool enabled);
+
+ // Overridden from NotificationObserver.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) OVERRIDE;
+
+ // Overridden from DropdownBarhost.
+ virtual void Show(bool animate) OVERRIDE;
+ virtual void Hide(bool animate) OVERRIDE;
+
+ // Overridden from views::AcceleratorTarget in DropdownBarHost class.
+ virtual bool AcceleratorPressed(
+ const views::Accelerator& accelerator) OVERRIDE;
+
+ // Overridden from DropdownBarHost class.
+ virtual gfx::Rect GetDialogPosition(
+ gfx::Rect avoid_overlapping_rect) OVERRIDE;
+ virtual void SetDialogPosition(const gfx::Rect& new_pos,
+ bool no_redraw) OVERRIDE;
+
+ // Overriden from TabStripModelObserver class.
+ virtual void TabInsertedAt(TabContentsWrapper* contents,
+ int index,
+ bool foreground) OVERRIDE;
+ virtual void TabClosingAt(TabStripModel* tab_strip_model,
+ TabContentsWrapper* contents,
+ int index) OVERRIDE;
+ virtual void TabSelectedAt(TabContentsWrapper* old_contents,
+ TabContentsWrapper* new_contents,
+ int index,
+ bool user_gesture) OVERRIDE;
+ virtual void TabMoved(TabContentsWrapper* contents,
+ int from_index,
+ int to_index) OVERRIDE;
+ virtual void TabChangedAt(TabContentsWrapper* contents, int index,
+ TabChangeType change_type) OVERRIDE;
+ virtual void TabReselected(int index) OVERRIDE;
+
+ CompactLocationBarView* GetCompactLocationBarView();
+
+ virtual void MoveWindowIfNecessary(const gfx::Rect& selection_rect,
+ bool no_redraw);
sky 2011/05/03 18:38:32 OVERRIDE and document where it comes from.
SteveT 2011/05/06 18:48:43 Not actually overridden from somewhere else, just
+
+ private:
+ friend class MouseObserver;
+ friend class CompactLocationBarViewHostTest;
+
+ bool HasFocus();
+ void HideCallback();
+ bool IsCurrentTabIndex(int index);
+ bool IsCurrentTab(TabContents* contents);
+
+ // We use this to be notified of the end of a page load so we can hide.
+ NotificationRegistrar registrar_;
+
+ // The index of the tab, in terms of the model, that the compact location bar
+ // is attached to.
+ int current_tab_model_index_;
+
+ scoped_ptr<base::OneShotTimer<CompactLocationBarViewHost> > auto_hide_timer_;
+
+ scoped_ptr<MouseObserver> mouse_observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(CompactLocationBarViewHost);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_COMPACT_NAV_COMPACT_LOCATION_BAR_HOST_H_

Powered by Google App Engine
This is Rietveld 408576698