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

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

Issue 1813043002: Move the hiding of Views location bar bubbles into LocationBarView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move bubble hiding into LocationBarView Created 4 years, 9 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
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" 45 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
46 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" 46 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
47 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" 47 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
48 #include "chrome/browser/ui/views/location_bar/star_view.h" 48 #include "chrome/browser/ui/views/location_bar/star_view.h"
49 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" 49 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
50 #include "chrome/browser/ui/views/location_bar/zoom_view.h" 50 #include "chrome/browser/ui/views/location_bar/zoom_view.h"
51 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 51 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
52 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" 52 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h"
53 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" 53 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
54 #include "chrome/browser/ui/views/translate/translate_icon_view.h" 54 #include "chrome/browser/ui/views/translate/translate_icon_view.h"
55 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
55 #include "chrome/grit/generated_resources.h" 56 #include "chrome/grit/generated_resources.h"
56 #include "components/bookmarks/common/bookmark_pref_names.h" 57 #include "components/bookmarks/common/bookmark_pref_names.h"
57 #include "components/favicon/content/content_favicon_driver.h" 58 #include "components/favicon/content/content_favicon_driver.h"
58 #include "components/omnibox/browser/omnibox_popup_model.h" 59 #include "components/omnibox/browser/omnibox_popup_model.h"
59 #include "components/omnibox/browser/omnibox_popup_view.h" 60 #include "components/omnibox/browser/omnibox_popup_view.h"
60 #include "components/prefs/pref_service.h" 61 #include "components/prefs/pref_service.h"
61 #include "components/search_engines/template_url.h" 62 #include "components/search_engines/template_url.h"
62 #include "components/search_engines/template_url_service.h" 63 #include "components/search_engines/template_url_service.h"
63 #include "components/toolbar/toolbar_model.h" 64 #include "components/toolbar/toolbar_model.h"
64 #include "components/translate/core/browser/language_state.h" 65 #include "components/translate/core/browser/language_state.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 size_animation_(this), 144 size_animation_(this),
144 is_popup_mode_(is_popup_mode), 145 is_popup_mode_(is_popup_mode),
145 show_focus_rect_(false), 146 show_focus_rect_(false),
146 template_url_service_(NULL), 147 template_url_service_(NULL),
147 web_contents_null_at_last_refresh_(true) { 148 web_contents_null_at_last_refresh_(true) {
148 edit_bookmarks_enabled_.Init( 149 edit_bookmarks_enabled_.Init(
149 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), 150 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(),
150 base::Bind(&LocationBarView::UpdateWithoutTabRestore, 151 base::Bind(&LocationBarView::UpdateWithoutTabRestore,
151 base::Unretained(this))); 152 base::Unretained(this)));
152 153
154 if (browser_)
155 browser_->tab_strip_model()->AddObserver(this);
156
153 ui_zoom::ZoomEventManager::GetForBrowserContext(profile) 157 ui_zoom::ZoomEventManager::GetForBrowserContext(profile)
154 ->AddZoomEventManagerObserver(this); 158 ->AddZoomEventManagerObserver(this);
155 } 159 }
156 160
157 LocationBarView::~LocationBarView() { 161 LocationBarView::~LocationBarView() {
158 if (template_url_service_) 162 if (template_url_service_)
159 template_url_service_->RemoveObserver(this); 163 template_url_service_->RemoveObserver(this);
160 164
165 if (browser_)
166 browser_->tab_strip_model()->RemoveObserver(this);
167
161 ui_zoom::ZoomEventManager::GetForBrowserContext(profile()) 168 ui_zoom::ZoomEventManager::GetForBrowserContext(profile())
162 ->RemoveZoomEventManagerObserver(this); 169 ->RemoveZoomEventManagerObserver(this);
163 } 170 }
164 171
165 //////////////////////////////////////////////////////////////////////////////// 172 ////////////////////////////////////////////////////////////////////////////////
166 // LocationBarView, public: 173 // LocationBarView, public:
167 174
168 // static 175 // static
169 SkColor LocationBarView::GetBorderColor(bool incognito) { 176 SkColor LocationBarView::GetBorderColor(bool incognito) {
170 return color_utils::AlphaBlend( 177 return color_utils::AlphaBlend(
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 835
829 ToolbarModel* LocationBarView::GetToolbarModel() { 836 ToolbarModel* LocationBarView::GetToolbarModel() {
830 return delegate_->GetToolbarModel(); 837 return delegate_->GetToolbarModel();
831 } 838 }
832 839
833 WebContents* LocationBarView::GetWebContents() { 840 WebContents* LocationBarView::GetWebContents() {
834 return delegate_->GetWebContents(); 841 return delegate_->GetWebContents();
835 } 842 }
836 843
837 //////////////////////////////////////////////////////////////////////////////// 844 ////////////////////////////////////////////////////////////////////////////////
845 // LocationBarView, public TabStripModelObserver implementation:
846
847 void LocationBarView::TabDetachedAt(content::WebContents* contents, int index) {
848 if (PermissionBubbleManager::FromWebContents(contents))
849 PermissionBubbleManager::FromWebContents(contents)->HideBubble();
850 }
851
852 void LocationBarView::TabDeactivated(content::WebContents* contents) {
853 if (PermissionBubbleManager::FromWebContents(contents))
854 PermissionBubbleManager::FromWebContents(contents)->HideBubble();
855 }
856
857 void LocationBarView::ActiveTabChanged(content::WebContents* old_contents,
858 content::WebContents* new_contents,
859 int index,
860 int reason) {
861 // Hide the permission bubble on the old web contents if present and open a
862 // new one if there are pending requests on the new web contents.
863 if (old_contents && PermissionBubbleManager::FromWebContents(old_contents))
864 PermissionBubbleManager::FromWebContents(old_contents)->HideBubble();
865
866 if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) {
867 PermissionBubbleManager::FromWebContents(new_contents)
868 ->DisplayPendingRequests();
869 }
870
871 // Hide the save card, translate, and zoom bubbles if present.
872 if (old_contents &&
873 autofill::SaveCardBubbleControllerImpl::FromWebContents(old_contents)) {
874 autofill::SaveCardBubbleControllerImpl::FromWebContents(old_contents)
875 ->HideBubble();
876 }
877
878 TranslateBubbleView::CloseCurrentBubble();
879 ZoomBubbleView::CloseCurrentBubble();
880 }
881
882 ////////////////////////////////////////////////////////////////////////////////
883 // LocationBarView, public ZoomEventManagerObserver implementation:
884
885 void LocationBarView::OnDefaultZoomLevelChanged() {
886 RefreshZoomView();
887 }
888
889 ////////////////////////////////////////////////////////////////////////////////
838 // LocationBarView, private: 890 // LocationBarView, private:
839 891
840 int LocationBarView::IncrementalMinimumWidth(views::View* view) const { 892 int LocationBarView::IncrementalMinimumWidth(views::View* view) const {
841 return view->visible() ? 893 return view->visible() ?
842 (GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING) + 894 (GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING) +
843 view->GetMinimumSize().width()) : 0; 895 view->GetMinimumSize().width()) : 0;
844 } 896 }
845 897
846 int LocationBarView::GetHorizontalEdgeThickness() const { 898 int LocationBarView::GetHorizontalEdgeThickness() const {
847 return is_popup_mode_ ? 0 : GetLayoutConstant(LOCATION_BAR_BORDER_THICKNESS); 899 return is_popup_mode_ ? 0 : GetLayoutConstant(LOCATION_BAR_BORDER_THICKNESS);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 WebContents* web_contents = GetWebContents(); 1032 WebContents* web_contents = GetWebContents();
981 if (!web_contents) 1033 if (!web_contents)
982 return false; 1034 return false;
983 const bool was_visible = zoom_view_->visible(); 1035 const bool was_visible = zoom_view_->visible();
984 zoom_view_->Update(ui_zoom::ZoomController::FromWebContents(web_contents)); 1036 zoom_view_->Update(ui_zoom::ZoomController::FromWebContents(web_contents));
985 if (!zoom_view_->visible()) 1037 if (!zoom_view_->visible())
986 ZoomBubbleView::CloseCurrentBubble(); 1038 ZoomBubbleView::CloseCurrentBubble();
987 return was_visible != zoom_view_->visible(); 1039 return was_visible != zoom_view_->visible();
988 } 1040 }
989 1041
990 void LocationBarView::OnDefaultZoomLevelChanged() {
991 RefreshZoomView();
992 }
993
994 bool LocationBarView::RefreshSaveCreditCardIconView() { 1042 bool LocationBarView::RefreshSaveCreditCardIconView() {
995 WebContents* web_contents = GetWebContents(); 1043 WebContents* web_contents = GetWebContents();
996 if (!web_contents) 1044 if (!web_contents)
997 return false; 1045 return false;
998 1046
999 const bool was_visible = save_credit_card_icon_view_->visible(); 1047 const bool was_visible = save_credit_card_icon_view_->visible();
1000 // |controller| may be nullptr due to lazy initialization. 1048 // |controller| may be nullptr due to lazy initialization.
1001 autofill::SaveCardBubbleControllerImpl* controller = 1049 autofill::SaveCardBubbleControllerImpl* controller =
1002 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents); 1050 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents);
1003 bool enabled = controller && controller->IsIconVisible(); 1051 bool enabled = controller && controller->IsIconVisible();
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 // LocationBarView, private TemplateURLServiceObserver implementation: 1436 // LocationBarView, private TemplateURLServiceObserver implementation:
1389 1437
1390 void LocationBarView::OnTemplateURLServiceChanged() { 1438 void LocationBarView::OnTemplateURLServiceChanged() {
1391 template_url_service_->RemoveObserver(this); 1439 template_url_service_->RemoveObserver(this);
1392 template_url_service_ = nullptr; 1440 template_url_service_ = nullptr;
1393 // If the browser is no longer active, let's not show the info bubble, as this 1441 // If the browser is no longer active, let's not show the info bubble, as this
1394 // would make the browser the active window again. 1442 // would make the browser the active window again.
1395 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) 1443 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive())
1396 ShowFirstRunBubble(); 1444 ShowFirstRunBubble();
1397 } 1445 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698