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/manage_passwords_bubble_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.h" |
6 | 6 |
7 #include "base/mac/scoped_block.h" | 7 #include "base/mac/scoped_block.h" |
8 #include "chrome/browser/ui/browser_dialogs.h" | 8 #include "chrome/browser/ui/browser_dialogs.h" |
9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 ManagePasswordsBubbleCocoa* instance = ManagePasswordsBubbleCocoa::instance(); | 44 ManagePasswordsBubbleCocoa* instance = ManagePasswordsBubbleCocoa::instance(); |
45 if (instance && (instance->webContents_ != webContents)) { | 45 if (instance && (instance->webContents_ != webContents)) { |
46 // The bubble is currently shown for some other tab. We should close it now | 46 // The bubble is currently shown for some other tab. We should close it now |
47 // and open for |webContents|. | 47 // and open for |webContents|. |
48 instance->Close(); | 48 instance->Close(); |
49 } | 49 } |
50 | 50 |
51 ManagePasswordsUIController* controller = | 51 ManagePasswordsUIController* controller = |
52 ManagePasswordsUIController::FromWebContents(webContents); | 52 ManagePasswordsUIController::FromWebContents(webContents); |
53 NSWindow* window = webContents->GetTopLevelNativeWindow(); | 53 NSWindow* window = webContents->GetTopLevelNativeWindow(); |
| 54 if (!window) { |
| 55 // The tab isn't active right now. |
| 56 return; |
| 57 } |
54 BrowserWindowController* bwc = | 58 BrowserWindowController* bwc = |
55 [BrowserWindowController browserWindowControllerForWindow:window]; | 59 [BrowserWindowController browserWindowControllerForWindow:window]; |
56 ManagePasswordsBubbleCocoa::ShowBubble( | 60 ManagePasswordsBubbleCocoa::ShowBubble( |
57 webContents, | 61 webContents, |
58 password_manager::ui::IsAutomaticDisplayState(controller->state()) | 62 password_manager::ui::IsAutomaticDisplayState(controller->state()) |
59 ? ManagePasswordsBubble::AUTOMATIC | 63 ? ManagePasswordsBubble::AUTOMATIC |
60 : ManagePasswordsBubble::USER_ACTION, | 64 : ManagePasswordsBubble::USER_ACTION, |
61 [bwc locationBarBridge]->manage_passwords_decoration()->icon()); | 65 [bwc locationBarBridge]->manage_passwords_decoration()->icon()); |
62 } | 66 } |
63 } // namespace chrome | 67 } // namespace chrome |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 127 |
124 // static | 128 // static |
125 void ManagePasswordsBubbleCocoa::ShowBubble(content::WebContents* webContents, | 129 void ManagePasswordsBubbleCocoa::ShowBubble(content::WebContents* webContents, |
126 DisplayReason displayReason, | 130 DisplayReason displayReason, |
127 ManagePasswordsIcon* icon) { | 131 ManagePasswordsIcon* icon) { |
128 if (bubble_) | 132 if (bubble_) |
129 return; | 133 return; |
130 bubble_ = new ManagePasswordsBubbleCocoa(webContents, displayReason, icon); | 134 bubble_ = new ManagePasswordsBubbleCocoa(webContents, displayReason, icon); |
131 bubble_->Show(); | 135 bubble_->Show(); |
132 } | 136 } |
OLD | NEW |