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/foundation_util.h" |
8 #include "base/mac/scoped_block.h" | 8 #include "base/mac/scoped_block.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" |
11 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 11 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
12 #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" |
13 #include "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" | 13 #include "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" |
14 #import "chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.h" | 14 #import "chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.h" |
15 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" | 15 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" |
16 #include "chrome/browser/ui/passwords/passwords_model_delegate.h" | 16 #include "chrome/browser/ui/passwords/passwords_model_delegate.h" |
17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
18 #include "ui/base/material_design/material_design_controller.h" | |
18 | 19 |
19 typedef void (^Callback)(void); | 20 typedef void (^Callback)(void); |
20 | 21 |
21 @interface ManagePasswordsBubbleCocoaNotificationBridge : NSObject { | 22 @interface ManagePasswordsBubbleCocoaNotificationBridge : NSObject { |
22 base::mac::ScopedBlock<Callback> callback_; | 23 base::mac::ScopedBlock<Callback> callback_; |
23 } | 24 } |
24 - (id)initWithCallback:(Callback)callback; | 25 - (id)initWithCallback:(Callback)callback; |
25 - (void)onClose; | 26 - (void)onClose; |
26 @end | 27 @end |
27 | 28 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 Close(false); | 103 Close(false); |
103 } | 104 } |
104 | 105 |
105 void ManagePasswordsBubbleCocoa::OnClose() { | 106 void ManagePasswordsBubbleCocoa::OnClose() { |
106 delete this; | 107 delete this; |
107 } | 108 } |
108 | 109 |
109 // static | 110 // static |
110 void ManagePasswordsBubbleCocoa::Show(content::WebContents* webContents, | 111 void ManagePasswordsBubbleCocoa::Show(content::WebContents* webContents, |
111 bool user_action) { | 112 bool user_action) { |
113 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | |
tapted
2017/04/11 07:48:58
I think it's fine to move this down to line 140 so
varkha
2017/04/12 01:57:28
Done.
| |
114 NSWindow* window = [webContents->GetNativeView() window]; | |
115 if (!window) { | |
116 // The tab isn't active right now. | |
117 return; | |
118 } | |
119 BrowserWindowController* bwc = | |
120 [BrowserWindowController browserWindowControllerForWindow:window]; | |
121 NSPoint ns_point = [bwc bookmarkBubblePoint]; | |
tapted
2017/04/11 07:48:58
nit: ns_point -> anchor?
varkha
2017/04/12 01:57:28
Done.
| |
122 ShowManagePasswordsBubbleOnCocoaBrowser(ns_point, webContents, user_action); | |
123 return; | |
124 } | |
125 | |
112 if (bubble_) { | 126 if (bubble_) { |
113 // The bubble is currently shown. It's to be reopened with the new content. | 127 // The bubble is currently shown. It's to be reopened with the new content. |
114 // Disable closing animation so that it's destroyed immediately. | 128 // Disable closing animation so that it's destroyed immediately. |
115 bubble_->Close(true); | 129 bubble_->Close(true); |
116 } | 130 } |
117 DCHECK(!bubble_); | 131 DCHECK(!bubble_); |
118 | 132 |
119 NSWindow* window = [webContents->GetNativeView() window]; | 133 NSWindow* window = [webContents->GetNativeView() window]; |
120 if (!window) { | 134 if (!window) { |
121 // The tab isn't active right now. | 135 // The tab isn't active right now. |
122 return; | 136 return; |
123 } | 137 } |
124 BrowserWindowController* bwc = | 138 BrowserWindowController* bwc = |
125 [BrowserWindowController browserWindowControllerForWindow:window]; | 139 [BrowserWindowController browserWindowControllerForWindow:window]; |
126 bubble_ = new ManagePasswordsBubbleCocoa( | 140 bubble_ = new ManagePasswordsBubbleCocoa( |
127 webContents, user_action ? ManagePasswordsBubbleModel::USER_ACTION | 141 webContents, user_action ? ManagePasswordsBubbleModel::USER_ACTION |
128 : ManagePasswordsBubbleModel::AUTOMATIC, | 142 : ManagePasswordsBubbleModel::AUTOMATIC, |
129 [bwc locationBarBridge]->manage_passwords_decoration()->icon()); | 143 [bwc locationBarBridge]->manage_passwords_decoration()->icon()); |
130 | 144 |
131 bubble_->Show(user_action); | 145 bubble_->Show(user_action); |
132 } | 146 } |
OLD | NEW |