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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 49 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
50 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 50 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
51 #include "chrome/browser/ui/views/location_bar/script_bubble_icon_view.h" | 51 #include "chrome/browser/ui/views/location_bar/script_bubble_icon_view.h" |
52 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 52 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
53 #include "chrome/browser/ui/views/location_bar/star_view.h" | 53 #include "chrome/browser/ui/views/location_bar/star_view.h" |
54 #include "chrome/browser/ui/views/location_bar/translate_icon_view.h" | 54 #include "chrome/browser/ui/views/location_bar/translate_icon_view.h" |
55 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | 55 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
56 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 56 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
57 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | 57 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
58 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" | 58 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
59 #include "chrome/browser/ui/views/toolbar/site_chip_view.h" | |
59 #include "chrome/browser/ui/zoom/zoom_controller.h" | 60 #include "chrome/browser/ui/zoom/zoom_controller.h" |
60 #include "chrome/common/chrome_switches.h" | 61 #include "chrome/common/chrome_switches.h" |
61 #include "chrome/common/pref_names.h" | 62 #include "chrome/common/pref_names.h" |
62 #include "content/public/browser/notification_service.h" | 63 #include "content/public/browser/notification_service.h" |
63 #include "content/public/browser/render_widget_host_view.h" | 64 #include "content/public/browser/render_widget_host_view.h" |
64 #include "content/public/browser/web_contents.h" | 65 #include "content/public/browser/web_contents.h" |
65 #include "extensions/common/feature_switch.h" | 66 #include "extensions/common/feature_switch.h" |
66 #include "grit/generated_resources.h" | 67 #include "grit/generated_resources.h" |
67 #include "grit/theme_resources.h" | 68 #include "grit/theme_resources.h" |
68 #include "ui/base/accessibility/accessible_view_state.h" | 69 #include "ui/base/accessibility/accessible_view_state.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 ime_inline_autocomplete_view_(NULL), | 177 ime_inline_autocomplete_view_(NULL), |
177 selected_keyword_view_(NULL), | 178 selected_keyword_view_(NULL), |
178 suggested_text_view_(NULL), | 179 suggested_text_view_(NULL), |
179 keyword_hint_view_(NULL), | 180 keyword_hint_view_(NULL), |
180 mic_search_view_(NULL), | 181 mic_search_view_(NULL), |
181 zoom_view_(NULL), | 182 zoom_view_(NULL), |
182 generated_credit_card_view_(NULL), | 183 generated_credit_card_view_(NULL), |
183 open_pdf_in_reader_view_(NULL), | 184 open_pdf_in_reader_view_(NULL), |
184 manage_passwords_icon_view_(NULL), | 185 manage_passwords_icon_view_(NULL), |
185 script_bubble_icon_view_(NULL), | 186 script_bubble_icon_view_(NULL), |
187 site_chip_view_(NULL), | |
186 translate_icon_view_(NULL), | 188 translate_icon_view_(NULL), |
187 star_view_(NULL), | 189 star_view_(NULL), |
188 search_button_(NULL), | 190 search_button_(NULL), |
189 is_popup_mode_(is_popup_mode), | 191 is_popup_mode_(is_popup_mode), |
190 show_focus_rect_(false), | 192 show_focus_rect_(false), |
191 template_url_service_(NULL), | 193 template_url_service_(NULL), |
192 animation_offset_(0), | 194 animation_offset_(0), |
193 weak_ptr_factory_(this) { | 195 weak_ptr_factory_(this) { |
194 const int kOmniboxBorderImages[] = IMAGE_GRID(IDR_OMNIBOX_BORDER); | 196 const int kOmniboxBorderImages[] = IMAGE_GRID(IDR_OMNIBOX_BORDER); |
195 const int kOmniboxPopupImages[] = IMAGE_GRID(IDR_OMNIBOX_POPUP_BORDER); | 197 const int kOmniboxPopupImages[] = IMAGE_GRID(IDR_OMNIBOX_POPUP_BORDER); |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 gfx::Image image = extensions::OmniboxAPI::Get(profile_)-> | 714 gfx::Image image = extensions::OmniboxAPI::Get(profile_)-> |
713 GetOmniboxIcon(template_url->GetExtensionId()); | 715 GetOmniboxIcon(template_url->GetExtensionId()); |
714 selected_keyword_view_->SetImage(image.AsImageSkia()); | 716 selected_keyword_view_->SetImage(image.AsImageSkia()); |
715 selected_keyword_view_->set_is_extension_icon(true); | 717 selected_keyword_view_->set_is_extension_icon(true); |
716 } else { | 718 } else { |
717 selected_keyword_view_->SetImage( | 719 selected_keyword_view_->SetImage( |
718 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH))); | 720 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH))); |
719 selected_keyword_view_->set_is_extension_icon(false); | 721 selected_keyword_view_->set_is_extension_icon(false); |
720 } | 722 } |
721 } | 723 } |
722 } else if (GetToolbarModel()->GetSecurityLevel(false) == | 724 } else if (!site_chip_view_ && |
723 ToolbarModel::EV_SECURE) { | 725 (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE)) { |
724 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName()); | 726 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName()); |
725 // The largest fraction of the omnibox that can be taken by the EV bubble. | 727 // The largest fraction of the omnibox that can be taken by the EV bubble. |
726 const double kMaxBubbleFraction = 0.5; | 728 const double kMaxBubbleFraction = 0.5; |
727 leading_decorations.AddDecoration(bubble_location_y, bubble_height, false, | 729 leading_decorations.AddDecoration(bubble_location_y, bubble_height, false, |
728 kMaxBubbleFraction, kBubblePadding, | 730 kMaxBubbleFraction, kBubblePadding, |
729 item_padding, 0, ev_bubble_view_); | 731 item_padding, 0, ev_bubble_view_); |
730 } else { | 732 } else { |
731 leading_decorations.AddDecoration( | 733 leading_decorations.AddDecoration( |
732 vertical_edge_thickness(), location_height, | 734 vertical_edge_thickness(), location_height, |
733 GetBuiltInHorizontalPaddingForChildViews(), | 735 GetBuiltInHorizontalPaddingForChildViews(), |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
962 void LocationBarView::SetShowFocusRect(bool show) { | 964 void LocationBarView::SetShowFocusRect(bool show) { |
963 show_focus_rect_ = show; | 965 show_focus_rect_ = show; |
964 SchedulePaint(); | 966 SchedulePaint(); |
965 } | 967 } |
966 | 968 |
967 void LocationBarView::SelectAll() { | 969 void LocationBarView::SelectAll() { |
968 omnibox_view_->SelectAll(true); | 970 omnibox_view_->SelectAll(true); |
969 } | 971 } |
970 | 972 |
971 views::ImageView* LocationBarView::GetLocationIconView() { | 973 views::ImageView* LocationBarView::GetLocationIconView() { |
972 return location_icon_view_; | 974 return site_chip_view_ ? |
msw
2013/12/11 21:54:44
I think this change will alter the point returned
Greg Billock
2013/12/11 22:34:08
Yep. That's the intention -- infobars will be draw
| |
975 site_chip_view_->location_icon_view() : location_icon_view_; | |
973 } | 976 } |
974 | 977 |
975 const views::ImageView* LocationBarView::GetLocationIconView() const { | 978 const views::ImageView* LocationBarView::GetLocationIconView() const { |
976 return location_icon_view_; | 979 return site_chip_view_ ? |
980 site_chip_view_->location_icon_view() : location_icon_view_; | |
977 } | 981 } |
978 | 982 |
979 views::View* LocationBarView::GetLocationBarAnchor() { | 983 views::View* LocationBarView::GetLocationBarAnchor() { |
980 return GetLocationIconView(); | 984 return GetLocationIconView(); |
981 } | 985 } |
982 | 986 |
983 gfx::Point LocationBarView::GetLocationBarAnchorPoint() const { | 987 gfx::Point LocationBarView::GetLocationBarAnchorPoint() const { |
984 // The +1 in the next line creates a 1-px gap between icon and arrow tip. | 988 // The +1 in the next line creates a 1-px gap between icon and arrow tip. |
985 gfx::Point icon_bottom(0, GetLocationIconView()->GetImageBounds().bottom() - | 989 gfx::Point icon_bottom(0, GetLocationIconView()->GetImageBounds().bottom() - |
986 LocationBarView::kIconInternalPadding + 1); | 990 LocationBarView::kIconInternalPadding + 1); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1040 ((conditions != chrome::DISPLAY_SEARCH_BUTTON_NEVER) && | 1044 ((conditions != chrome::DISPLAY_SEARCH_BUTTON_NEVER) && |
1041 (toolbar_model->WouldPerformSearchTermReplacement(true) || | 1045 (toolbar_model->WouldPerformSearchTermReplacement(true) || |
1042 ((conditions == chrome::DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP) && | 1046 ((conditions == chrome::DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP) && |
1043 toolbar_model->input_in_progress()))); | 1047 toolbar_model->input_in_progress()))); |
1044 search_button_->SetVisible(!is_popup_mode_ && meets_conditions); | 1048 search_button_->SetVisible(!is_popup_mode_ && meets_conditions); |
1045 search_button_->SetImage( | 1049 search_button_->SetImage( |
1046 views::Button::STATE_NORMAL, | 1050 views::Button::STATE_NORMAL, |
1047 *GetThemeProvider()->GetImageSkiaNamed((icon_id == IDR_OMNIBOX_SEARCH) ? | 1051 *GetThemeProvider()->GetImageSkiaNamed((icon_id == IDR_OMNIBOX_SEARCH) ? |
1048 IDR_OMNIBOX_SEARCH_BUTTON_LOUPE : IDR_OMNIBOX_SEARCH_BUTTON_ARROW)); | 1052 IDR_OMNIBOX_SEARCH_BUTTON_LOUPE : IDR_OMNIBOX_SEARCH_BUTTON_ARROW)); |
1049 | 1053 |
1054 if (site_chip_view_) | |
1055 site_chip_view_->OnChanged(); | |
1056 | |
1050 Layout(); | 1057 Layout(); |
1051 SchedulePaint(); | 1058 SchedulePaint(); |
1052 } | 1059 } |
1053 | 1060 |
1054 void LocationBarView::OnSetFocus() { | 1061 void LocationBarView::OnSetFocus() { |
1055 GetFocusManager()->SetFocusedView(this); | 1062 GetFocusManager()->SetFocusedView(this); |
1056 } | 1063 } |
1057 | 1064 |
1058 InstantController* LocationBarView::GetInstant() { | 1065 InstantController* LocationBarView::GetInstant() { |
1059 return delegate_->GetInstant(); | 1066 return delegate_->GetInstant(); |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1544 bounds.Inset(-(horizontal_padding + 1) / 2, 0); | 1551 bounds.Inset(-(horizontal_padding + 1) / 2, 0); |
1545 location_bar_util::PaintExtensionActionBackground( | 1552 location_bar_util::PaintExtensionActionBackground( |
1546 *(*page_action_view)->image_view()->page_action(), | 1553 *(*page_action_view)->image_view()->page_action(), |
1547 tab_id, canvas, bounds, text_color, background_color); | 1554 tab_id, canvas, bounds, text_color, background_color); |
1548 } | 1555 } |
1549 } | 1556 } |
1550 | 1557 |
1551 void LocationBarView::AccessibilitySetValue(const string16& new_value) { | 1558 void LocationBarView::AccessibilitySetValue(const string16& new_value) { |
1552 omnibox_view_->SetUserText(new_value, new_value, true); | 1559 omnibox_view_->SetUserText(new_value, new_value, true); |
1553 } | 1560 } |
OLD | NEW |