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 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 #include "ui/compositor/scoped_layer_animation_settings.h" | 95 #include "ui/compositor/scoped_layer_animation_settings.h" |
96 #endif | 96 #endif |
97 | 97 |
98 using content::WebContents; | 98 using content::WebContents; |
99 using views::View; | 99 using views::View; |
100 | 100 |
101 namespace { | 101 namespace { |
102 | 102 |
103 Browser* GetBrowserFromDelegate(LocationBarView::Delegate* delegate) { | 103 Browser* GetBrowserFromDelegate(LocationBarView::Delegate* delegate) { |
104 WebContents* contents = delegate->GetWebContents(); | 104 WebContents* contents = delegate->GetWebContents(); |
105 return chrome::FindBrowserWithWebContents(contents); | 105 return contents ? chrome::FindBrowserWithWebContents(contents) : NULL; |
106 } | 106 } |
107 | 107 |
108 // Height of the location bar's round corner region. | 108 // Height of the location bar's round corner region. |
109 const int kBorderRoundCornerHeight = 5; | 109 const int kBorderRoundCornerHeight = 5; |
110 // Width of location bar's round corner region. | 110 // Width of location bar's round corner region. |
111 const int kBorderRoundCornerWidth = 4; | 111 const int kBorderRoundCornerWidth = 4; |
112 // Radius of the round corners inside the location bar. | 112 // Radius of the round corners inside the location bar. |
113 const int kBorderCornerRadius = 2; | 113 const int kBorderCornerRadius = 2; |
114 | 114 |
115 const int kDesktopItemPadding = 3; | 115 const int kDesktopItemPadding = 3; |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 ConvertPointToScreen(this, &screen_point); | 1273 ConvertPointToScreen(this, &screen_point); |
1274 omnibox_win->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); | 1274 omnibox_win->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); |
1275 } | 1275 } |
1276 } | 1276 } |
1277 #endif | 1277 #endif |
1278 | 1278 |
1279 void LocationBarView::ShowFirstRunBubbleInternal() { | 1279 void LocationBarView::ShowFirstRunBubbleInternal() { |
1280 #if !defined(OS_CHROMEOS) | 1280 #if !defined(OS_CHROMEOS) |
1281 // First run bubble doesn't make sense for Chrome OS. | 1281 // First run bubble doesn't make sense for Chrome OS. |
1282 Browser* browser = GetBrowserFromDelegate(delegate_); | 1282 Browser* browser = GetBrowserFromDelegate(delegate_); |
| 1283 if (!browser) |
| 1284 return; // Possible when browser is shutting down. |
| 1285 |
1283 FirstRunBubble::ShowBubble(browser, location_icon_view_); | 1286 FirstRunBubble::ShowBubble(browser, location_icon_view_); |
1284 #endif | 1287 #endif |
1285 } | 1288 } |
1286 | 1289 |
1287 void LocationBarView::PaintPageActionBackgrounds(gfx::Canvas* canvas) { | 1290 void LocationBarView::PaintPageActionBackgrounds(gfx::Canvas* canvas) { |
1288 WebContents* web_contents = GetWebContents(); | 1291 WebContents* web_contents = GetWebContents(); |
1289 // web_contents may be NULL while the browser is shutting down. | 1292 // web_contents may be NULL while the browser is shutting down. |
1290 if (!web_contents) | 1293 if (!web_contents) |
1291 return; | 1294 return; |
1292 | 1295 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1578 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
1576 int total_height = | 1579 int total_height = |
1577 use_preferred_size ? GetPreferredSize().height() : height(); | 1580 use_preferred_size ? GetPreferredSize().height() : height(); |
1578 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1581 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
1579 } | 1582 } |
1580 | 1583 |
1581 bool LocationBarView::HasValidSuggestText() const { | 1584 bool LocationBarView::HasValidSuggestText() const { |
1582 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1585 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
1583 !suggested_text_view_->text().empty(); | 1586 !suggested_text_view_->text().empty(); |
1584 } | 1587 } |
OLD | NEW |