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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/location_bar/location_bar_view.cc
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index c488fb8a0782ccc1d43fb9fafe6b71ce77c13449..f1561f11483e9d066398b0b266393186d2f52fcb 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -52,6 +52,7 @@
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h"
#include "chrome/browser/ui/views/translate/translate_bubble_view.h"
#include "chrome/browser/ui/views/translate/translate_icon_view.h"
+#include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
#include "chrome/grit/generated_resources.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
#include "components/favicon/content/content_favicon_driver.h"
@@ -150,6 +151,9 @@ LocationBarView::LocationBarView(Browser* browser,
base::Bind(&LocationBarView::UpdateWithoutTabRestore,
base::Unretained(this)));
+ if (browser_)
+ browser_->tab_strip_model()->AddObserver(this);
+
ui_zoom::ZoomEventManager::GetForBrowserContext(profile)
->AddZoomEventManagerObserver(this);
}
@@ -158,6 +162,9 @@ LocationBarView::~LocationBarView() {
if (template_url_service_)
template_url_service_->RemoveObserver(this);
+ if (browser_)
+ browser_->tab_strip_model()->RemoveObserver(this);
+
ui_zoom::ZoomEventManager::GetForBrowserContext(profile())
->RemoveZoomEventManagerObserver(this);
}
@@ -835,6 +842,51 @@ WebContents* LocationBarView::GetWebContents() {
}
////////////////////////////////////////////////////////////////////////////////
+// LocationBarView, public TabStripModelObserver implementation:
+
+void LocationBarView::TabDetachedAt(content::WebContents* contents, int index) {
+ if (PermissionBubbleManager::FromWebContents(contents))
+ PermissionBubbleManager::FromWebContents(contents)->HideBubble();
+}
+
+void LocationBarView::TabDeactivated(content::WebContents* contents) {
+ if (PermissionBubbleManager::FromWebContents(contents))
+ PermissionBubbleManager::FromWebContents(contents)->HideBubble();
+}
+
+void LocationBarView::ActiveTabChanged(content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index,
+ int reason) {
+ // Hide the permission bubble on the old web contents if present and open a
+ // new one if there are pending requests on the new web contents.
+ if (old_contents && PermissionBubbleManager::FromWebContents(old_contents))
+ PermissionBubbleManager::FromWebContents(old_contents)->HideBubble();
+
+ if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) {
+ PermissionBubbleManager::FromWebContents(new_contents)
+ ->DisplayPendingRequests();
+ }
+
+ // Hide the save card, translate, and zoom bubbles if present.
+ if (old_contents &&
+ autofill::SaveCardBubbleControllerImpl::FromWebContents(old_contents)) {
+ autofill::SaveCardBubbleControllerImpl::FromWebContents(old_contents)
+ ->HideBubble();
+ }
+
+ TranslateBubbleView::CloseCurrentBubble();
+ ZoomBubbleView::CloseCurrentBubble();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// LocationBarView, public ZoomEventManagerObserver implementation:
+
+void LocationBarView::OnDefaultZoomLevelChanged() {
+ RefreshZoomView();
+}
+
+////////////////////////////////////////////////////////////////////////////////
// LocationBarView, private:
int LocationBarView::IncrementalMinimumWidth(views::View* view) const {
@@ -987,10 +1039,6 @@ bool LocationBarView::RefreshZoomView() {
return was_visible != zoom_view_->visible();
}
-void LocationBarView::OnDefaultZoomLevelChanged() {
- RefreshZoomView();
-}
-
bool LocationBarView::RefreshSaveCreditCardIconView() {
WebContents* web_contents = GetWebContents();
if (!web_contents)
« 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