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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 Profile* profile, | 199 Profile* profile, |
201 CommandUpdater* command_updater, | 200 CommandUpdater* command_updater, |
202 Delegate* delegate, | 201 Delegate* delegate, |
203 bool is_popup_mode) | 202 bool is_popup_mode) |
204 : LocationBar(profile), | 203 : LocationBar(profile), |
205 OmniboxEditController(command_updater), | 204 OmniboxEditController(command_updater), |
206 browser_(browser), | 205 browser_(browser), |
207 omnibox_view_(NULL), | 206 omnibox_view_(NULL), |
208 delegate_(delegate), | 207 delegate_(delegate), |
209 origin_chip_view_(NULL), | 208 origin_chip_view_(NULL), |
210 toolbar_origin_chip_view_(NULL), | |
211 location_icon_view_(NULL), | 209 location_icon_view_(NULL), |
212 ev_bubble_view_(NULL), | 210 ev_bubble_view_(NULL), |
213 ime_inline_autocomplete_view_(NULL), | 211 ime_inline_autocomplete_view_(NULL), |
214 selected_keyword_view_(NULL), | 212 selected_keyword_view_(NULL), |
215 suggested_text_view_(NULL), | 213 suggested_text_view_(NULL), |
216 keyword_hint_view_(NULL), | 214 keyword_hint_view_(NULL), |
217 mic_search_view_(NULL), | 215 mic_search_view_(NULL), |
218 zoom_view_(NULL), | 216 zoom_view_(NULL), |
219 generated_credit_card_view_(NULL), | 217 generated_credit_card_view_(NULL), |
220 open_pdf_in_reader_view_(NULL), | 218 open_pdf_in_reader_view_(NULL), |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 | 588 |
591 void LocationBarView::SetShowFocusRect(bool show) { | 589 void LocationBarView::SetShowFocusRect(bool show) { |
592 show_focus_rect_ = show; | 590 show_focus_rect_ = show; |
593 SchedulePaint(); | 591 SchedulePaint(); |
594 } | 592 } |
595 | 593 |
596 void LocationBarView::SelectAll() { | 594 void LocationBarView::SelectAll() { |
597 omnibox_view_->SelectAll(true); | 595 omnibox_view_->SelectAll(true); |
598 } | 596 } |
599 | 597 |
600 views::ImageView* LocationBarView::GetLocationIconView() { | |
601 return toolbar_origin_chip_view_ ? | |
602 toolbar_origin_chip_view_->location_icon_view() : location_icon_view_; | |
603 } | |
604 | |
605 const views::ImageView* LocationBarView::GetLocationIconView() const { | |
606 return toolbar_origin_chip_view_ ? | |
607 toolbar_origin_chip_view_->location_icon_view() : location_icon_view_; | |
608 } | |
609 | |
610 views::View* LocationBarView::GetLocationBarAnchor() { | |
611 return GetLocationIconView(); | |
612 } | |
613 | |
614 gfx::Point LocationBarView::GetLocationBarAnchorPoint() const { | 598 gfx::Point LocationBarView::GetLocationBarAnchorPoint() const { |
615 // The +1 in the next line creates a 1-px gap between icon and arrow tip. | 599 // The +1 in the next line creates a 1-px gap between icon and arrow tip. |
616 gfx::Point icon_bottom(0, GetLocationIconView()->GetImageBounds().bottom() - | 600 gfx::Point icon_bottom(0, location_icon_view_->GetImageBounds().bottom() - |
617 LocationBarView::kIconInternalPadding + 1); | 601 LocationBarView::kIconInternalPadding + 1); |
618 gfx::Point icon_center(GetLocationIconView()->GetImageBounds().CenterPoint()); | 602 gfx::Point icon_center(location_icon_view_->GetImageBounds().CenterPoint()); |
619 gfx::Point point(icon_center.x(), icon_bottom.y()); | 603 gfx::Point point(icon_center.x(), icon_bottom.y()); |
620 ConvertPointToTarget(GetLocationIconView(), this, &point); | 604 ConvertPointToTarget(location_icon_view_, this, &point); |
621 return point; | 605 return point; |
622 } | 606 } |
623 | 607 |
624 views::View* LocationBarView::generated_credit_card_view() { | 608 views::View* LocationBarView::generated_credit_card_view() { |
625 return generated_credit_card_view_; | 609 return generated_credit_card_view_; |
626 } | 610 } |
627 | 611 |
628 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 612 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
629 int total_height = | 613 int total_height = |
630 use_preferred_size ? GetPreferredSize().height() : height(); | 614 use_preferred_size ? GetPreferredSize().height() : height(); |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 | 1031 |
1048 if (contents) | 1032 if (contents) |
1049 omnibox_view_->OnTabChanged(contents); | 1033 omnibox_view_->OnTabChanged(contents); |
1050 else | 1034 else |
1051 omnibox_view_->Update(); | 1035 omnibox_view_->Update(); |
1052 | 1036 |
1053 OnChanged(); // NOTE: Calls Layout(). | 1037 OnChanged(); // NOTE: Calls Layout(). |
1054 } | 1038 } |
1055 | 1039 |
1056 void LocationBarView::ShowURL() { | 1040 void LocationBarView::ShowURL() { |
1057 if (chrome::ShouldDisplayOriginChipV2()) { | 1041 if (chrome::ShouldDisplayOriginChip()) { |
1058 omnibox_view_->SetVisible(false); | 1042 omnibox_view_->SetVisible(false); |
1059 omnibox_view_->ShowURL(); | 1043 omnibox_view_->ShowURL(); |
1060 show_url_animation_->Show(); | 1044 show_url_animation_->Show(); |
1061 } else { | 1045 } else { |
1062 omnibox_view_->ShowURL(); | 1046 omnibox_view_->ShowURL(); |
1063 } | 1047 } |
1064 } | 1048 } |
1065 | 1049 |
1066 ToolbarModel* LocationBarView::GetToolbarModel() { | 1050 ToolbarModel* LocationBarView::GetToolbarModel() { |
1067 return delegate_->GetToolbarModel(); | 1051 return delegate_->GetToolbarModel(); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 } | 1212 } |
1229 | 1213 |
1230 void LocationBarView::ShowFirstRunBubbleInternal() { | 1214 void LocationBarView::ShowFirstRunBubbleInternal() { |
1231 // First run bubble doesn't make sense for Chrome OS. | 1215 // First run bubble doesn't make sense for Chrome OS. |
1232 #if !defined(OS_CHROMEOS) | 1216 #if !defined(OS_CHROMEOS) |
1233 WebContents* web_contents = delegate_->GetWebContents(); | 1217 WebContents* web_contents = delegate_->GetWebContents(); |
1234 if (!web_contents) | 1218 if (!web_contents) |
1235 return; | 1219 return; |
1236 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 1220 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
1237 if (browser) | 1221 if (browser) |
1238 FirstRunBubble::ShowBubble(browser, GetLocationBarAnchor()); | 1222 FirstRunBubble::ShowBubble(browser, location_icon_view_); |
1239 #endif | 1223 #endif |
1240 } | 1224 } |
1241 | 1225 |
1242 void LocationBarView::AccessibilitySetValue(const base::string16& new_value) { | 1226 void LocationBarView::AccessibilitySetValue(const base::string16& new_value) { |
1243 omnibox_view_->SetUserText(new_value, new_value, true); | 1227 omnibox_view_->SetUserText(new_value, new_value, true); |
1244 } | 1228 } |
1245 | 1229 |
1246 bool LocationBarView::HasValidSuggestText() const { | 1230 bool LocationBarView::HasValidSuggestText() const { |
1247 return suggested_text_view_->visible() && | 1231 return suggested_text_view_->visible() && |
1248 !suggested_text_view_->size().IsEmpty(); | 1232 !suggested_text_view_->size().IsEmpty(); |
1249 } | 1233 } |
1250 | 1234 |
1251 bool LocationBarView::ShouldShowKeywordBubble() const { | 1235 bool LocationBarView::ShouldShowKeywordBubble() const { |
1252 return !omnibox_view_->model()->keyword().empty() && | 1236 return !omnibox_view_->model()->keyword().empty() && |
1253 !omnibox_view_->model()->is_keyword_hint(); | 1237 !omnibox_view_->model()->is_keyword_hint(); |
1254 } | 1238 } |
1255 | 1239 |
1256 bool LocationBarView::ShouldShowEVBubble() const { | 1240 bool LocationBarView::ShouldShowEVBubble() const { |
1257 return !toolbar_origin_chip_view_ && !chrome::ShouldDisplayOriginChipV2() && | 1241 return !chrome::ShouldDisplayOriginChip() && |
1258 (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE); | 1242 (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE); |
1259 } | 1243 } |
1260 | 1244 |
1261 void LocationBarView::OnShowURLAnimationEnded() { | 1245 void LocationBarView::OnShowURLAnimationEnded() { |
1262 animated_host_label_->SetVisible(false); | 1246 animated_host_label_->SetVisible(false); |
1263 omnibox_view_->SetVisible(true); | 1247 omnibox_view_->SetVisible(true); |
1264 omnibox_view_->FadeIn(); | 1248 omnibox_view_->FadeIn(); |
1265 omnibox_view_->SetFocus(); | 1249 omnibox_view_->SetFocus(); |
1266 | 1250 |
1267 // Sometimes the selection established by OmniboxView::ShowURL() is lost at | 1251 // Sometimes the selection established by OmniboxView::ShowURL() is lost at |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 ((conditions != chrome::DISPLAY_SEARCH_BUTTON_NEVER) && | 1565 ((conditions != chrome::DISPLAY_SEARCH_BUTTON_NEVER) && |
1582 (toolbar_model->WouldPerformSearchTermReplacement(true) || | 1566 (toolbar_model->WouldPerformSearchTermReplacement(true) || |
1583 ((conditions == chrome::DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP) && | 1567 ((conditions == chrome::DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP) && |
1584 toolbar_model->input_in_progress()))); | 1568 toolbar_model->input_in_progress()))); |
1585 search_button_->SetVisible(!is_popup_mode_ && meets_conditions); | 1569 search_button_->SetVisible(!is_popup_mode_ && meets_conditions); |
1586 search_button_->SetImage( | 1570 search_button_->SetImage( |
1587 views::Button::STATE_NORMAL, | 1571 views::Button::STATE_NORMAL, |
1588 *GetThemeProvider()->GetImageSkiaNamed((icon_id == IDR_OMNIBOX_SEARCH) ? | 1572 *GetThemeProvider()->GetImageSkiaNamed((icon_id == IDR_OMNIBOX_SEARCH) ? |
1589 IDR_OMNIBOX_SEARCH_BUTTON_LOUPE : IDR_OMNIBOX_SEARCH_BUTTON_ARROW)); | 1573 IDR_OMNIBOX_SEARCH_BUTTON_LOUPE : IDR_OMNIBOX_SEARCH_BUTTON_ARROW)); |
1590 | 1574 |
1591 if (toolbar_origin_chip_view_) | |
1592 toolbar_origin_chip_view_->OnChanged(); | |
1593 | |
1594 if (origin_chip_view_->visible()) | 1575 if (origin_chip_view_->visible()) |
1595 origin_chip_view_->OnChanged(); | 1576 origin_chip_view_->OnChanged(); |
1596 | 1577 |
1597 Layout(); | 1578 Layout(); |
1598 SchedulePaint(); | 1579 SchedulePaint(); |
1599 } | 1580 } |
1600 | 1581 |
1601 void LocationBarView::OnSetFocus() { | 1582 void LocationBarView::OnSetFocus() { |
1602 GetFocusManager()->SetFocusedView(this); | 1583 GetFocusManager()->SetFocusedView(this); |
1603 } | 1584 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1670 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
1690 const SearchModel::State& new_state) { | 1671 const SearchModel::State& new_state) { |
1691 const bool visible = !GetToolbarModel()->input_in_progress() && | 1672 const bool visible = !GetToolbarModel()->input_in_progress() && |
1692 new_state.voice_search_supported; | 1673 new_state.voice_search_supported; |
1693 if (mic_search_view_->visible() != visible) { | 1674 if (mic_search_view_->visible() != visible) { |
1694 mic_search_view_->SetVisible(visible); | 1675 mic_search_view_->SetVisible(visible); |
1695 Layout(); | 1676 Layout(); |
1696 } | 1677 } |
1697 } | 1678 } |
1698 | 1679 |
OLD | NEW |