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 "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 } | 119 } |
120 | 120 |
121 } // namespace | 121 } // namespace |
122 | 122 |
123 | 123 |
124 // Globals -------------------------------------------------------------------- | 124 // Globals -------------------------------------------------------------------- |
125 | 125 |
126 namespace chrome { | 126 namespace chrome { |
127 | 127 |
128 void ShowManagePasswordsBubble(content::WebContents* web_contents) { | 128 void ShowManagePasswordsBubble(content::WebContents* web_contents) { |
129 if (ManagePasswordsBubbleView::IsShowing()) { | |
130 // IDC_MANAGE_PASSWORDS_FOR_PAGE command cann't open the bubble twice for | |
131 // the same tab. However, the bubble may be open in another tab. | |
132 DCHECK(ManagePasswordsBubbleView::Bubble()->web_contents() != web_contents); | |
Peter Kasting
2014/07/22 18:55:18
If this DCHECK is the only reason to expose web_co
vasilii
2014/07/23 09:22:53
Done.
| |
133 ManagePasswordsBubbleView::CloseBubble(); | |
134 } | |
129 ManagePasswordsUIController* controller = | 135 ManagePasswordsUIController* controller = |
130 ManagePasswordsUIController::FromWebContents(web_contents); | 136 ManagePasswordsUIController::FromWebContents(web_contents); |
131 ManagePasswordsBubbleView::ShowBubble( | 137 ManagePasswordsBubbleView::ShowBubble( |
132 web_contents, | 138 web_contents, |
133 controller->state() == | 139 controller->state() == |
134 password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE | 140 password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE |
135 ? ManagePasswordsBubbleView::AUTOMATIC | 141 ? ManagePasswordsBubbleView::AUTOMATIC |
136 : ManagePasswordsBubbleView::USER_ACTION); | 142 : ManagePasswordsBubbleView::USER_ACTION); |
137 } | 143 } |
138 | 144 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
427 parent_->Close(); | 433 parent_->Close(); |
428 } | 434 } |
429 | 435 |
430 // ManagePasswordsBubbleView -------------------------------------------------- | 436 // ManagePasswordsBubbleView -------------------------------------------------- |
431 | 437 |
432 // static | 438 // static |
433 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = | 439 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = |
434 NULL; | 440 NULL; |
435 | 441 |
436 // static | 442 // static |
437 const ManagePasswordsBubbleView* ManagePasswordsBubbleView::Bubble() { | |
438 return ManagePasswordsBubbleView::manage_passwords_bubble_; | |
439 } | |
440 | |
441 // static | |
442 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, | 443 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, |
443 DisplayReason reason) { | 444 DisplayReason reason) { |
444 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 445 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
445 DCHECK(browser); | 446 DCHECK(browser); |
446 DCHECK(browser->window()); | 447 DCHECK(browser->window()); |
447 DCHECK(browser->fullscreen_controller()); | 448 DCHECK(browser->fullscreen_controller()); |
448 | 449 |
449 if (IsShowing()) | 450 if (IsShowing()) |
450 return; | 451 return; |
451 | 452 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 manage_passwords_bubble_->Close(); | 487 manage_passwords_bubble_->Close(); |
487 } | 488 } |
488 | 489 |
489 // static | 490 // static |
490 bool ManagePasswordsBubbleView::IsShowing() { | 491 bool ManagePasswordsBubbleView::IsShowing() { |
491 // The bubble may be in the process of closing. | 492 // The bubble may be in the process of closing. |
492 return (manage_passwords_bubble_ != NULL) && | 493 return (manage_passwords_bubble_ != NULL) && |
493 manage_passwords_bubble_->GetWidget()->IsVisible(); | 494 manage_passwords_bubble_->GetWidget()->IsVisible(); |
494 } | 495 } |
495 | 496 |
497 // static | |
498 const ManagePasswordsBubbleView* ManagePasswordsBubbleView::Bubble() { | |
499 return ManagePasswordsBubbleView::manage_passwords_bubble_; | |
500 } | |
501 | |
502 content::WebContents* ManagePasswordsBubbleView::web_contents() const { | |
503 return model()->web_contents(); | |
504 } | |
505 | |
496 ManagePasswordsBubbleView::ManagePasswordsBubbleView( | 506 ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
497 content::WebContents* web_contents, | 507 content::WebContents* web_contents, |
498 ManagePasswordsIconView* anchor_view, | 508 ManagePasswordsIconView* anchor_view, |
499 DisplayReason reason) | 509 DisplayReason reason) |
500 : ManagePasswordsBubble(web_contents, reason), | 510 : ManagePasswordsBubble(web_contents, reason), |
501 BubbleDelegateView(anchor_view, | 511 BubbleDelegateView(anchor_view, |
502 anchor_view ? views::BubbleBorder::TOP_RIGHT | 512 anchor_view ? views::BubbleBorder::TOP_RIGHT |
503 : views::BubbleBorder::NONE), | 513 : views::BubbleBorder::NONE), |
504 anchor_view_(anchor_view), | 514 anchor_view_(anchor_view), |
505 never_save_passwords_(false) { | 515 never_save_passwords_(false) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 | 586 |
577 void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() { | 587 void ManagePasswordsBubbleView::NotifyConfirmedNeverForThisSite() { |
578 model()->OnNeverForThisSiteClicked(); | 588 model()->OnNeverForThisSiteClicked(); |
579 Close(); | 589 Close(); |
580 } | 590 } |
581 | 591 |
582 void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { | 592 void ManagePasswordsBubbleView::NotifyUndoNeverForThisSite() { |
583 never_save_passwords_ = false; | 593 never_save_passwords_ = false; |
584 Refresh(); | 594 Refresh(); |
585 } | 595 } |
OLD | NEW |