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 54771cb6040e073dbfb8cc03a5eee371f0cd23a3..04ca6a6add44aeb936e686bb66ee95c1bcfa3c37 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" |
@@ -35,20 +39,47 @@ typedef void (^Callback)(void); |
// static |
ManagePasswordsBubbleCocoa* ManagePasswordsBubbleCocoa::bubble_ = NULL; |
+namespace chrome { |
+void ShowManagePasswordsBubble(content::WebContents* webContents) { |
+ ManagePasswordsBubbleCocoa* instance = ManagePasswordsBubbleCocoa::instance(); |
+ if (instance && (instance->webContents_ != webContents)) { |
+ // The bubble is currently shown for some other tab. We should close it now |
+ // and open for |webContents|. |
+ 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); |
} |
void ManagePasswordsBubbleCocoa::Show() { |
@@ -90,9 +121,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(); |
} |