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

Unified Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 11416042: views: Change the LocationBarView delegate's API to GetWebContents(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed Created 8 years, 1 month 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/location_bar/location_bar_view.cc
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 03e3d4aded8ff19aa4ea5b1a46901f7ade401dda..1e8cb5558f6e658af561dfea0df48df2b394dbc1 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -101,16 +101,6 @@ using views::View;
namespace {
-WebContents* GetWebContentsFromDelegate(LocationBarView::Delegate* delegate) {
- const TabContents* tab_contents = delegate->GetTabContents();
- return tab_contents ? tab_contents->web_contents() : NULL;
-}
-
-Browser* GetBrowserFromDelegate(LocationBarView::Delegate* delegate) {
- WebContents* contents = GetWebContentsFromDelegate(delegate);
- return browser::FindBrowserWithWebContents(contents);
-}
-
// Height of the location bar's round corner region.
const int kBorderRoundCornerHeight = 5;
// Width of location bar's round corner region.
@@ -538,7 +528,7 @@ void LocationBarView::SetPreviewEnabledPageAction(ExtensionAction* page_action,
return;
DCHECK(page_action);
- WebContents* contents = GetWebContentsFromDelegate(delegate_);
+ WebContents* contents = delegate_->GetWebContents();
RefreshPageActionViews();
PageActionWithBadgeView* page_action_view =
@@ -591,10 +581,8 @@ void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) {
Layout();
SchedulePaint();
- if (can_show_bubble && zoom_view_->visible()) {
- ZoomBubbleView::ShowBubble(
- zoom_view_, GetWebContentsFromDelegate(delegate_), true);
- }
+ if (can_show_bubble && zoom_view_->visible())
+ ZoomBubbleView::ShowBubble(zoom_view_, delegate_->GetWebContents(), true);
}
void LocationBarView::RefreshZoomView() {
@@ -610,7 +598,7 @@ void LocationBarView::RefreshZoomView() {
void LocationBarView::ShowChromeToMobileBubble() {
chrome::ShowChromeToMobileBubbleView(action_box_button_view_,
- GetBrowserFromDelegate(delegate_));
+ browser::FindBrowserWithWebContents(delegate_->GetWebContents()));
Peter Kasting 2012/11/16 23:12:14 Nit: Move "action_box_button_view_," to a new 4-sp
}
gfx::Point LocationBarView::GetLocationEntryOrigin() const {
@@ -1142,11 +1130,11 @@ void LocationBarView::OnSetFocus() {
gfx::Image LocationBarView::GetFavicon() const {
return FaviconTabHelper::FromWebContents(
- delegate_->GetTabContents()->web_contents())->GetFavicon();
+ delegate_->GetWebContents())->GetFavicon();
}
string16 LocationBarView::GetTitle() const {
- return GetWebContentsFromDelegate(delegate_)->GetTitle();
+ return delegate_->GetWebContents()->GetTitle();
}
InstantController* LocationBarView::GetInstant() {
@@ -1154,7 +1142,8 @@ InstantController* LocationBarView::GetInstant() {
}
TabContents* LocationBarView::GetTabContents() const {
- return delegate_->GetTabContents();
+ return delegate_->GetWebContents() ?
+ TabContents::FromWebContents(delegate_->GetWebContents()) : NULL;
}
int LocationBarView::AvailableWidth(int location_bar_width) {
@@ -1208,7 +1197,7 @@ void LocationBarView::RefreshPageActionViews() {
std::vector<ExtensionAction*> new_page_actions;
- WebContents* contents = GetWebContentsFromDelegate(delegate_);
+ WebContents* contents = delegate_->GetWebContents();
if (contents) {
extensions::TabHelper* extensions_tab_helper =
extensions::TabHelper::FromWebContents(contents);
@@ -1278,7 +1267,8 @@ void LocationBarView::OnMouseEvent(const ui::MouseEvent& event, UINT msg) {
void LocationBarView::ShowFirstRunBubbleInternal() {
#if !defined(OS_CHROMEOS)
// First run bubble doesn't make sense for Chrome OS.
- Browser* browser = GetBrowserFromDelegate(delegate_);
+ Browser* browser = browser::FindBrowserWithWebContents(
Peter Kasting 2012/11/16 23:12:14 Tiny nit: Prefer to linebreak after '='
+ delegate_->GetWebContents());
FirstRunBubble::ShowBubble(browser, location_icon_view_);
#endif
}
@@ -1389,7 +1379,7 @@ void LocationBarView::WriteDragDataForView(views::View* sender,
int LocationBarView::GetDragOperationsForView(views::View* sender,
const gfx::Point& p) {
DCHECK((sender == location_icon_view_) || (sender == ev_bubble_view_));
- WebContents* web_contents = GetWebContentsFromDelegate(delegate_);
+ WebContents* web_contents = delegate_->GetWebContents();
return (web_contents && web_contents->GetURL().is_valid() &&
!GetLocationEntry()->IsEditingOrEmpty()) ?
(ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK) :
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | chrome/browser/ui/views/location_bar/zoom_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698