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

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

Issue 287543002: Remove origin chip v1 and "hide on input" v2 behavior. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test compile Created 6 years, 7 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "chrome/browser/ui/views/location_bar/origin_chip_view.h" 54 #include "chrome/browser/ui/views/location_bar/origin_chip_view.h"
55 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" 55 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
56 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" 56 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
57 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" 57 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
58 #include "chrome/browser/ui/views/location_bar/star_view.h" 58 #include "chrome/browser/ui/views/location_bar/star_view.h"
59 #include "chrome/browser/ui/views/location_bar/translate_icon_view.h" 59 #include "chrome/browser/ui/views/location_bar/translate_icon_view.h"
60 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" 60 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
61 #include "chrome/browser/ui/views/location_bar/zoom_view.h" 61 #include "chrome/browser/ui/views/location_bar/zoom_view.h"
62 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 62 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
63 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" 63 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
64 #include "chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.h"
65 #include "chrome/browser/ui/zoom/zoom_controller.h" 64 #include "chrome/browser/ui/zoom/zoom_controller.h"
66 #include "chrome/common/chrome_switches.h" 65 #include "chrome/common/chrome_switches.h"
67 #include "chrome/common/pref_names.h" 66 #include "chrome/common/pref_names.h"
68 #include "content/public/browser/notification_service.h" 67 #include "content/public/browser/notification_service.h"
69 #include "content/public/browser/render_widget_host_view.h" 68 #include "content/public/browser/render_widget_host_view.h"
70 #include "content/public/browser/web_contents.h" 69 #include "content/public/browser/web_contents.h"
71 #include "extensions/browser/extension_system.h" 70 #include "extensions/browser/extension_system.h"
72 #include "extensions/common/feature_switch.h" 71 #include "extensions/common/feature_switch.h"
73 #include "extensions/common/permissions/permissions_data.h" 72 #include "extensions/common/permissions/permissions_data.h"
74 #include "grit/generated_resources.h" 73 #include "grit/generated_resources.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 Profile* profile, 196 Profile* profile,
198 CommandUpdater* command_updater, 197 CommandUpdater* command_updater,
199 Delegate* delegate, 198 Delegate* delegate,
200 bool is_popup_mode) 199 bool is_popup_mode)
201 : LocationBar(profile), 200 : LocationBar(profile),
202 OmniboxEditController(command_updater), 201 OmniboxEditController(command_updater),
203 browser_(browser), 202 browser_(browser),
204 omnibox_view_(NULL), 203 omnibox_view_(NULL),
205 delegate_(delegate), 204 delegate_(delegate),
206 origin_chip_view_(NULL), 205 origin_chip_view_(NULL),
207 toolbar_origin_chip_view_(NULL),
208 location_icon_view_(NULL), 206 location_icon_view_(NULL),
209 ev_bubble_view_(NULL), 207 ev_bubble_view_(NULL),
210 ime_inline_autocomplete_view_(NULL), 208 ime_inline_autocomplete_view_(NULL),
211 selected_keyword_view_(NULL), 209 selected_keyword_view_(NULL),
212 suggested_text_view_(NULL), 210 suggested_text_view_(NULL),
213 keyword_hint_view_(NULL), 211 keyword_hint_view_(NULL),
214 mic_search_view_(NULL), 212 mic_search_view_(NULL),
215 zoom_view_(NULL), 213 zoom_view_(NULL),
216 generated_credit_card_view_(NULL), 214 generated_credit_card_view_(NULL),
217 open_pdf_in_reader_view_(NULL), 215 open_pdf_in_reader_view_(NULL),
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 585
588 void LocationBarView::SetShowFocusRect(bool show) { 586 void LocationBarView::SetShowFocusRect(bool show) {
589 show_focus_rect_ = show; 587 show_focus_rect_ = show;
590 SchedulePaint(); 588 SchedulePaint();
591 } 589 }
592 590
593 void LocationBarView::SelectAll() { 591 void LocationBarView::SelectAll() {
594 omnibox_view_->SelectAll(true); 592 omnibox_view_->SelectAll(true);
595 } 593 }
596 594
597 views::ImageView* LocationBarView::GetLocationIconView() {
598 return toolbar_origin_chip_view_ ?
599 toolbar_origin_chip_view_->location_icon_view() : location_icon_view_;
600 }
601
602 const views::ImageView* LocationBarView::GetLocationIconView() const {
603 return toolbar_origin_chip_view_ ?
604 toolbar_origin_chip_view_->location_icon_view() : location_icon_view_;
605 }
606
607 views::View* LocationBarView::GetLocationBarAnchor() {
608 return GetLocationIconView();
609 }
610
611 gfx::Point LocationBarView::GetLocationBarAnchorPoint() const { 595 gfx::Point LocationBarView::GetLocationBarAnchorPoint() const {
612 // The +1 in the next line creates a 1-px gap between icon and arrow tip. 596 // The +1 in the next line creates a 1-px gap between icon and arrow tip.
613 gfx::Point icon_bottom(0, GetLocationIconView()->GetImageBounds().bottom() - 597 gfx::Point icon_bottom(0, location_icon_view_->GetImageBounds().bottom() -
614 LocationBarView::kIconInternalPadding + 1); 598 LocationBarView::kIconInternalPadding + 1);
615 gfx::Point icon_center(GetLocationIconView()->GetImageBounds().CenterPoint()); 599 gfx::Point icon_center(location_icon_view_->GetImageBounds().CenterPoint());
616 gfx::Point point(icon_center.x(), icon_bottom.y()); 600 gfx::Point point(icon_center.x(), icon_bottom.y());
617 ConvertPointToTarget(GetLocationIconView(), this, &point); 601 ConvertPointToTarget(location_icon_view_, this, &point);
618 return point; 602 return point;
619 } 603 }
620 604
621 views::View* LocationBarView::generated_credit_card_view() { 605 views::View* LocationBarView::generated_credit_card_view() {
622 return generated_credit_card_view_; 606 return generated_credit_card_view_;
623 } 607 }
624 608
625 int LocationBarView::GetInternalHeight(bool use_preferred_size) { 609 int LocationBarView::GetInternalHeight(bool use_preferred_size) {
626 int total_height = 610 int total_height =
627 use_preferred_size ? GetPreferredSize().height() : height(); 611 use_preferred_size ? GetPreferredSize().height() : height();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> 782 gfx::Image image = extensions::OmniboxAPI::Get(profile())->
799 GetOmniboxIcon(template_url->GetExtensionId()); 783 GetOmniboxIcon(template_url->GetExtensionId());
800 selected_keyword_view_->SetImage(image.AsImageSkia()); 784 selected_keyword_view_->SetImage(image.AsImageSkia());
801 selected_keyword_view_->set_is_extension_icon(true); 785 selected_keyword_view_->set_is_extension_icon(true);
802 } else { 786 } else {
803 selected_keyword_view_->SetImage( 787 selected_keyword_view_->SetImage(
804 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH))); 788 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)));
805 selected_keyword_view_->set_is_extension_icon(false); 789 selected_keyword_view_->set_is_extension_icon(false);
806 } 790 }
807 } 791 }
808 } else if (!toolbar_origin_chip_view_ && 792 } else if (!chrome::ShouldDisplayOriginChip() &&
809 !chrome::ShouldDisplayOriginChipV2() &&
810 (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE)) { 793 (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE)) {
811 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName()); 794 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName());
812 // The largest fraction of the omnibox that can be taken by the EV bubble. 795 // The largest fraction of the omnibox that can be taken by the EV bubble.
813 const double kMaxBubbleFraction = 0.5; 796 const double kMaxBubbleFraction = 0.5;
814 leading_decorations.AddDecoration(bubble_location_y, bubble_height, false, 797 leading_decorations.AddDecoration(bubble_location_y, bubble_height, false,
815 kMaxBubbleFraction, kBubblePadding, 798 kMaxBubbleFraction, kBubblePadding,
816 kItemPadding, ev_bubble_view_); 799 kItemPadding, ev_bubble_view_);
817 } else if (!origin_chip_view_->visible()) { 800 } else if (!origin_chip_view_->visible()) {
818 leading_decorations.AddDecoration( 801 leading_decorations.AddDecoration(
819 vertical_edge_thickness(), location_height, 802 vertical_edge_thickness(), location_height,
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 999
1017 if (contents) 1000 if (contents)
1018 omnibox_view_->OnTabChanged(contents); 1001 omnibox_view_->OnTabChanged(contents);
1019 else 1002 else
1020 omnibox_view_->Update(); 1003 omnibox_view_->Update();
1021 1004
1022 OnChanged(); // NOTE: Calls Layout(). 1005 OnChanged(); // NOTE: Calls Layout().
1023 } 1006 }
1024 1007
1025 void LocationBarView::ShowURL() { 1008 void LocationBarView::ShowURL() {
1026 if (chrome::ShouldDisplayOriginChipV2()) { 1009 if (chrome::ShouldDisplayOriginChip()) {
1027 omnibox_view_->SetVisible(false); 1010 omnibox_view_->SetVisible(false);
1028 omnibox_view_->ShowURL(); 1011 omnibox_view_->ShowURL();
1029 show_url_animation_->Show(); 1012 show_url_animation_->Show();
1030 } else { 1013 } else {
1031 omnibox_view_->ShowURL(); 1014 omnibox_view_->ShowURL();
1032 } 1015 }
1033 } 1016 }
1034 1017
1035 ToolbarModel* LocationBarView::GetToolbarModel() { 1018 ToolbarModel* LocationBarView::GetToolbarModel() {
1036 return delegate_->GetToolbarModel(); 1019 return delegate_->GetToolbarModel();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 return was_visible != manage_passwords_icon_view_->visible(); 1174 return was_visible != manage_passwords_icon_view_->visible();
1192 } 1175 }
1193 1176
1194 void LocationBarView::ShowFirstRunBubbleInternal() { 1177 void LocationBarView::ShowFirstRunBubbleInternal() {
1195 #if !defined(OS_CHROMEOS) 1178 #if !defined(OS_CHROMEOS)
1196 // First run bubble doesn't make sense for Chrome OS. 1179 // First run bubble doesn't make sense for Chrome OS.
1197 Browser* browser = GetBrowserFromDelegate(delegate_); 1180 Browser* browser = GetBrowserFromDelegate(delegate_);
1198 if (!browser) 1181 if (!browser)
1199 return; // Possible when browser is shutting down. 1182 return; // Possible when browser is shutting down.
1200 1183
1201 FirstRunBubble::ShowBubble(browser, GetLocationBarAnchor()); 1184 FirstRunBubble::ShowBubble(browser, location_icon_view_);
1202 #endif 1185 #endif
1203 } 1186 }
1204 1187
1205 void LocationBarView::AccessibilitySetValue(const base::string16& new_value) { 1188 void LocationBarView::AccessibilitySetValue(const base::string16& new_value) {
1206 omnibox_view_->SetUserText(new_value, new_value, true); 1189 omnibox_view_->SetUserText(new_value, new_value, true);
1207 } 1190 }
1208 1191
1209 bool LocationBarView::HasValidSuggestText() const { 1192 bool LocationBarView::HasValidSuggestText() const {
1210 return suggested_text_view_->visible() && 1193 return suggested_text_view_->visible() &&
1211 !suggested_text_view_->size().IsEmpty(); 1194 !suggested_text_view_->size().IsEmpty();
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 ((conditions != chrome::DISPLAY_SEARCH_BUTTON_NEVER) && 1517 ((conditions != chrome::DISPLAY_SEARCH_BUTTON_NEVER) &&
1535 (toolbar_model->WouldPerformSearchTermReplacement(true) || 1518 (toolbar_model->WouldPerformSearchTermReplacement(true) ||
1536 ((conditions == chrome::DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP) && 1519 ((conditions == chrome::DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP) &&
1537 toolbar_model->input_in_progress()))); 1520 toolbar_model->input_in_progress())));
1538 search_button_->SetVisible(!is_popup_mode_ && meets_conditions); 1521 search_button_->SetVisible(!is_popup_mode_ && meets_conditions);
1539 search_button_->SetImage( 1522 search_button_->SetImage(
1540 views::Button::STATE_NORMAL, 1523 views::Button::STATE_NORMAL,
1541 *GetThemeProvider()->GetImageSkiaNamed((icon_id == IDR_OMNIBOX_SEARCH) ? 1524 *GetThemeProvider()->GetImageSkiaNamed((icon_id == IDR_OMNIBOX_SEARCH) ?
1542 IDR_OMNIBOX_SEARCH_BUTTON_LOUPE : IDR_OMNIBOX_SEARCH_BUTTON_ARROW)); 1525 IDR_OMNIBOX_SEARCH_BUTTON_LOUPE : IDR_OMNIBOX_SEARCH_BUTTON_ARROW));
1543 1526
1544 if (toolbar_origin_chip_view_)
1545 toolbar_origin_chip_view_->OnChanged();
1546
1547 if (origin_chip_view_->visible()) 1527 if (origin_chip_view_->visible())
1548 origin_chip_view_->OnChanged(); 1528 origin_chip_view_->OnChanged();
1549 1529
1550 Layout(); 1530 Layout();
1551 SchedulePaint(); 1531 SchedulePaint();
1552 } 1532 }
1553 1533
1554 void LocationBarView::OnSetFocus() { 1534 void LocationBarView::OnSetFocus() {
1555 GetFocusManager()->SetFocusedView(this); 1535 GetFocusManager()->SetFocusedView(this);
1556 } 1536 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 void LocationBarView::ModelChanged(const SearchModel::State& old_state, 1622 void LocationBarView::ModelChanged(const SearchModel::State& old_state,
1643 const SearchModel::State& new_state) { 1623 const SearchModel::State& new_state) {
1644 const bool visible = !GetToolbarModel()->input_in_progress() && 1624 const bool visible = !GetToolbarModel()->input_in_progress() &&
1645 new_state.voice_search_supported; 1625 new_state.voice_search_supported;
1646 if (mic_search_view_->visible() != visible) { 1626 if (mic_search_view_->visible() != visible) {
1647 mic_search_view_->SetVisible(visible); 1627 mic_search_view_->SetVisible(visible);
1648 Layout(); 1628 Layout();
1649 } 1629 }
1650 } 1630 }
1651 1631
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698