| Index: chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.mm
|
| diff --git a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.mm b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.mm
|
| index 3eb180f52917b55d0463987f9a4229f3499620d4..8672c4aaac24d52440501fb776d9ab31158b90b8 100644
|
| --- a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.mm
|
| +++ b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.mm
|
| @@ -7,7 +7,11 @@
|
| #include "base/mac/scoped_block.h"
|
| #include "chrome/browser/ui/browser_dialogs.h"
|
| #include "chrome/browser/ui/browser_finder.h"
|
| +#import "chrome/browser/ui/cocoa/browser_window_controller.h"
|
| +#include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
|
| +#include "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h"
|
| #import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_controller.h"
|
| +#include "chrome/browser/ui/passwords/manage_passwords_icon.h"
|
| #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
|
| #include "content/public/browser/web_contents.h"
|
|
|
| @@ -32,20 +36,45 @@ typedef void (^Callback)(void);
|
| }
|
| @end
|
|
|
| +namespace chrome {
|
| +void ShowManagePasswordsBubble(content::WebContents* webContents) {
|
| + if (ManagePasswordsBubbleCocoa::instance()) {
|
| + // The bubble is currently shown for some other tab. We should close it now
|
| + // and open for |webContents|.
|
| + ManagePasswordsBubbleCocoa::instance()->Close();
|
| + }
|
| + ManagePasswordsUIController* controller =
|
| + ManagePasswordsUIController::FromWebContents(webContents);
|
| + NSWindow* window = webContents->GetTopLevelNativeWindow();
|
| + BrowserWindowController* bwc =
|
| + [BrowserWindowController browserWindowControllerForWindow:window];
|
| + ManagePasswordsBubbleCocoa::ShowBubble(
|
| + webContents,
|
| + password_manager::ui::IsAutomaticDisplayState(controller->state())
|
| + ? ManagePasswordsBubble::AUTOMATIC
|
| + : ManagePasswordsBubble::USER_ACTION,
|
| + [bwc locationBarBridge]->manage_passwords_decoration()->icon());
|
| +}
|
| +} // namespace chrome
|
| +
|
| ManagePasswordsBubbleCocoa::ManagePasswordsBubbleCocoa(
|
| content::WebContents* webContents,
|
| - DisplayReason displayReason)
|
| + DisplayReason displayReason,
|
| + ManagePasswordsIcon* icon)
|
| : ManagePasswordsBubble(webContents, displayReason),
|
| + icon_(icon),
|
| closing_(false),
|
| controller_(nil),
|
| webContents_(webContents),
|
| bridge_(nil) {
|
| + icon_->SetActive(true);
|
| }
|
|
|
| ManagePasswordsBubbleCocoa::~ManagePasswordsBubbleCocoa() {
|
| [[NSNotificationCenter defaultCenter] removeObserver:bridge_];
|
| // Clear the global instance pointer.
|
| bubble_ = NULL;
|
| + icon_->SetActive(false);
|
| }
|
|
|
| ManagePasswordsBubbleCocoa* ManagePasswordsBubbleCocoa::bubble_ = NULL;
|
| @@ -89,9 +118,10 @@ void ManagePasswordsBubbleCocoa::OnClose() {
|
|
|
| // static
|
| void ManagePasswordsBubbleCocoa::ShowBubble(content::WebContents* webContents,
|
| - DisplayReason displayReason) {
|
| + DisplayReason displayReason,
|
| + ManagePasswordsIcon* icon) {
|
| if (bubble_)
|
| return;
|
| - bubble_ = new ManagePasswordsBubbleCocoa(webContents, displayReason);
|
| + bubble_ = new ManagePasswordsBubbleCocoa(webContents, displayReason, icon);
|
| bubble_->Show();
|
| }
|
|
|