Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "chrome/browser/ui/cocoa/passwords/passwords_bubble_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/passwords/passwords_bubble_cocoa.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | |
| 7 #include "base/mac/scoped_block.h" | 8 #include "base/mac/scoped_block.h" |
| 8 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
| 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 11 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | |
| 10 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 12 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 11 #include "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" | 13 #include "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" |
| 12 #import "chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.h" | 14 #import "chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.h" |
| 13 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" | 15 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" |
| 14 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 15 | 17 |
| 16 typedef void (^Callback)(void); | 18 typedef void (^Callback)(void); |
| 17 | 19 |
| 18 @interface ManagePasswordsBubbleCocoaNotificationBridge : NSObject { | 20 @interface ManagePasswordsBubbleCocoaNotificationBridge : NSObject { |
| 19 base::mac::ScopedBlock<Callback> callback_; | 21 base::mac::ScopedBlock<Callback> callback_; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 } | 95 } |
| 94 } | 96 } |
| 95 | 97 |
| 96 void ManagePasswordsBubbleCocoa::OnClose() { | 98 void ManagePasswordsBubbleCocoa::OnClose() { |
| 97 delete this; | 99 delete this; |
| 98 } | 100 } |
| 99 | 101 |
| 100 // static | 102 // static |
| 101 void ManagePasswordsBubbleCocoa::Show(content::WebContents* webContents, | 103 void ManagePasswordsBubbleCocoa::Show(content::WebContents* webContents, |
| 102 bool user_action) { | 104 bool user_action) { |
| 103 if (bubble_ && (bubble_->webContents_ != webContents)) { | 105 if (bubble_) { |
| 104 // The bubble is currently shown for some other tab. We should close it now | 106 // The bubble is currently shown it should be reopened with the new content. |
|
vabr (Chromium)
2016/05/30 08:36:41
nit: Split the sentence between "shown it"?
...cur
vasilii
2016/05/30 08:43:02
Done.
| |
| 105 // and open for |webContents|. | 107 // Disable closing animation so that it's destroyed immediately. |
| 108 InfoBubbleWindow* window = base::mac::ObjCCastStrict<InfoBubbleWindow>( | |
| 109 [bubble_->controller_ window]); | |
| 110 [window setAllowedAnimations:info_bubble::kAnimateNone]; | |
| 106 bubble_->Close(); | 111 bubble_->Close(); |
| 107 } | 112 } |
| 108 if (bubble_) | 113 DCHECK(!bubble_); |
| 109 return; | |
| 110 | 114 |
| 111 NSWindow* window = [webContents->GetNativeView() window]; | 115 NSWindow* window = [webContents->GetNativeView() window]; |
| 112 if (!window) { | 116 if (!window) { |
| 113 // The tab isn't active right now. | 117 // The tab isn't active right now. |
| 114 return; | 118 return; |
| 115 } | 119 } |
| 116 BrowserWindowController* bwc = | 120 BrowserWindowController* bwc = |
| 117 [BrowserWindowController browserWindowControllerForWindow:window]; | 121 [BrowserWindowController browserWindowControllerForWindow:window]; |
| 118 bubble_ = new ManagePasswordsBubbleCocoa( | 122 bubble_ = new ManagePasswordsBubbleCocoa( |
| 119 webContents, user_action ? ManagePasswordsBubbleModel::USER_ACTION | 123 webContents, user_action ? ManagePasswordsBubbleModel::USER_ACTION |
| 120 : ManagePasswordsBubbleModel::AUTOMATIC, | 124 : ManagePasswordsBubbleModel::AUTOMATIC, |
| 121 [bwc locationBarBridge]->manage_passwords_decoration()->icon()); | 125 [bwc locationBarBridge]->manage_passwords_decoration()->icon()); |
| 122 | 126 |
| 123 bubble_->Show(user_action); | 127 bubble_->Show(user_action); |
| 124 } | 128 } |
| OLD | NEW |