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

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: Avoid changing Mac edit field width when script badges disabled 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/location_bar_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/extensions/extension_popup.h" 41 #include "chrome/browser/ui/views/extensions/extension_popup.h"
41 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" 42 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 109
109 // Height of the location bar's round corner region. 110 // Height of the location bar's round corner region.
110 const int kBorderRoundCornerHeight = 5; 111 const int kBorderRoundCornerHeight = 5;
111 // Width of location bar's round corner region. 112 // Width of location bar's round corner region.
112 const int kBorderRoundCornerWidth = 4; 113 const int kBorderRoundCornerWidth = 4;
113 // Radius of the round corners inside the location bar. 114 // Radius of the round corners inside the location bar.
114 const int kBorderCornerRadius = 2; 115 const int kBorderCornerRadius = 2;
115 116
116 const int kDesktopItemPadding = 3; 117 const int kDesktopItemPadding = 3;
117 const int kDesktopEdgeItemPadding = kDesktopItemPadding; 118 const int kDesktopEdgeItemPadding = kDesktopItemPadding;
119 const int kDesktopScriptBadgeItemPadding = 9;
120 const int kDesktopScriptBadgeEdgeItemPadding = kDesktopScriptBadgeItemPadding;
118 121
119 const int kTouchItemPadding = 8; 122 const int kTouchItemPadding = 8;
120 const int kTouchEdgeItemPadding = kTouchItemPadding; 123 const int kTouchEdgeItemPadding = kTouchItemPadding;
121 124
122 // Extra padding for the height of the omnibox in search mode. 125 // Extra padding for the height of the omnibox in search mode.
123 const int kSearchEditHeightPadding = 2; 126 const int kSearchEditHeightPadding = 2;
124 127
125 } // namespace 128 } // namespace
126 129
127 // static 130 // static
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 378 }
376 379
377 default: 380 default:
378 NOTREACHED(); 381 NOTREACHED();
379 return GetColor(security_level, TEXT); 382 return GetColor(security_level, TEXT);
380 } 383 }
381 } 384 }
382 385
383 // static 386 // static
384 int LocationBarView::GetItemPadding() { 387 int LocationBarView::GetItemPadding() {
385 return (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) ? 388 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH)
386 kTouchItemPadding : kDesktopItemPadding; 389 return kTouchItemPadding;
390 return extensions::switch_utils::AreScriptBadgesEnabled() ?
391 kDesktopScriptBadgeItemPadding : kDesktopItemPadding;
387 } 392 }
388 393
389 // static 394 // static
390 int LocationBarView::GetEdgeItemPadding() { 395 int LocationBarView::GetEdgeItemPadding() {
391 return (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) ? 396 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH)
392 kTouchEdgeItemPadding : kDesktopEdgeItemPadding; 397 return kTouchEdgeItemPadding;
398 return extensions::switch_utils::AreScriptBadgesEnabled() ?
399 kDesktopScriptBadgeEdgeItemPadding : kDesktopEdgeItemPadding;
393 } 400 }
394 401
395 // DropdownBarHostDelegate 402 // DropdownBarHostDelegate
396 void LocationBarView::SetFocusAndSelection(bool select_all) { 403 void LocationBarView::SetFocusAndSelection(bool select_all) {
397 FocusLocation(select_all); 404 FocusLocation(select_all);
398 } 405 }
399 406
400 void LocationBarView::SetAnimationOffset(int offset) { 407 void LocationBarView::SetAnimationOffset(int offset) {
401 animation_offset_ = offset; 408 animation_offset_ = offset;
402 } 409 }
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 paint.setStyle(SkPaint::kFill_Style); 944 paint.setStyle(SkPaint::kFill_Style);
938 paint.setAntiAlias(true); 945 paint.setAntiAlias(true);
939 // TODO(jamescook): Make the corners of the dropdown match the corners of 946 // TODO(jamescook): Make the corners of the dropdown match the corners of
940 // the omnibox. 947 // the omnibox.
941 const SkScalar radius(SkIntToScalar(kBorderCornerRadius)); 948 const SkScalar radius(SkIntToScalar(kBorderCornerRadius));
942 bounds.Inset(kNormalHorizontalEdgeThickness, 0); 949 bounds.Inset(kNormalHorizontalEdgeThickness, 0);
943 canvas->sk_canvas()->drawRoundRect(gfx::RectToSkRect(bounds), radius, 950 canvas->sk_canvas()->drawRoundRect(gfx::RectToSkRect(bounds), radius,
944 radius, paint); 951 radius, paint);
945 if (action_box_button_view_) 952 if (action_box_button_view_)
946 PaintActionBoxBackground(canvas, bounds); 953 PaintActionBoxBackground(canvas, bounds);
954 PaintPageActionBackgrounds(canvas);
947 } else { 955 } else {
948 canvas->FillRect(bounds, color); 956 canvas->FillRect(bounds, color);
949 } 957 }
950 958
951 if (show_focus_rect_ && HasFocus()) { 959 if (show_focus_rect_ && HasFocus()) {
952 gfx::Rect r = location_entry_view_->bounds(); 960 gfx::Rect r = location_entry_view_->bounds();
953 // TODO(jamescook): Is this still needed? 961 // TODO(jamescook): Is this still needed?
954 #if defined(OS_WIN) 962 #if defined(OS_WIN)
955 r.Inset(-1, -1); 963 r.Inset(-1, -1);
956 #else 964 #else
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 bounds.set_width(kBorderCornerRadius); 1249 bounds.set_width(kBorderCornerRadius);
1242 canvas->DrawRect(bounds, paint); 1250 canvas->DrawRect(bounds, paint);
1243 1251
1244 // Draw left border. 1252 // Draw left border.
1245 gfx::Point line_end(bounds.origin()); 1253 gfx::Point line_end(bounds.origin());
1246 line_end.Offset(0, bounds.height()); 1254 line_end.Offset(0, bounds.height());
1247 canvas->DrawLine(bounds.origin(), line_end, 1255 canvas->DrawLine(bounds.origin(), line_end,
1248 action_box_button_view_->GetBorderColor()); 1256 action_box_button_view_->GetBorderColor());
1249 } 1257 }
1250 1258
1259 void LocationBarView::PaintPageActionBackgrounds(gfx::Canvas* canvas) {
1260 for (PageActionViews::const_iterator
1261 page_action_view = page_action_views_.begin();
1262 page_action_view != page_action_views_.end();
1263 ++page_action_view) {
1264 gfx::Rect bounds = (*page_action_view)->bounds();
1265 int horizontal_padding = GetItemPadding() -
1266 (*page_action_view)->GetBuiltInHorizontalPadding();
1267 // Make the bounding rectangle include the whole vertical range of the
1268 // location bar, and the mid-point pixels between adjacent page actions.
1269 //
1270 // For odd horizontal_paddings, "horizontal_padding + 1" includes the
1271 // mid-point between two page actions in the bounding rectangle. For even
1272 // paddings, the +1 is dropped, which is right since there is no pixel at
1273 // the mid-point.
1274 bounds.Inset(-(horizontal_padding + 1) / 2, 0);
1275 ToolbarModel::SecurityLevel security_level = model_->GetSecurityLevel();
1276 location_bar_util::PaintExtensionActionBackground(
1277 *(*page_action_view)->image_view()->page_action(),
1278 SessionID::IdForTab(GetTabContents()->web_contents()),
1279 canvas, bounds,
1280 GetColor(security_level, TEXT), GetColor(security_level, BACKGROUND));
1281 }
1282 }
1283
1251 std::string LocationBarView::GetClassName() const { 1284 std::string LocationBarView::GetClassName() const {
1252 return kViewClassName; 1285 return kViewClassName;
1253 } 1286 }
1254 1287
1255 bool LocationBarView::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { 1288 bool LocationBarView::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) {
1256 #if defined(OS_WIN) 1289 #if defined(OS_WIN)
1257 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { 1290 if (views::FocusManager::IsTabTraversalKeyEvent(event)) {
1258 if (location_entry_->model()->popup_model()->IsOpen()) { 1291 if (location_entry_->model()->popup_model()->IsOpen()) {
1259 // Return true so that the edit sees the tab and moves the selection. 1292 // Return true so that the edit sees the tab and moves the selection.
1260 return true; 1293 return true;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 } 1566 }
1534 1567
1535 void LocationBarView::CleanupFadeAnimation() { 1568 void LocationBarView::CleanupFadeAnimation() {
1536 // Since we're no longer animating we don't need our layer. 1569 // Since we're no longer animating we don't need our layer.
1537 SetPaintToLayer(false); 1570 SetPaintToLayer(false);
1538 // Bubble labels don't need a transparent background anymore. 1571 // Bubble labels don't need a transparent background anymore.
1539 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); 1572 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE);
1540 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); 1573 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE);
1541 } 1574 }
1542 #endif // USE_AURA 1575 #endif // USE_AURA
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698