| 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/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "chrome/browser/ui/layout_constants.h" | 33 #include "chrome/browser/ui/layout_constants.h" |
| 34 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 34 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 36 #include "chrome/browser/ui/views/autofill/save_card_icon_view.h" | 36 #include "chrome/browser/ui/views/autofill/save_card_icon_view.h" |
| 37 #include "chrome/browser/ui/views/frame/browser_view.h" | 37 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 38 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" | 38 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" |
| 39 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 39 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
| 40 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 40 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
| 41 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" | 41 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" |
| 42 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 42 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 43 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" | |
| 44 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 43 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
| 45 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 44 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
| 46 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 45 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
| 47 #include "chrome/browser/ui/views/location_bar/star_view.h" | 46 #include "chrome/browser/ui/views/location_bar/star_view.h" |
| 48 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | 47 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
| 49 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 48 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
| 50 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | 49 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
| 51 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" | 50 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" |
| 52 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" | 51 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" |
| 53 #include "chrome/browser/ui/views/translate/translate_icon_view.h" | 52 #include "chrome/browser/ui/views/translate/translate_icon_view.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 : LocationBar(profile), | 123 : LocationBar(profile), |
| 125 ChromeOmniboxEditController(command_updater), | 124 ChromeOmniboxEditController(command_updater), |
| 126 browser_(browser), | 125 browser_(browser), |
| 127 omnibox_view_(nullptr), | 126 omnibox_view_(nullptr), |
| 128 delegate_(delegate), | 127 delegate_(delegate), |
| 129 location_icon_view_(nullptr), | 128 location_icon_view_(nullptr), |
| 130 ime_inline_autocomplete_view_(nullptr), | 129 ime_inline_autocomplete_view_(nullptr), |
| 131 selected_keyword_view_(nullptr), | 130 selected_keyword_view_(nullptr), |
| 132 keyword_hint_view_(nullptr), | 131 keyword_hint_view_(nullptr), |
| 133 zoom_view_(nullptr), | 132 zoom_view_(nullptr), |
| 134 open_pdf_in_reader_view_(nullptr), | |
| 135 manage_passwords_icon_view_(nullptr), | 133 manage_passwords_icon_view_(nullptr), |
| 136 save_credit_card_icon_view_(nullptr), | 134 save_credit_card_icon_view_(nullptr), |
| 137 translate_icon_view_(nullptr), | 135 translate_icon_view_(nullptr), |
| 138 star_view_(nullptr), | 136 star_view_(nullptr), |
| 139 size_animation_(this), | 137 size_animation_(this), |
| 140 is_popup_mode_(is_popup_mode), | 138 is_popup_mode_(is_popup_mode), |
| 141 show_focus_rect_(false), | 139 show_focus_rect_(false), |
| 142 template_url_service_(NULL), | 140 template_url_service_(NULL), |
| 143 web_contents_null_at_last_refresh_(true) { | 141 web_contents_null_at_last_refresh_(true) { |
| 144 edit_bookmarks_enabled_.Init( | 142 edit_bookmarks_enabled_.Init( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 new ContentSettingImageView(std::move(model), this, font_list); | 242 new ContentSettingImageView(std::move(model), this, font_list); |
| 245 content_setting_views_.push_back(image_view); | 243 content_setting_views_.push_back(image_view); |
| 246 image_view->SetVisible(false); | 244 image_view->SetVisible(false); |
| 247 AddChildView(image_view); | 245 AddChildView(image_view); |
| 248 } | 246 } |
| 249 | 247 |
| 250 zoom_view_ = new ZoomView(delegate_); | 248 zoom_view_ = new ZoomView(delegate_); |
| 251 zoom_view_->Init(); | 249 zoom_view_->Init(); |
| 252 AddChildView(zoom_view_); | 250 AddChildView(zoom_view_); |
| 253 | 251 |
| 254 open_pdf_in_reader_view_ = new OpenPDFInReaderView(); | |
| 255 AddChildView(open_pdf_in_reader_view_); | |
| 256 | |
| 257 manage_passwords_icon_view_ = new ManagePasswordsIconViews(command_updater()); | 252 manage_passwords_icon_view_ = new ManagePasswordsIconViews(command_updater()); |
| 258 manage_passwords_icon_view_->Init(); | 253 manage_passwords_icon_view_->Init(); |
| 259 AddChildView(manage_passwords_icon_view_); | 254 AddChildView(manage_passwords_icon_view_); |
| 260 | 255 |
| 261 save_credit_card_icon_view_ = | 256 save_credit_card_icon_view_ = |
| 262 new autofill::SaveCardIconView(command_updater(), browser_); | 257 new autofill::SaveCardIconView(command_updater(), browser_); |
| 263 save_credit_card_icon_view_->Init(); | 258 save_credit_card_icon_view_->Init(); |
| 264 save_credit_card_icon_view_->SetVisible(false); | 259 save_credit_card_icon_view_->SetVisible(false); |
| 265 AddChildView(save_credit_card_icon_view_); | 260 AddChildView(save_credit_card_icon_view_); |
| 266 | 261 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 .width(); | 463 .width(); |
| 469 } else { | 464 } else { |
| 470 leading_width += GetLayoutConstant(LOCATION_BAR_ELEMENT_PADDING) + | 465 leading_width += GetLayoutConstant(LOCATION_BAR_ELEMENT_PADDING) + |
| 471 location_icon_view_->GetMinimumSize().width(); | 466 location_icon_view_->GetMinimumSize().width(); |
| 472 } | 467 } |
| 473 | 468 |
| 474 // Compute width of omnibox-trailing content. | 469 // Compute width of omnibox-trailing content. |
| 475 int trailing_width = edge_thickness; | 470 int trailing_width = edge_thickness; |
| 476 trailing_width += IncrementalMinimumWidth(star_view_) + | 471 trailing_width += IncrementalMinimumWidth(star_view_) + |
| 477 IncrementalMinimumWidth(translate_icon_view_) + | 472 IncrementalMinimumWidth(translate_icon_view_) + |
| 478 IncrementalMinimumWidth(open_pdf_in_reader_view_) + | |
| 479 IncrementalMinimumWidth(save_credit_card_icon_view_) + | 473 IncrementalMinimumWidth(save_credit_card_icon_view_) + |
| 480 IncrementalMinimumWidth(manage_passwords_icon_view_) + | 474 IncrementalMinimumWidth(manage_passwords_icon_view_) + |
| 481 IncrementalMinimumWidth(zoom_view_); | 475 IncrementalMinimumWidth(zoom_view_); |
| 482 for (const auto& action_view : page_action_views_) | 476 for (const auto& action_view : page_action_views_) |
| 483 trailing_width += IncrementalMinimumWidth(action_view.get()); | 477 trailing_width += IncrementalMinimumWidth(action_view.get()); |
| 484 for (auto i = content_setting_views_.begin(); | 478 for (auto i = content_setting_views_.begin(); |
| 485 i != content_setting_views_.end(); ++i) { | 479 i != content_setting_views_.end(); ++i) { |
| 486 trailing_width += IncrementalMinimumWidth((*i)); | 480 trailing_width += IncrementalMinimumWidth((*i)); |
| 487 } | 481 } |
| 488 | 482 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 } | 542 } |
| 549 | 543 |
| 550 if (star_view_->visible()) { | 544 if (star_view_->visible()) { |
| 551 trailing_decorations.AddDecoration(vertical_padding, location_height, | 545 trailing_decorations.AddDecoration(vertical_padding, location_height, |
| 552 star_view_); | 546 star_view_); |
| 553 } | 547 } |
| 554 if (translate_icon_view_->visible()) { | 548 if (translate_icon_view_->visible()) { |
| 555 trailing_decorations.AddDecoration(vertical_padding, location_height, | 549 trailing_decorations.AddDecoration(vertical_padding, location_height, |
| 556 translate_icon_view_); | 550 translate_icon_view_); |
| 557 } | 551 } |
| 558 if (open_pdf_in_reader_view_->visible()) { | |
| 559 trailing_decorations.AddDecoration(vertical_padding, location_height, | |
| 560 open_pdf_in_reader_view_); | |
| 561 } | |
| 562 if (save_credit_card_icon_view_->visible()) { | 552 if (save_credit_card_icon_view_->visible()) { |
| 563 trailing_decorations.AddDecoration(vertical_padding, location_height, | 553 trailing_decorations.AddDecoration(vertical_padding, location_height, |
| 564 save_credit_card_icon_view_); | 554 save_credit_card_icon_view_); |
| 565 } | 555 } |
| 566 if (manage_passwords_icon_view_->visible()) { | 556 if (manage_passwords_icon_view_->visible()) { |
| 567 trailing_decorations.AddDecoration(vertical_padding, location_height, | 557 trailing_decorations.AddDecoration(vertical_padding, location_height, |
| 568 manage_passwords_icon_view_); | 558 manage_passwords_icon_view_); |
| 569 } | 559 } |
| 570 for (const auto& action_view : page_action_views_) { | 560 for (const auto& action_view : page_action_views_) { |
| 571 if (action_view->visible()) { | 561 if (action_view->visible()) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 637 } |
| 648 } | 638 } |
| 649 | 639 |
| 650 void LocationBarView::Update(const WebContents* contents) { | 640 void LocationBarView::Update(const WebContents* contents) { |
| 651 RefreshContentSettingViews(); | 641 RefreshContentSettingViews(); |
| 652 RefreshZoomView(); | 642 RefreshZoomView(); |
| 653 RefreshPageActionViews(); | 643 RefreshPageActionViews(); |
| 654 RefreshTranslateIcon(); | 644 RefreshTranslateIcon(); |
| 655 RefreshSaveCreditCardIconView(); | 645 RefreshSaveCreditCardIconView(); |
| 656 RefreshManagePasswordsIconView(); | 646 RefreshManagePasswordsIconView(); |
| 657 WebContents* web_contents_for_sub_views = | |
| 658 GetToolbarModel()->input_in_progress() ? nullptr : GetWebContents(); | |
| 659 open_pdf_in_reader_view_->Update(web_contents_for_sub_views); | |
| 660 | 647 |
| 661 if (star_view_) | 648 if (star_view_) |
| 662 UpdateBookmarkStarVisibility(); | 649 UpdateBookmarkStarVisibility(); |
| 663 | 650 |
| 664 if (contents) | 651 if (contents) |
| 665 omnibox_view_->OnTabChanged(contents); | 652 omnibox_view_->OnTabChanged(contents); |
| 666 else | 653 else |
| 667 omnibox_view_->Update(); | 654 omnibox_view_->Update(); |
| 668 | 655 |
| 669 location_icon_view_->SetTextVisibility( | 656 location_icon_view_->SetTextVisibility( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 // Create the page action views. | 760 // Create the page action views. |
| 774 for (PageActions::const_iterator i = new_page_actions.begin(); | 761 for (PageActions::const_iterator i = new_page_actions.begin(); |
| 775 i != new_page_actions.end(); ++i) { | 762 i != new_page_actions.end(); ++i) { |
| 776 std::unique_ptr<PageActionWithBadgeView> page_action_view = | 763 std::unique_ptr<PageActionWithBadgeView> page_action_view = |
| 777 base::MakeUnique<PageActionWithBadgeView>( | 764 base::MakeUnique<PageActionWithBadgeView>( |
| 778 delegate_->CreatePageActionImageView(this, *i)); | 765 delegate_->CreatePageActionImageView(this, *i)); |
| 779 page_action_view->SetVisible(false); | 766 page_action_view->SetVisible(false); |
| 780 page_action_views_.push_back(std::move(page_action_view)); | 767 page_action_views_.push_back(std::move(page_action_view)); |
| 781 } | 768 } |
| 782 | 769 |
| 783 View* right_anchor = open_pdf_in_reader_view_; | 770 View* right_anchor = star_view_; |
| 784 if (!right_anchor) | |
| 785 right_anchor = star_view_; | |
| 786 DCHECK(right_anchor); | 771 DCHECK(right_anchor); |
| 787 | 772 |
| 788 // |page_action_views_| are ordered right-to-left. Add them as children in | 773 // |page_action_views_| are ordered right-to-left. Add them as children in |
| 789 // reverse order so the logical order and visual order match for | 774 // reverse order so the logical order and visual order match for |
| 790 // accessibility purposes. | 775 // accessibility purposes. |
| 791 for (PageActionViews::reverse_iterator i = page_action_views_.rbegin(); | 776 for (PageActionViews::reverse_iterator i = page_action_views_.rbegin(); |
| 792 i != page_action_views_.rend(); ++i) | 777 i != page_action_views_.rend(); ++i) |
| 793 AddChildViewAt(i->get(), GetIndexOf(right_anchor)); | 778 AddChildViewAt(i->get(), GetIndexOf(right_anchor)); |
| 794 } | 779 } |
| 795 | 780 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 CHECK(false); | 1016 CHECK(false); |
| 1032 } | 1017 } |
| 1033 PageActionImageView* page_action_image_view = page_action_view->image_view(); | 1018 PageActionImageView* page_action_image_view = page_action_view->image_view(); |
| 1034 CHECK(page_action_image_view); | 1019 CHECK(page_action_image_view); |
| 1035 ExtensionActionViewController* extension_action_view_controller = | 1020 ExtensionActionViewController* extension_action_view_controller = |
| 1036 page_action_image_view->view_controller(); | 1021 page_action_image_view->view_controller(); |
| 1037 CHECK(extension_action_view_controller); | 1022 CHECK(extension_action_view_controller); |
| 1038 return extension_action_view_controller->ExecuteAction(grant_tab_permissions); | 1023 return extension_action_view_controller->ExecuteAction(grant_tab_permissions); |
| 1039 } | 1024 } |
| 1040 | 1025 |
| 1041 void LocationBarView::UpdateOpenPDFInReaderPrompt() { | |
| 1042 open_pdf_in_reader_view_->Update( | |
| 1043 GetToolbarModel()->input_in_progress() ? nullptr : GetWebContents()); | |
| 1044 Layout(); | |
| 1045 SchedulePaint(); | |
| 1046 } | |
| 1047 | |
| 1048 void LocationBarView::SaveStateToContents(WebContents* contents) { | 1026 void LocationBarView::SaveStateToContents(WebContents* contents) { |
| 1049 omnibox_view_->SaveStateToTab(contents); | 1027 omnibox_view_->SaveStateToTab(contents); |
| 1050 } | 1028 } |
| 1051 | 1029 |
| 1052 const OmniboxView* LocationBarView::GetOmniboxView() const { | 1030 const OmniboxView* LocationBarView::GetOmniboxView() const { |
| 1053 return omnibox_view_; | 1031 return omnibox_view_; |
| 1054 } | 1032 } |
| 1055 | 1033 |
| 1056 LocationBarTesting* LocationBarView::GetLocationBarForTesting() { | 1034 LocationBarTesting* LocationBarView::GetLocationBarForTesting() { |
| 1057 return this; | 1035 return this; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 // LocationBarView, private TemplateURLServiceObserver implementation: | 1213 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1236 | 1214 |
| 1237 void LocationBarView::OnTemplateURLServiceChanged() { | 1215 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1238 template_url_service_->RemoveObserver(this); | 1216 template_url_service_->RemoveObserver(this); |
| 1239 template_url_service_ = nullptr; | 1217 template_url_service_ = nullptr; |
| 1240 // If the browser is no longer active, let's not show the info bubble, as this | 1218 // If the browser is no longer active, let's not show the info bubble, as this |
| 1241 // would make the browser the active window again. | 1219 // would make the browser the active window again. |
| 1242 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1220 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1243 ShowFirstRunBubble(); | 1221 ShowFirstRunBubble(); |
| 1244 } | 1222 } |
| OLD | NEW |