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

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

Issue 92073003: [SiteChip] Draw site chip icon and site title. Drag support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" 48 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
49 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" 49 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
50 #include "chrome/browser/ui/views/location_bar/script_bubble_icon_view.h" 50 #include "chrome/browser/ui/views/location_bar/script_bubble_icon_view.h"
51 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" 51 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
52 #include "chrome/browser/ui/views/location_bar/star_view.h" 52 #include "chrome/browser/ui/views/location_bar/star_view.h"
53 #include "chrome/browser/ui/views/location_bar/translate_icon_view.h" 53 #include "chrome/browser/ui/views/location_bar/translate_icon_view.h"
54 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" 54 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
55 #include "chrome/browser/ui/views/location_bar/zoom_view.h" 55 #include "chrome/browser/ui/views/location_bar/zoom_view.h"
56 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 56 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
57 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" 57 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
58 #include "chrome/browser/ui/views/toolbar/site_chip_view.h"
58 #include "chrome/browser/ui/zoom/zoom_controller.h" 59 #include "chrome/browser/ui/zoom/zoom_controller.h"
59 #include "chrome/common/chrome_switches.h" 60 #include "chrome/common/chrome_switches.h"
60 #include "chrome/common/pref_names.h" 61 #include "chrome/common/pref_names.h"
61 #include "content/public/browser/notification_service.h" 62 #include "content/public/browser/notification_service.h"
62 #include "content/public/browser/render_widget_host_view.h" 63 #include "content/public/browser/render_widget_host_view.h"
63 #include "content/public/browser/web_contents.h" 64 #include "content/public/browser/web_contents.h"
64 #include "extensions/common/feature_switch.h" 65 #include "extensions/common/feature_switch.h"
65 #include "grit/generated_resources.h" 66 #include "grit/generated_resources.h"
66 #include "grit/theme_resources.h" 67 #include "grit/theme_resources.h"
67 #include "ui/base/accessibility/accessible_view_state.h" 68 #include "ui/base/accessibility/accessible_view_state.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 ime_inline_autocomplete_view_(NULL), 174 ime_inline_autocomplete_view_(NULL),
174 selected_keyword_view_(NULL), 175 selected_keyword_view_(NULL),
175 suggested_text_view_(NULL), 176 suggested_text_view_(NULL),
176 keyword_hint_view_(NULL), 177 keyword_hint_view_(NULL),
177 mic_search_view_(NULL), 178 mic_search_view_(NULL),
178 zoom_view_(NULL), 179 zoom_view_(NULL),
179 generated_credit_card_view_(NULL), 180 generated_credit_card_view_(NULL),
180 open_pdf_in_reader_view_(NULL), 181 open_pdf_in_reader_view_(NULL),
181 manage_passwords_icon_view_(NULL), 182 manage_passwords_icon_view_(NULL),
182 script_bubble_icon_view_(NULL), 183 script_bubble_icon_view_(NULL),
184 site_chip_view_(NULL),
183 translate_icon_view_(NULL), 185 translate_icon_view_(NULL),
184 star_view_(NULL), 186 star_view_(NULL),
185 is_popup_mode_(is_popup_mode), 187 is_popup_mode_(is_popup_mode),
186 show_focus_rect_(false), 188 show_focus_rect_(false),
187 template_url_service_(NULL), 189 template_url_service_(NULL),
188 animation_offset_(0), 190 animation_offset_(0),
189 weak_ptr_factory_(this) { 191 weak_ptr_factory_(this) {
190 const int kOmniboxBorderImages[] = IMAGE_GRID(IDR_OMNIBOX_BORDER); 192 const int kOmniboxBorderImages[] = IMAGE_GRID(IDR_OMNIBOX_BORDER);
191 const int kOmniboxPopupImages[] = IMAGE_GRID(IDR_OMNIBOX_POPUP_BORDER); 193 const int kOmniboxPopupImages[] = IMAGE_GRID(IDR_OMNIBOX_POPUP_BORDER);
192 background_border_painter_.reset( 194 background_border_painter_.reset(
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 GetOmniboxIcon(template_url->GetExtensionId()); 670 GetOmniboxIcon(template_url->GetExtensionId());
669 selected_keyword_view_->SetImage(image.AsImageSkia()); 671 selected_keyword_view_->SetImage(image.AsImageSkia());
670 selected_keyword_view_->set_is_extension_icon(true); 672 selected_keyword_view_->set_is_extension_icon(true);
671 } else { 673 } else {
672 selected_keyword_view_->SetImage( 674 selected_keyword_view_->SetImage(
673 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH))); 675 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)));
674 selected_keyword_view_->set_is_extension_icon(false); 676 selected_keyword_view_->set_is_extension_icon(false);
675 } 677 }
676 } 678 }
677 } else if (GetToolbarModel()->GetSecurityLevel(false) == 679 } else if (GetToolbarModel()->GetSecurityLevel(false) ==
678 ToolbarModel::EV_SECURE) { 680 ToolbarModel::EV_SECURE && !site_chip_view_) {
Peter Kasting 2013/12/06 02:16:52 Nit: Parens around binary subexprs If you put the
Greg Billock 2013/12/06 19:54:26 won't quite. :-( But I think it's better re-ordere
679 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName()); 681 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName());
680 // The largest fraction of the omnibox that can be taken by the EV bubble. 682 // The largest fraction of the omnibox that can be taken by the EV bubble.
681 const double kMaxBubbleFraction = 0.5; 683 const double kMaxBubbleFraction = 0.5;
682 leading_decorations.AddDecoration(bubble_location_y, bubble_height, false, 684 leading_decorations.AddDecoration(bubble_location_y, bubble_height, false,
683 kMaxBubbleFraction, kBubblePadding, 685 kMaxBubbleFraction, kBubblePadding,
684 item_padding, 0, ev_bubble_view_); 686 item_padding, 0, ev_bubble_view_);
685 } else { 687 } else {
686 leading_decorations.AddDecoration( 688 leading_decorations.AddDecoration(
687 vertical_edge_thickness(), location_height, 689 vertical_edge_thickness(), location_height,
688 GetBuiltInHorizontalPaddingForChildViews(), 690 GetBuiltInHorizontalPaddingForChildViews(),
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 void LocationBarView::SetShowFocusRect(bool show) { 907 void LocationBarView::SetShowFocusRect(bool show) {
906 show_focus_rect_ = show; 908 show_focus_rect_ = show;
907 SchedulePaint(); 909 SchedulePaint();
908 } 910 }
909 911
910 void LocationBarView::SelectAll() { 912 void LocationBarView::SelectAll() {
911 omnibox_view_->SelectAll(true); 913 omnibox_view_->SelectAll(true);
912 } 914 }
913 915
914 views::ImageView* LocationBarView::GetLocationIconView() { 916 views::ImageView* LocationBarView::GetLocationIconView() {
917 if (site_chip_view_)
918 return site_chip_view_->location_icon_view();
919
915 return location_icon_view_; 920 return location_icon_view_;
916 } 921 }
917 922
918 const views::ImageView* LocationBarView::GetLocationIconView() const { 923 const views::ImageView* LocationBarView::GetLocationIconView() const {
924 if (site_chip_view_)
925 return site_chip_view_->location_icon_view();
926
919 return location_icon_view_; 927 return location_icon_view_;
920 } 928 }
921 929
922 views::View* LocationBarView::GetLocationBarAnchor() { 930 views::View* LocationBarView::GetLocationBarAnchor() {
923 return GetLocationIconView(); 931 return GetLocationIconView();
924 } 932 }
925 933
926 gfx::Point LocationBarView::GetLocationBarAnchorPoint() const { 934 gfx::Point LocationBarView::GetLocationBarAnchorPoint() const {
927 // The +1 in the next line creates a 1-px gap between icon and arrow tip. 935 // The +1 in the next line creates a 1-px gap between icon and arrow tip.
928 gfx::Point icon_bottom(0, GetLocationIconView()->GetImageBounds().bottom() - 936 gfx::Point icon_bottom(0, GetLocationIconView()->GetImageBounds().bottom() -
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 omnibox_view_->Update(); 976 omnibox_view_->Update();
969 977
970 OnChanged(); // NOTE: Calls Layout(). 978 OnChanged(); // NOTE: Calls Layout().
971 } 979 }
972 980
973 void LocationBarView::OnChanged() { 981 void LocationBarView::OnChanged() {
974 location_icon_view_->SetImage( 982 location_icon_view_->SetImage(
975 GetThemeProvider()->GetImageSkiaNamed(omnibox_view_->GetIcon())); 983 GetThemeProvider()->GetImageSkiaNamed(omnibox_view_->GetIcon()));
976 location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty()); 984 location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty());
977 985
986 if (site_chip_view_)
987 site_chip_view_->OnChanged();
988
978 Layout(); 989 Layout();
979 SchedulePaint(); 990 SchedulePaint();
980 } 991 }
981 992
982 void LocationBarView::OnSetFocus() { 993 void LocationBarView::OnSetFocus() {
983 GetFocusManager()->SetFocusedView(this); 994 GetFocusManager()->SetFocusedView(this);
984 } 995 }
985 996
986 InstantController* LocationBarView::GetInstant() { 997 InstantController* LocationBarView::GetInstant() {
987 return delegate_->GetInstant(); 998 return delegate_->GetInstant();
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 bounds.Inset(-(horizontal_padding + 1) / 2, 0); 1476 bounds.Inset(-(horizontal_padding + 1) / 2, 0);
1466 location_bar_util::PaintExtensionActionBackground( 1477 location_bar_util::PaintExtensionActionBackground(
1467 *(*page_action_view)->image_view()->page_action(), 1478 *(*page_action_view)->image_view()->page_action(),
1468 tab_id, canvas, bounds, text_color, background_color); 1479 tab_id, canvas, bounds, text_color, background_color);
1469 } 1480 }
1470 } 1481 }
1471 1482
1472 void LocationBarView::AccessibilitySetValue(const string16& new_value) { 1483 void LocationBarView::AccessibilitySetValue(const string16& new_value) {
1473 omnibox_view_->SetUserText(new_value, new_value, true); 1484 omnibox_view_->SetUserText(new_value, new_value, true);
1474 } 1485 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698