| 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 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/ui/browser_finder.h" | 32 #include "chrome/browser/ui/browser_finder.h" |
| 33 #include "chrome/browser/ui/browser_instant_controller.h" | 33 #include "chrome/browser/ui/browser_instant_controller.h" |
| 34 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
| 35 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 35 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 36 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 36 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
| 37 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" | 37 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" |
| 38 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 38 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| 39 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 39 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 40 #include "chrome/browser/ui/view_ids.h" | 40 #include "chrome/browser/ui/view_ids.h" |
| 41 #include "chrome/browser/ui/views/browser_dialogs.h" | 41 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 42 #include "chrome/browser/ui/views/location_bar/add_to_app_launcher_view.h" | |
| 43 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 42 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
| 44 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 43 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
| 45 #include "chrome/browser/ui/views/location_bar/generated_credit_card_view.h" | 44 #include "chrome/browser/ui/views/location_bar/generated_credit_card_view.h" |
| 46 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 45 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
| 47 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" | 46 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" |
| 48 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 47 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 49 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" | 48 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" |
| 50 #include "chrome/browser/ui/views/location_bar/origin_chip_view.h" | 49 #include "chrome/browser/ui/views/location_bar/origin_chip_view.h" |
| 51 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 50 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
| 52 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 51 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 ime_inline_autocomplete_view_(NULL), | 214 ime_inline_autocomplete_view_(NULL), |
| 216 selected_keyword_view_(NULL), | 215 selected_keyword_view_(NULL), |
| 217 suggested_text_view_(NULL), | 216 suggested_text_view_(NULL), |
| 218 keyword_hint_view_(NULL), | 217 keyword_hint_view_(NULL), |
| 219 mic_search_view_(NULL), | 218 mic_search_view_(NULL), |
| 220 zoom_view_(NULL), | 219 zoom_view_(NULL), |
| 221 generated_credit_card_view_(NULL), | 220 generated_credit_card_view_(NULL), |
| 222 open_pdf_in_reader_view_(NULL), | 221 open_pdf_in_reader_view_(NULL), |
| 223 manage_passwords_icon_view_(NULL), | 222 manage_passwords_icon_view_(NULL), |
| 224 translate_icon_view_(NULL), | 223 translate_icon_view_(NULL), |
| 225 add_to_app_launcher_view_(NULL), | |
| 226 star_view_(NULL), | 224 star_view_(NULL), |
| 227 search_button_(NULL), | 225 search_button_(NULL), |
| 228 is_popup_mode_(is_popup_mode), | 226 is_popup_mode_(is_popup_mode), |
| 229 show_focus_rect_(false), | 227 show_focus_rect_(false), |
| 230 template_url_service_(NULL), | 228 template_url_service_(NULL), |
| 231 dropdown_animation_offset_(0), | 229 dropdown_animation_offset_(0), |
| 232 starting_omnibox_offset_(0), | 230 starting_omnibox_offset_(0), |
| 233 current_omnibox_offset_(0), | 231 current_omnibox_offset_(0), |
| 234 starting_omnibox_leading_inset_(0), | 232 starting_omnibox_leading_inset_(0), |
| 235 current_omnibox_leading_inset_(0), | 233 current_omnibox_leading_inset_(0), |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 open_pdf_in_reader_view_ = new OpenPDFInReaderView(); | 381 open_pdf_in_reader_view_ = new OpenPDFInReaderView(); |
| 384 AddChildView(open_pdf_in_reader_view_); | 382 AddChildView(open_pdf_in_reader_view_); |
| 385 | 383 |
| 386 manage_passwords_icon_view_ = new ManagePasswordsIconView(command_updater()); | 384 manage_passwords_icon_view_ = new ManagePasswordsIconView(command_updater()); |
| 387 AddChildView(manage_passwords_icon_view_); | 385 AddChildView(manage_passwords_icon_view_); |
| 388 | 386 |
| 389 translate_icon_view_ = new TranslateIconView(command_updater()); | 387 translate_icon_view_ = new TranslateIconView(command_updater()); |
| 390 translate_icon_view_->SetVisible(false); | 388 translate_icon_view_->SetVisible(false); |
| 391 AddChildView(translate_icon_view_); | 389 AddChildView(translate_icon_view_); |
| 392 | 390 |
| 393 add_to_app_launcher_view_ = new AddToAppLauncherView( | |
| 394 this, bubble_font_list, text_color, background_color); | |
| 395 add_to_app_launcher_view_->SetVisible(false); | |
| 396 AddChildView(add_to_app_launcher_view_); | |
| 397 | |
| 398 star_view_ = new StarView(command_updater()); | 391 star_view_ = new StarView(command_updater()); |
| 399 star_view_->SetVisible(false); | 392 star_view_->SetVisible(false); |
| 400 AddChildView(star_view_); | 393 AddChildView(star_view_); |
| 401 | 394 |
| 402 search_button_ = new SearchButton(this); | 395 search_button_ = new SearchButton(this); |
| 403 search_button_->SetVisible(false); | 396 search_button_->SetVisible(false); |
| 404 AddChildView(search_button_); | 397 AddChildView(search_button_); |
| 405 | 398 |
| 406 show_url_animation_.reset(new gfx::SlideAnimation(this)); | 399 show_url_animation_.reset(new gfx::SlideAnimation(this)); |
| 407 show_url_animation_->SetTweenType(kShowTweenType); | 400 show_url_animation_->SetTweenType(kShowTweenType); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 // Compute width of omnibox-trailing content. | 662 // Compute width of omnibox-trailing content. |
| 670 int trailing_width = search_button_->visible() ? | 663 int trailing_width = search_button_->visible() ? |
| 671 (search_button_->GetMinimumSize().width() + kSearchButtonInset) : | 664 (search_button_->GetMinimumSize().width() + kSearchButtonInset) : |
| 672 horizontal_edge_thickness; | 665 horizontal_edge_thickness; |
| 673 trailing_width += IncrementalMinimumWidth(star_view_) + | 666 trailing_width += IncrementalMinimumWidth(star_view_) + |
| 674 IncrementalMinimumWidth(translate_icon_view_) + | 667 IncrementalMinimumWidth(translate_icon_view_) + |
| 675 IncrementalMinimumWidth(open_pdf_in_reader_view_) + | 668 IncrementalMinimumWidth(open_pdf_in_reader_view_) + |
| 676 IncrementalMinimumWidth(manage_passwords_icon_view_) + | 669 IncrementalMinimumWidth(manage_passwords_icon_view_) + |
| 677 IncrementalMinimumWidth(zoom_view_) + | 670 IncrementalMinimumWidth(zoom_view_) + |
| 678 IncrementalMinimumWidth(generated_credit_card_view_) + | 671 IncrementalMinimumWidth(generated_credit_card_view_) + |
| 679 IncrementalMinimumWidth(mic_search_view_) + | 672 IncrementalMinimumWidth(mic_search_view_) + kItemPadding; |
| 680 IncrementalMinimumWidth(add_to_app_launcher_view_) + kItemPadding; | |
| 681 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 673 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| 682 i != page_action_views_.end(); ++i) | 674 i != page_action_views_.end(); ++i) |
| 683 trailing_width += IncrementalMinimumWidth((*i)); | 675 trailing_width += IncrementalMinimumWidth((*i)); |
| 684 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 676 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
| 685 i != content_setting_views_.end(); ++i) | 677 i != content_setting_views_.end(); ++i) |
| 686 trailing_width += IncrementalMinimumWidth((*i)); | 678 trailing_width += IncrementalMinimumWidth((*i)); |
| 687 | 679 |
| 688 min_size.set_width( | 680 min_size.set_width( |
| 689 leading_width + omnibox_view_->GetMinimumSize().width() + trailing_width); | 681 leading_width + omnibox_view_->GetMinimumSize().width() + trailing_width); |
| 690 return min_size; | 682 return min_size; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 } else if (!origin_chip_view_->visible()) { | 747 } else if (!origin_chip_view_->visible()) { |
| 756 leading_decorations.AddDecoration( | 748 leading_decorations.AddDecoration( |
| 757 vertical_edge_thickness(), location_height, | 749 vertical_edge_thickness(), location_height, |
| 758 location_icon_view_); | 750 location_icon_view_); |
| 759 } | 751 } |
| 760 | 752 |
| 761 if (star_view_->visible()) { | 753 if (star_view_->visible()) { |
| 762 trailing_decorations.AddDecoration( | 754 trailing_decorations.AddDecoration( |
| 763 vertical_edge_thickness(), location_height, star_view_); | 755 vertical_edge_thickness(), location_height, star_view_); |
| 764 } | 756 } |
| 765 if (add_to_app_launcher_view_->visible()) { | |
| 766 trailing_decorations.AddDecoration( | |
| 767 vertical_edge_thickness(), location_height, add_to_app_launcher_view_); | |
| 768 } | |
| 769 if (translate_icon_view_->visible()) { | 757 if (translate_icon_view_->visible()) { |
| 770 trailing_decorations.AddDecoration( | 758 trailing_decorations.AddDecoration( |
| 771 vertical_edge_thickness(), location_height, translate_icon_view_); | 759 vertical_edge_thickness(), location_height, translate_icon_view_); |
| 772 } | 760 } |
| 773 if (open_pdf_in_reader_view_->visible()) { | 761 if (open_pdf_in_reader_view_->visible()) { |
| 774 trailing_decorations.AddDecoration( | 762 trailing_decorations.AddDecoration( |
| 775 vertical_edge_thickness(), location_height, open_pdf_in_reader_view_); | 763 vertical_edge_thickness(), location_height, open_pdf_in_reader_view_); |
| 776 } | 764 } |
| 777 if (manage_passwords_icon_view_->visible()) { | 765 if (manage_passwords_icon_view_->visible()) { |
| 778 trailing_decorations.AddDecoration(vertical_edge_thickness(), | 766 trailing_decorations.AddDecoration(vertical_edge_thickness(), |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 generated_credit_card_view_->Update(); | 1030 generated_credit_card_view_->Update(); |
| 1043 ZoomBubbleView::CloseBubble(); | 1031 ZoomBubbleView::CloseBubble(); |
| 1044 TranslateBubbleView::CloseBubble(); | 1032 TranslateBubbleView::CloseBubble(); |
| 1045 RefreshZoomView(); | 1033 RefreshZoomView(); |
| 1046 RefreshPageActionViews(); | 1034 RefreshPageActionViews(); |
| 1047 RefreshTranslateIcon(); | 1035 RefreshTranslateIcon(); |
| 1048 RefreshManagePasswordsIconView(); | 1036 RefreshManagePasswordsIconView(); |
| 1049 content::WebContents* web_contents_for_sub_views = | 1037 content::WebContents* web_contents_for_sub_views = |
| 1050 GetToolbarModel()->input_in_progress() ? NULL : GetWebContents(); | 1038 GetToolbarModel()->input_in_progress() ? NULL : GetWebContents(); |
| 1051 open_pdf_in_reader_view_->Update(web_contents_for_sub_views); | 1039 open_pdf_in_reader_view_->Update(web_contents_for_sub_views); |
| 1052 add_to_app_launcher_view_->Update(web_contents_for_sub_views); | |
| 1053 | 1040 |
| 1054 if (star_view_) { | 1041 if (star_view_) { |
| 1055 star_view_->SetVisible( | 1042 star_view_->SetVisible( |
| 1056 browser_defaults::bookmarks_enabled && !is_popup_mode_ && | 1043 browser_defaults::bookmarks_enabled && !is_popup_mode_ && |
| 1057 !GetToolbarModel()->input_in_progress() && | 1044 !GetToolbarModel()->input_in_progress() && |
| 1058 edit_bookmarks_enabled_.GetValue() && | 1045 edit_bookmarks_enabled_.GetValue() && |
| 1059 !IsBookmarkStarHiddenByExtension()); | 1046 !IsBookmarkStarHiddenByExtension()); |
| 1060 } | 1047 } |
| 1061 | 1048 |
| 1062 if (contents) | 1049 if (contents) |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 | 1749 |
| 1763 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1750 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
| 1764 const SearchModel::State& new_state) { | 1751 const SearchModel::State& new_state) { |
| 1765 const bool visible = !GetToolbarModel()->input_in_progress() && | 1752 const bool visible = !GetToolbarModel()->input_in_progress() && |
| 1766 new_state.voice_search_supported; | 1753 new_state.voice_search_supported; |
| 1767 if (mic_search_view_->visible() != visible) { | 1754 if (mic_search_view_->visible() != visible) { |
| 1768 mic_search_view_->SetVisible(visible); | 1755 mic_search_view_->SetVisible(visible); |
| 1769 Layout(); | 1756 Layout(); |
| 1770 } | 1757 } |
| 1771 } | 1758 } |
| OLD | NEW |