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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 10834279: Give request-to-act badges a grey background, and increase spacing to make it fit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Finish mac support; fix pkasting's comments Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
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 11 matching lines...) Expand all
22 #include "chrome/browser/extensions/tab_helper.h" 22 #include "chrome/browser/extensions/tab_helper.h"
23 #include "chrome/browser/favicon/favicon_tab_helper.h" 23 #include "chrome/browser/favicon/favicon_tab_helper.h"
24 #include "chrome/browser/prefs/pref_service.h" 24 #include "chrome/browser/prefs/pref_service.h"
25 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/search_engines/template_url.h" 26 #include "chrome/browser/search_engines/template_url.h"
27 #include "chrome/browser/search_engines/template_url_service.h" 27 #include "chrome/browser/search_engines/template_url_service.h"
28 #include "chrome/browser/search_engines/template_url_service_factory.h" 28 #include "chrome/browser/search_engines/template_url_service_factory.h"
29 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
30 #include "chrome/browser/ui/browser_finder.h" 30 #include "chrome/browser/ui/browser_finder.h"
31 #include "chrome/browser/ui/browser_tabstrip.h" 31 #include "chrome/browser/ui/browser_tabstrip.h"
32 #include "chrome/browser/ui/omnibox/extension_action_util.h"
32 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 33 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
33 #include "chrome/browser/ui/search/search.h" 34 #include "chrome/browser/ui/search/search.h"
34 #include "chrome/browser/ui/search/search_model.h" 35 #include "chrome/browser/ui/search/search_model.h"
35 #include "chrome/browser/ui/search/search_types.h" 36 #include "chrome/browser/ui/search/search_types.h"
36 #include "chrome/browser/ui/search/search_ui.h" 37 #include "chrome/browser/ui/search/search_ui.h"
37 #include "chrome/browser/ui/tab_contents/tab_contents.h" 38 #include "chrome/browser/ui/tab_contents/tab_contents.h"
38 #include "chrome/browser/ui/view_ids.h" 39 #include "chrome/browser/ui/view_ids.h"
39 #include "chrome/browser/ui/views/browser_dialogs.h" 40 #include "chrome/browser/ui/views/browser_dialogs.h"
40 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" 41 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h"
41 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" 42 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 108
108 // Height of the location bar's round corner region. 109 // Height of the location bar's round corner region.
109 const int kBorderRoundCornerHeight = 5; 110 const int kBorderRoundCornerHeight = 5;
110 // Width of location bar's round corner region. 111 // Width of location bar's round corner region.
111 const int kBorderRoundCornerWidth = 4; 112 const int kBorderRoundCornerWidth = 4;
112 // Radius of the round corners inside the location bar. 113 // Radius of the round corners inside the location bar.
113 const int kBorderCornerRadius = 2; 114 const int kBorderCornerRadius = 2;
114 115
115 const int kDesktopItemPadding = 3; 116 const int kDesktopItemPadding = 3;
116 const int kDesktopEdgeItemPadding = kDesktopItemPadding; 117 const int kDesktopEdgeItemPadding = kDesktopItemPadding;
118 const int kDesktopScriptBadgeItemPadding = 9;
119 const int kDesktopScriptBadgeEdgeItemPadding = kDesktopScriptBadgeItemPadding;
117 120
118 const int kTouchItemPadding = 8; 121 const int kTouchItemPadding = 8;
119 const int kTouchEdgeItemPadding = kTouchItemPadding; 122 const int kTouchEdgeItemPadding = kTouchItemPadding;
120 123
121 // Extra padding for the height of the omnibox in search mode. 124 // Extra padding for the height of the omnibox in search mode.
122 const int kSearchEditHeightPadding = 2; 125 const int kSearchEditHeightPadding = 2;
123 126
124 } // namespace 127 } // namespace
125 128
126 // static 129 // static
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 377 }
375 378
376 default: 379 default:
377 NOTREACHED(); 380 NOTREACHED();
378 return GetColor(security_level, TEXT); 381 return GetColor(security_level, TEXT);
379 } 382 }
380 } 383 }
381 384
382 // static 385 // static
383 int LocationBarView::GetItemPadding() { 386 int LocationBarView::GetItemPadding() {
384 return (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) ? 387 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH)
385 kTouchItemPadding : kDesktopItemPadding; 388 return kTouchItemPadding;
389 return extensions::switch_utils::AreScriptBadgesEnabled() ?
390 kDesktopScriptBadgeItemPadding : kDesktopItemPadding;
386 } 391 }
387 392
388 // static 393 // static
389 int LocationBarView::GetEdgeItemPadding() { 394 int LocationBarView::GetEdgeItemPadding() {
390 return (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) ? 395 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH)
391 kTouchEdgeItemPadding : kDesktopEdgeItemPadding; 396 return kTouchEdgeItemPadding;
397 return extensions::switch_utils::AreScriptBadgesEnabled() ?
398 kDesktopScriptBadgeEdgeItemPadding : kDesktopEdgeItemPadding;
392 } 399 }
393 400
394 // DropdownBarHostDelegate 401 // DropdownBarHostDelegate
395 void LocationBarView::SetFocusAndSelection(bool select_all) { 402 void LocationBarView::SetFocusAndSelection(bool select_all) {
396 FocusLocation(select_all); 403 FocusLocation(select_all);
397 } 404 }
398 405
399 void LocationBarView::SetAnimationOffset(int offset) { 406 void LocationBarView::SetAnimationOffset(int offset) {
400 animation_offset_ = offset; 407 animation_offset_ = offset;
401 } 408 }
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 paint.setStyle(SkPaint::kFill_Style); 942 paint.setStyle(SkPaint::kFill_Style);
936 paint.setAntiAlias(true); 943 paint.setAntiAlias(true);
937 // TODO(jamescook): Make the corners of the dropdown match the corners of 944 // TODO(jamescook): Make the corners of the dropdown match the corners of
938 // the omnibox. 945 // the omnibox.
939 const SkScalar radius(SkIntToScalar(kBorderCornerRadius)); 946 const SkScalar radius(SkIntToScalar(kBorderCornerRadius));
940 bounds.Inset(kNormalHorizontalEdgeThickness, 0); 947 bounds.Inset(kNormalHorizontalEdgeThickness, 0);
941 canvas->sk_canvas()->drawRoundRect(gfx::RectToSkRect(bounds), radius, 948 canvas->sk_canvas()->drawRoundRect(gfx::RectToSkRect(bounds), radius,
942 radius, paint); 949 radius, paint);
943 if (action_box_button_view_) 950 if (action_box_button_view_)
944 PaintActionBoxBackground(canvas, bounds); 951 PaintActionBoxBackground(canvas, bounds);
952 PaintPageActionBackgrounds(canvas);
945 } else { 953 } else {
946 canvas->FillRect(bounds, color); 954 canvas->FillRect(bounds, color);
947 } 955 }
948 956
949 if (show_focus_rect_ && HasFocus()) { 957 if (show_focus_rect_ && HasFocus()) {
950 gfx::Rect r = location_entry_view_->bounds(); 958 gfx::Rect r = location_entry_view_->bounds();
951 // TODO(jamescook): Is this still needed? 959 // TODO(jamescook): Is this still needed?
952 #if defined(OS_WIN) 960 #if defined(OS_WIN)
953 r.Inset(-1, -1); 961 r.Inset(-1, -1);
954 #else 962 #else
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 bounds.set_width(kBorderCornerRadius); 1248 bounds.set_width(kBorderCornerRadius);
1241 canvas->DrawRect(bounds, paint); 1249 canvas->DrawRect(bounds, paint);
1242 1250
1243 // Draw left border. 1251 // Draw left border.
1244 gfx::Point line_end(bounds.origin()); 1252 gfx::Point line_end(bounds.origin());
1245 line_end.Offset(0, bounds.height()); 1253 line_end.Offset(0, bounds.height());
1246 canvas->DrawLine(bounds.origin(), line_end, 1254 canvas->DrawLine(bounds.origin(), line_end,
1247 action_box_button_view_->GetBorderColor()); 1255 action_box_button_view_->GetBorderColor());
1248 } 1256 }
1249 1257
1258 void LocationBarView::PaintPageActionBackgrounds(gfx::Canvas* canvas) {
1259 for (PageActionViews::const_iterator
1260 page_action_view = page_action_views_.begin();
1261 page_action_view != page_action_views_.end();
1262 ++page_action_view) {
1263 gfx::Rect bounds = (*page_action_view)->bounds();
1264 int horizontal_padding = GetItemPadding() -
1265 (*page_action_view)->GetBuiltInHorizontalPadding();
1266 // Make the bounding rectangle include the whole vertical range of the
1267 // location bar, and the mid-point pixels between adjacent page actions.
1268 //
1269 // For odd horizontal_paddings, "horizontal_padding + 1" includes the
1270 // mid-point between two page actions in the bounding rectangle. For even
Peter Kasting 2012/09/11 22:27:47 Does this mean that the items' bounds might overla
Jeffrey Yasskin 2012/09/11 23:05:28 I believe this doesn't affect the code that detect
1271 // paddings, the +1 is dropped, which is right since there is no pixel at
1272 // the mid-point.
1273 bounds.Inset(-(horizontal_padding + 1) / 2, 0);
1274 ToolbarModel::SecurityLevel security_level = model_->GetSecurityLevel();
1275 extensions::PaintExtensionActionBackground(
1276 *(*page_action_view)->image_view()->page_action(),
1277 SessionID::IdForTab(GetTabContents()),
1278 canvas, bounds,
1279 GetColor(security_level, TEXT), GetColor(security_level, BACKGROUND));
1280 }
1281 }
1282
1250 std::string LocationBarView::GetClassName() const { 1283 std::string LocationBarView::GetClassName() const {
1251 return kViewClassName; 1284 return kViewClassName;
1252 } 1285 }
1253 1286
1254 bool LocationBarView::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { 1287 bool LocationBarView::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) {
1255 #if defined(OS_WIN) 1288 #if defined(OS_WIN)
1256 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { 1289 if (views::FocusManager::IsTabTraversalKeyEvent(event)) {
1257 if (location_entry_->model()->popup_model()->IsOpen()) { 1290 if (location_entry_->model()->popup_model()->IsOpen()) {
1258 // Return true so that the edit sees the tab and moves the selection. 1291 // Return true so that the edit sees the tab and moves the selection.
1259 return true; 1292 return true;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 } 1565 }
1533 1566
1534 void LocationBarView::CleanupFadeAnimation() { 1567 void LocationBarView::CleanupFadeAnimation() {
1535 // Since we're no longer animating we don't need our layer. 1568 // Since we're no longer animating we don't need our layer.
1536 SetPaintToLayer(false); 1569 SetPaintToLayer(false);
1537 // Bubble labels don't need a transparent background anymore. 1570 // Bubble labels don't need a transparent background anymore.
1538 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); 1571 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE);
1539 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); 1572 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE);
1540 } 1573 }
1541 #endif // USE_AURA 1574 #endif // USE_AURA
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698