| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/passwords/manage_passwords_bubble_view.h" | 5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 const autofill::PasswordForm& form = parent_->model()->pending_password(); | 220 const autofill::PasswordForm& form = parent_->model()->pending_password(); |
| 221 CredentialsItemView* credential = new CredentialsItemView( | 221 CredentialsItemView* credential = new CredentialsItemView( |
| 222 this, base::string16(), | 222 this, base::string16(), |
| 223 l10n_util::GetStringFUTF16(IDS_MANAGE_PASSWORDS_AUTO_SIGNIN_TITLE, | 223 l10n_util::GetStringFUTF16(IDS_MANAGE_PASSWORDS_AUTO_SIGNIN_TITLE, |
| 224 form.username_value), | 224 form.username_value), |
| 225 kButtonHoverColor, &form, | 225 kButtonHoverColor, &form, |
| 226 parent_->model()->GetProfile()->GetRequestContext()); | 226 parent_->model()->GetProfile()->GetRequestContext()); |
| 227 credential->SetEnabled(false); | 227 credential->SetEnabled(false); |
| 228 AddChildView(credential); | 228 AddChildView(credential); |
| 229 | 229 |
| 230 #if 0 |
| 230 // Setup the observer and maybe start the timer. | 231 // Setup the observer and maybe start the timer. |
| 231 Browser* browser = | 232 Browser* browser = |
| 232 chrome::FindBrowserWithWebContents(parent_->web_contents()); | 233 chrome::FindBrowserWithWebContents(parent_->web_contents()); |
| 233 DCHECK(browser); | 234 DCHECK(browser); |
| 234 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 235 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 235 observed_browser_.Add(browser_view->GetWidget()); | 236 observed_browser_.Add(browser_view->GetWidget()); |
| 236 | 237 |
| 237 if (browser_view->IsActive()) | 238 if (browser_view->IsActive()) |
| 238 timer_.Start(FROM_HERE, GetTimeout(), this, &AutoSigninView::OnTimer); | 239 timer_.Start(FROM_HERE, GetTimeout(), this, &AutoSigninView::OnTimer); |
| 240 #endif |
| 239 } | 241 } |
| 240 | 242 |
| 241 void ManagePasswordsBubbleView::AutoSigninView::ButtonPressed( | 243 void ManagePasswordsBubbleView::AutoSigninView::ButtonPressed( |
| 242 views::Button* sender, const ui::Event& event) { | 244 views::Button* sender, const ui::Event& event) { |
| 243 NOTREACHED(); | 245 NOTREACHED(); |
| 244 } | 246 } |
| 245 | 247 |
| 246 void ManagePasswordsBubbleView::AutoSigninView::OnWidgetActivationChanged( | 248 void ManagePasswordsBubbleView::AutoSigninView::OnWidgetActivationChanged( |
| 247 views::Widget* widget, bool active) { | 249 views::Widget* widget, bool active) { |
| 248 if (active && !timer_.IsRunning()) | 250 if (active && !timer_.IsRunning()) |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 // static | 713 // static |
| 712 void ManagePasswordsBubbleView::ShowBubble( | 714 void ManagePasswordsBubbleView::ShowBubble( |
| 713 content::WebContents* web_contents, | 715 content::WebContents* web_contents, |
| 714 DisplayReason reason) { | 716 DisplayReason reason) { |
| 715 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 717 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 716 DCHECK(browser); | 718 DCHECK(browser); |
| 717 DCHECK(browser->window()); | 719 DCHECK(browser->window()); |
| 718 DCHECK(!manage_passwords_bubble_ || | 720 DCHECK(!manage_passwords_bubble_ || |
| 719 !manage_passwords_bubble_->GetWidget()->IsVisible()); | 721 !manage_passwords_bubble_->GetWidget()->IsVisible()); |
| 720 | 722 |
| 723 views::View* anchor_view = nullptr; |
| 724 bool is_fullscreen = browser->window()->IsFullscreen(); |
| 725 #if 0 |
| 721 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 726 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 722 bool is_fullscreen = browser_view->IsFullscreen(); | |
| 723 views::View* anchor_view = nullptr; | |
| 724 if (!is_fullscreen) { | 727 if (!is_fullscreen) { |
| 725 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 728 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 726 anchor_view = browser_view->GetLocationBarView(); | 729 anchor_view = browser_view->GetLocationBarView(); |
| 727 } else { | 730 } else { |
| 728 anchor_view = | 731 anchor_view = |
| 729 browser_view->GetLocationBarView()->manage_passwords_icon_view(); | 732 browser_view->GetLocationBarView()->manage_passwords_icon_view(); |
| 730 } | 733 } |
| 731 } | 734 } |
| 735 #endif |
| 732 manage_passwords_bubble_ = new ManagePasswordsBubbleView( | 736 manage_passwords_bubble_ = new ManagePasswordsBubbleView( |
| 733 web_contents, anchor_view, reason); | 737 web_contents, anchor_view, reason); |
| 734 | 738 |
| 735 if (is_fullscreen) | 739 if (is_fullscreen) |
| 736 manage_passwords_bubble_->set_parent_window(web_contents->GetNativeView()); | 740 manage_passwords_bubble_->set_parent_window(web_contents->GetNativeView()); |
| 737 | 741 |
| 738 views::Widget* manage_passwords_bubble_widget = | 742 views::Widget* manage_passwords_bubble_widget = |
| 739 views::BubbleDialogDelegateView::CreateBubble(manage_passwords_bubble_); | 743 views::BubbleDialogDelegateView::CreateBubble(manage_passwords_bubble_); |
| 744 ALLOW_UNUSED_LOCAL(manage_passwords_bubble_widget); |
| 745 #if 0 |
| 740 if (anchor_view) { | 746 if (anchor_view) { |
| 741 manage_passwords_bubble_widget->AddObserver( | 747 manage_passwords_bubble_widget->AddObserver( |
| 742 browser_view->GetLocationBarView()->manage_passwords_icon_view()); | 748 browser_view->GetLocationBarView()->manage_passwords_icon_view()); |
| 743 } | 749 } |
| 744 | 750 |
| 745 // Adjust for fullscreen after creation as it relies on the content size. | 751 // Adjust for fullscreen after creation as it relies on the content size. |
| 746 if (is_fullscreen) { | 752 if (is_fullscreen) { |
| 747 manage_passwords_bubble_->AdjustForFullscreen( | 753 manage_passwords_bubble_->AdjustForFullscreen( |
| 748 browser_view->GetBoundsInScreen()); | 754 browser_view->GetBoundsInScreen()); |
| 749 } | 755 } |
| 756 #endif |
| 750 | 757 |
| 751 manage_passwords_bubble_->ShowForReason(reason); | 758 manage_passwords_bubble_->ShowForReason(reason); |
| 752 } | 759 } |
| 753 | 760 |
| 754 // static | 761 // static |
| 755 void ManagePasswordsBubbleView::CloseCurrentBubble() { | 762 void ManagePasswordsBubbleView::CloseCurrentBubble() { |
| 756 if (manage_passwords_bubble_) | 763 if (manage_passwords_bubble_) |
| 757 manage_passwords_bubble_->CloseBubble(); | 764 manage_passwords_bubble_->CloseBubble(); |
| 758 } | 765 } |
| 759 | 766 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 AddChildView(new SaveConfirmationView(this)); | 844 AddChildView(new SaveConfirmationView(this)); |
| 838 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { | 845 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { |
| 839 AddChildView(new AutoSigninView(this)); | 846 AddChildView(new AutoSigninView(this)); |
| 840 } else if (model_.state() == | 847 } else if (model_.state() == |
| 841 password_manager::ui::CHROME_SIGN_IN_PROMO_STATE) { | 848 password_manager::ui::CHROME_SIGN_IN_PROMO_STATE) { |
| 842 AddChildView(new SignInPromoView(this)); | 849 AddChildView(new SignInPromoView(this)); |
| 843 } else { | 850 } else { |
| 844 AddChildView(new ManageView(this)); | 851 AddChildView(new ManageView(this)); |
| 845 } | 852 } |
| 846 } | 853 } |
| OLD | NEW |