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

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: l10n str for ev ssl, 2 16x16 icons, etc. 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 gfx::Image image = extensions::OmniboxAPI::Get(profile_)-> 669 gfx::Image image = extensions::OmniboxAPI::Get(profile_)->
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 (!site_chip_view_ &&
678 ToolbarModel::EV_SECURE) { 680 (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE)) {
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 void LocationBarView::SetShowFocusRect(bool show) { 906 void LocationBarView::SetShowFocusRect(bool show) {
905 show_focus_rect_ = show; 907 show_focus_rect_ = show;
906 SchedulePaint(); 908 SchedulePaint();
907 } 909 }
908 910
909 void LocationBarView::SelectAll() { 911 void LocationBarView::SelectAll() {
910 omnibox_view_->SelectAll(true); 912 omnibox_view_->SelectAll(true);
911 } 913 }
912 914
913 views::ImageView* LocationBarView::GetLocationIconView() { 915 views::ImageView* LocationBarView::GetLocationIconView() {
914 return location_icon_view_; 916 return site_chip_view_ ? site_chip_view_->location_icon_view()
Peter Kasting 2013/12/10 19:44:31 Nit: Break after '?' instead of before ':' (2 plac
Greg Billock 2013/12/10 20:36:23 Done. Done.
917 : location_icon_view_;
915 } 918 }
916 919
917 const views::ImageView* LocationBarView::GetLocationIconView() const { 920 const views::ImageView* LocationBarView::GetLocationIconView() const {
918 return location_icon_view_; 921 return site_chip_view_ ? site_chip_view_->location_icon_view()
922 : location_icon_view_;
919 } 923 }
920 924
921 views::View* LocationBarView::GetLocationBarAnchor() { 925 views::View* LocationBarView::GetLocationBarAnchor() {
922 return GetLocationIconView(); 926 return GetLocationIconView();
923 } 927 }
924 928
925 gfx::Point LocationBarView::GetLocationBarAnchorPoint() const { 929 gfx::Point LocationBarView::GetLocationBarAnchorPoint() const {
926 // The +1 in the next line creates a 1-px gap between icon and arrow tip. 930 // The +1 in the next line creates a 1-px gap between icon and arrow tip.
927 gfx::Point icon_bottom(0, GetLocationIconView()->GetImageBounds().bottom() - 931 gfx::Point icon_bottom(0, GetLocationIconView()->GetImageBounds().bottom() -
928 LocationBarView::kIconInternalPadding + 1); 932 LocationBarView::kIconInternalPadding + 1);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 omnibox_view_->Update(); 971 omnibox_view_->Update();
968 972
969 OnChanged(); // NOTE: Calls Layout(). 973 OnChanged(); // NOTE: Calls Layout().
970 } 974 }
971 975
972 void LocationBarView::OnChanged() { 976 void LocationBarView::OnChanged() {
973 location_icon_view_->SetImage( 977 location_icon_view_->SetImage(
974 GetThemeProvider()->GetImageSkiaNamed(omnibox_view_->GetIcon())); 978 GetThemeProvider()->GetImageSkiaNamed(omnibox_view_->GetIcon()));
975 location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty()); 979 location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty());
976 980
981 if (site_chip_view_)
982 site_chip_view_->OnChanged();
983
977 Layout(); 984 Layout();
978 SchedulePaint(); 985 SchedulePaint();
979 } 986 }
980 987
981 void LocationBarView::OnSetFocus() { 988 void LocationBarView::OnSetFocus() {
982 GetFocusManager()->SetFocusedView(this); 989 GetFocusManager()->SetFocusedView(this);
983 } 990 }
984 991
985 InstantController* LocationBarView::GetInstant() { 992 InstantController* LocationBarView::GetInstant() {
986 return delegate_->GetInstant(); 993 return delegate_->GetInstant();
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 bounds.Inset(-(horizontal_padding + 1) / 2, 0); 1471 bounds.Inset(-(horizontal_padding + 1) / 2, 0);
1465 location_bar_util::PaintExtensionActionBackground( 1472 location_bar_util::PaintExtensionActionBackground(
1466 *(*page_action_view)->image_view()->page_action(), 1473 *(*page_action_view)->image_view()->page_action(),
1467 tab_id, canvas, bounds, text_color, background_color); 1474 tab_id, canvas, bounds, text_color, background_color);
1468 } 1475 }
1469 } 1476 }
1470 1477
1471 void LocationBarView::AccessibilitySetValue(const string16& new_value) { 1478 void LocationBarView::AccessibilitySetValue(const string16& new_value) {
1472 omnibox_view_->SetUserText(new_value, new_value, true); 1479 omnibox_view_->SetUserText(new_value, new_value, true);
1473 } 1480 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698