Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: chrome/browser/ui/cocoa/page_info/page_info_bubble_controller.mm

Issue 2797923003: Rename PageInfoPopupView to PageInfoBubbleView. (Closed)
Patch Set: Rename more stuff. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/page_info/page_info_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/page_info/page_info_bubble_controller.h"
6 6
7 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 // Padding between the window frame and content for the internal page bubble. 106 // Padding between the window frame and content for the internal page bubble.
107 const CGFloat kInternalPageFramePadding = 10; 107 const CGFloat kInternalPageFramePadding = 10;
108 108
109 // Spacing between the image and text for internal pages. 109 // Spacing between the image and text for internal pages.
110 const CGFloat kInternalPageImageSpacing = 10; 110 const CGFloat kInternalPageImageSpacing = 10;
111 111
112 // ----------------------------------------------------------------------------- 112 // -----------------------------------------------------------------------------
113 113
114 // NOTE: This assumes that there will never be more than one page info 114 // NOTE: This assumes that there will never be more than one page info
115 // popup shown, and that the one that is shown is associated with the current 115 // bubbl shown, and that the one that is shown is associated with the current
msw 2017/04/05 19:27:20 nit: bubble
116 // window. This matches the behaviour in views: see PageInfoPopupView. 116 // window. This matches the behaviour in Views: see PageInfoBubbleView.
117 bool g_is_popup_showing = false; 117 bool g_is_bubble_showing = false;
118 118
119 // Takes in the parent window, which should be a BrowserWindow, and gets the 119 // Takes in the parent window, which should be a BrowserWindow, and gets the
120 // proper anchor point for the bubble. The returned point is in screen 120 // proper anchor point for the bubble. The returned point is in screen
121 // coordinates. 121 // coordinates.
122 NSPoint AnchorPointForWindow(NSWindow* parent) { 122 NSPoint AnchorPointForWindow(NSWindow* parent) {
123 BrowserWindowController* controller = [parent windowController]; 123 BrowserWindowController* controller = [parent windowController];
124 NSPoint origin = NSZeroPoint; 124 NSPoint origin = NSZeroPoint;
125 if ([controller isKindOfClass:[BrowserWindowController class]]) { 125 if ([controller isKindOfClass:[BrowserWindowController class]]) {
126 LocationBarViewMac* location_bar = [controller locationBarBridge]; 126 LocationBarViewMac* location_bar = [controller locationBarBridge];
127 if (location_bar) { 127 if (location_bar) {
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 controlOrigin.y)]; 1116 controlOrigin.y)];
1117 [self performLayout]; 1117 [self performLayout];
1118 } 1118 }
1119 1119
1120 @end 1120 @end
1121 1121
1122 PageInfoUIBridge::PageInfoUIBridge(content::WebContents* web_contents) 1122 PageInfoUIBridge::PageInfoUIBridge(content::WebContents* web_contents)
1123 : content::WebContentsObserver(web_contents), 1123 : content::WebContentsObserver(web_contents),
1124 web_contents_(web_contents), 1124 web_contents_(web_contents),
1125 bubble_controller_(nil) { 1125 bubble_controller_(nil) {
1126 DCHECK(!g_is_popup_showing); 1126 DCHECK(!g_is_bubble_showing);
1127 g_is_popup_showing = true; 1127 g_is_bubble_showing = true;
1128 } 1128 }
1129 1129
1130 PageInfoUIBridge::~PageInfoUIBridge() { 1130 PageInfoUIBridge::~PageInfoUIBridge() {
1131 DCHECK(g_is_popup_showing); 1131 DCHECK(g_is_bubble_showing);
1132 g_is_popup_showing = false; 1132 g_is_bubble_showing = false;
1133 } 1133 }
1134 1134
1135 void PageInfoUIBridge::set_bubble_controller( 1135 void PageInfoUIBridge::set_bubble_controller(
1136 PageInfoBubbleController* controller) { 1136 PageInfoBubbleController* controller) {
1137 bubble_controller_ = controller; 1137 bubble_controller_ = controller;
1138 } 1138 }
1139 1139
1140 void PageInfoUIBridge::Show(gfx::NativeWindow parent, 1140 void PageInfoUIBridge::Show(gfx::NativeWindow parent,
1141 Profile* profile, 1141 Profile* profile,
1142 content::WebContents* web_contents, 1142 content::WebContents* web_contents,
1143 const GURL& virtual_url, 1143 const GURL& virtual_url,
1144 const security_state::SecurityInfo& security_info) { 1144 const security_state::SecurityInfo& security_info) {
1145 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { 1145 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
1146 chrome::ShowPageInfoBubbleViewsAtPoint( 1146 chrome::ShowPageInfoBubbleViewsAtPoint(
1147 gfx::ScreenPointFromNSPoint(AnchorPointForWindow(parent)), profile, 1147 gfx::ScreenPointFromNSPoint(AnchorPointForWindow(parent)), profile,
1148 web_contents, virtual_url, security_info); 1148 web_contents, virtual_url, security_info);
1149 return; 1149 return;
1150 } 1150 }
1151 1151
1152 // Don't show the popup if it's already being shown. Since this method is 1152 // Don't show the popup if it's already being shown. Since this method is
msw 2017/04/05 19:27:20 nit: s/popup/bubble/
1153 // called each time the location icon is clicked, each click toggles the popup 1153 // called each time the location icon is clicked, each click toggles the popup
msw 2017/04/05 19:27:20 nit: s/popup/bubble/
1154 // in and out. 1154 // in and out.
1155 if (g_is_popup_showing) 1155 if (g_is_bubble_showing)
1156 return; 1156 return;
1157 1157
1158 // Create the bridge. This will be owned by the bubble controller. 1158 // Create the bridge. This will be owned by the bubble controller.
1159 PageInfoUIBridge* bridge = new PageInfoUIBridge(web_contents); 1159 PageInfoUIBridge* bridge = new PageInfoUIBridge(web_contents);
1160 1160
1161 // Create the bubble controller. It will dealloc itself when it closes, 1161 // Create the bubble controller. It will dealloc itself when it closes,
1162 // resetting |g_is_popup_showing|. 1162 // resetting |g_is_bubble_showing|.
1163 PageInfoBubbleController* bubble_controller = 1163 PageInfoBubbleController* bubble_controller =
1164 [[PageInfoBubbleController alloc] initWithParentWindow:parent 1164 [[PageInfoBubbleController alloc] initWithParentWindow:parent
1165 pageInfoUIBridge:bridge 1165 pageInfoUIBridge:bridge
1166 webContents:web_contents 1166 webContents:web_contents
1167 url:virtual_url]; 1167 url:virtual_url];
1168 1168
1169 if (!IsInternalURL(virtual_url)) { 1169 if (!IsInternalURL(virtual_url)) {
1170 // Initialize the presenter, which holds the model and controls the UI. 1170 // Initialize the presenter, which holds the model and controls the UI.
1171 // This is also owned by the bubble controller. 1171 // This is also owned by the bubble controller.
1172 PageInfo* presenter = 1172 PageInfo* presenter =
(...skipping 21 matching lines...) Expand all
1194 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) { 1194 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) {
1195 [bubble_controller_ setCookieInfo:cookie_info_list]; 1195 [bubble_controller_ setCookieInfo:cookie_info_list];
1196 } 1196 }
1197 1197
1198 void PageInfoUIBridge::SetPermissionInfo( 1198 void PageInfoUIBridge::SetPermissionInfo(
1199 const PermissionInfoList& permission_info_list, 1199 const PermissionInfoList& permission_info_list,
1200 ChosenObjectInfoList chosen_object_info_list) { 1200 ChosenObjectInfoList chosen_object_info_list) {
1201 [bubble_controller_ setPermissionInfo:permission_info_list 1201 [bubble_controller_ setPermissionInfo:permission_info_list
1202 andChosenObjects:std::move(chosen_object_info_list)]; 1202 andChosenObjects:std::move(chosen_object_info_list)];
1203 } 1203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698