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

Unified Diff: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc

Issue 2808823002: MacViews: Allows the toolkit-views Manage Passwords Dialog to be used (Closed)
Patch Set: MacViews: Allows the toolkit-views Manage Passwords Dialog to be used Created 3 years, 8 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
Index: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
diff --git a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
index 31b70dac9c8aff19cd40e29dffdb63dfc4cca9b8..1cad30ff7d3bf4de0dba301f734f33bd4c399f11 100644
--- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
+++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
@@ -11,13 +11,13 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/browser/ui/passwords/password_dialog_prompts.h"
#include "chrome/browser/ui/passwords/passwords_model_delegate.h"
-#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/harmony/layout_delegate.h"
#include "chrome/browser/ui/views/passwords/credentials_item_view.h"
-#include "chrome/browser/ui/views/passwords/credentials_selection_view.h"
+#include "chrome/browser/ui/views/passwords/credentials_selection_view_views.h"
#include "chrome/browser/ui/views/passwords/manage_password_items_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h"
#include "chrome/grit/generated_resources.h"
@@ -25,6 +25,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_features.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/native_theme/native_theme.h"
@@ -40,11 +41,16 @@
#include "ui/views/layout/layout_constants.h"
#include "ui/views/widget/widget.h"
+#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
+#include "chrome/browser/ui/views/frame/browser_view.h"
+#endif
+
#if defined(OS_WIN)
#include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bubble_view.h"
#endif
int ManagePasswordsBubbleView::auto_signin_toast_timeout_ = 3;
+bool g_bubble_shown_ = false;
// Helpers --------------------------------------------------------------------
@@ -199,10 +205,12 @@ class ManagePasswordsBubbleView::AutoSigninView
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
+#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
// views::WidgetObserver:
// Tracks the state of the browser window.
void OnWidgetActivationChanged(views::Widget* widget, bool active) override;
void OnWidgetClosing(views::Widget* widget) override;
+#endif
void OnTimer();
static base::TimeDelta GetTimeout() {
@@ -236,10 +244,15 @@ ManagePasswordsBubbleView::AutoSigninView::AutoSigninView(
Browser* browser =
chrome::FindBrowserWithWebContents(parent_->web_contents());
DCHECK(browser);
+
+// On MacOS the BrowserView should but does not yet exist. The auto-sign-in
tapted 2017/04/11 07:48:58 instead of The auto-sign-in... perhaps Auto-close
varkha 2017/04/12 01:57:28 Done.
+// bubble may not auto-close when it gets created in a non-active browser.
+// See http://crbug.com/468281.
+#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
observed_browser_.Add(browser_view->GetWidget());
-
- if (browser_view->IsActive())
+#endif
+ if (browser->window()->IsActive())
timer_.Start(FROM_HERE, GetTimeout(), this, &AutoSigninView::OnTimer);
}
@@ -248,6 +261,7 @@ void ManagePasswordsBubbleView::AutoSigninView::ButtonPressed(
NOTREACHED();
}
+#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
void ManagePasswordsBubbleView::AutoSigninView::OnWidgetActivationChanged(
views::Widget* widget, bool active) {
if (active && !timer_.IsRunning())
@@ -258,6 +272,7 @@ void ManagePasswordsBubbleView::AutoSigninView::OnWidgetClosing(
views::Widget* widget) {
observed_browser_.RemoveAll();
}
+#endif
void ManagePasswordsBubbleView::AutoSigninView::OnTimer() {
parent_->model()->OnAutoSignInToastTimeout();
@@ -698,6 +713,7 @@ void ManagePasswordsBubbleView::UpdatePendingView::StyledLabelLinkClicked(
ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ =
NULL;
+#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
// static
void ManagePasswordsBubbleView::ShowBubble(
content::WebContents* web_contents,
@@ -720,7 +736,7 @@ void ManagePasswordsBubbleView::ShowBubble(
}
}
manage_passwords_bubble_ = new ManagePasswordsBubbleView(
- web_contents, anchor_view, reason);
+ web_contents, anchor_view, gfx::Point(), reason);
if (is_fullscreen)
manage_passwords_bubble_->set_parent_window(web_contents->GetNativeView());
@@ -740,6 +756,7 @@ void ManagePasswordsBubbleView::ShowBubble(
manage_passwords_bubble_->ShowForReason(reason);
}
+#endif // !OS_MACOSX || MAC_VIEWS_BROWSER
// static
void ManagePasswordsBubbleView::CloseCurrentBubble() {
@@ -754,6 +771,11 @@ void ManagePasswordsBubbleView::ActivateBubble() {
manage_passwords_bubble_->GetWidget()->Activate();
}
+// static
+bool ManagePasswordsBubbleView::IsBubbleShown() {
+ return g_bubble_shown_;
+}
+
content::WebContents* ManagePasswordsBubbleView::web_contents() const {
return model_.GetWebContents();
}
@@ -761,8 +783,12 @@ content::WebContents* ManagePasswordsBubbleView::web_contents() const {
ManagePasswordsBubbleView::ManagePasswordsBubbleView(
content::WebContents* web_contents,
views::View* anchor_view,
+ const gfx::Point& anchor_point,
DisplayReason reason)
- : LocationBarBubbleDelegateView(anchor_view, web_contents),
+ : LocationBarBubbleDelegateView(anchor_view,
+ anchor_point,
+ views::BubbleBorder::TOP_RIGHT,
+ web_contents),
model_(PasswordsModelDelegateFromWebContents(web_contents),
reason == AUTOMATIC ? ManagePasswordsBubbleModel::AUTOMATIC
: ManagePasswordsBubbleModel::USER_ACTION),
@@ -774,6 +800,7 @@ ManagePasswordsBubbleView::ManagePasswordsBubbleView(
gfx::Insets(LayoutDelegate::Get()->GetMetric(
LayoutDelegate::Metric::PANEL_CONTENT_MARGIN),
side_margin, 0, side_margin));
+ g_bubble_shown_ = true;
}
ManagePasswordsBubbleView::~ManagePasswordsBubbleView() {
@@ -828,6 +855,10 @@ bool ManagePasswordsBubbleView::ShouldShowCloseButton() const {
model_.state() == password_manager::ui::CHROME_DESKTOP_IOS_PROMO_STATE;
}
+void ManagePasswordsBubbleView::OnWidgetDestroying(views::Widget* widget) {
+ g_bubble_shown_ = false;
tapted 2017/04/11 07:48:58 Does this work just as well in the destructor? --
varkha 2017/04/12 01:57:28 Done.
+}
+
void ManagePasswordsBubbleView::Refresh() {
RemoveAllChildViews(true);
initially_focused_view_ = NULL;

Powered by Google App Engine
This is Rietveld 408576698