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

Side by Side Diff: chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm

Issue 2171713002: Safe browsing subresource filter bubble UI skeleton. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Verified xib file Created 4 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/content_settings/content_setting_bubble_cocoa.h " 5 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h "
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 ContentSettingBubbleController* controller_; // weak 198 ContentSettingBubbleController* controller_; // weak
199 199
200 DISALLOW_COPY_AND_ASSIGN(ContentSettingBubbleWebContentsObserverBridge); 200 DISALLOW_COPY_AND_ASSIGN(ContentSettingBubbleWebContentsObserverBridge);
201 }; 201 };
202 202
203 @interface ContentSettingBubbleController(Private) 203 @interface ContentSettingBubbleController(Private)
204 - (id)initWithModel:(ContentSettingBubbleModel*)settingsBubbleModel 204 - (id)initWithModel:(ContentSettingBubbleModel*)settingsBubbleModel
205 webContents:(content::WebContents*)webContents 205 webContents:(content::WebContents*)webContents
206 parentWindow:(NSWindow*)parentWindow 206 parentWindow:(NSWindow*)parentWindow
207 anchoredAt:(NSPoint)anchoredAt; 207 anchoredAt:(NSPoint)anchoredAt;
208 - (NSString*)getNibPathForModel:(ContentSettingBubbleModel*)model;
208 - (NSButton*)hyperlinkButtonWithFrame:(NSRect)frame 209 - (NSButton*)hyperlinkButtonWithFrame:(NSRect)frame
209 title:(NSString*)title 210 title:(NSString*)title
210 icon:(NSImage*)icon 211 icon:(NSImage*)icon
211 referenceFrame:(NSRect)referenceFrame; 212 referenceFrame:(NSRect)referenceFrame;
212 - (void)initializeBlockedPluginsList; 213 - (void)initializeBlockedPluginsList;
213 - (void)initializeTitle; 214 - (void)initializeTitle;
214 - (void)initializeRadioGroup; 215 - (void)initializeRadioGroup;
215 - (void)initializeItemList; 216 - (void)initializeItemList;
216 - (void)initializeGeoLists; 217 - (void)initializeGeoLists;
217 - (void)initializeMediaMenus; 218 - (void)initializeMediaMenus;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 - (id)initWithModel:(ContentSettingBubbleModel*)contentSettingBubbleModel 262 - (id)initWithModel:(ContentSettingBubbleModel*)contentSettingBubbleModel
262 webContents:(content::WebContents*)webContents 263 webContents:(content::WebContents*)webContents
263 parentWindow:(NSWindow*)parentWindow 264 parentWindow:(NSWindow*)parentWindow
264 anchoredAt:(NSPoint)anchoredAt { 265 anchoredAt:(NSPoint)anchoredAt {
265 // This method takes ownership of |contentSettingBubbleModel| in all cases. 266 // This method takes ownership of |contentSettingBubbleModel| in all cases.
266 std::unique_ptr<ContentSettingBubbleModel> model(contentSettingBubbleModel); 267 std::unique_ptr<ContentSettingBubbleModel> model(contentSettingBubbleModel);
267 DCHECK(model.get()); 268 DCHECK(model.get());
268 observerBridge_.reset( 269 observerBridge_.reset(
269 new ContentSettingBubbleWebContentsObserverBridge(webContents, self)); 270 new ContentSettingBubbleWebContentsObserverBridge(webContents, self));
270 271
272 NSString* nibPath = [self getNibPathForModel:model.get()];
273
274 DCHECK_NE(0u, [nibPath length]);
275
276 if ((self = [super initWithWindowNibPath:nibPath
277 parentWindow:parentWindow
278 anchoredAt:anchoredAt])) {
279 contentSettingBubbleModel_.reset(model.release());
280 [self showWindow:nil];
281 }
282 return self;
283 }
284
285 - (NSString*)getNibPathForModel:(ContentSettingBubbleModel*)model {
271 NSString* nibPath = @""; 286 NSString* nibPath = @"";
272 287
273 ContentSettingSimpleBubbleModel* simple_bubble = model->AsSimpleBubbleModel(); 288 ContentSettingSimpleBubbleModel* simple_bubble = model->AsSimpleBubbleModel();
274 if (simple_bubble) { 289 if (simple_bubble) {
275 ContentSettingsType settingsType = simple_bubble->content_type(); 290 ContentSettingsType settingsType = simple_bubble->content_type();
276 291
277 for (const ContentTypeToNibPath& type_to_path : kNibPaths) { 292 for (const ContentTypeToNibPath& type_to_path : kNibPaths) {
278 if (settingsType == type_to_path.type) { 293 if (settingsType == type_to_path.type) {
279 nibPath = type_to_path.path; 294 nibPath = type_to_path.path;
280 break; 295 break;
281 } 296 }
282 } 297 }
283 } 298 }
284 299
285 if (model->AsMediaStreamBubbleModel()) 300 if (model->AsMediaStreamBubbleModel())
286 nibPath = @"ContentBlockedMedia"; 301 nibPath = @"ContentBlockedMedia";
287 302
288 DCHECK_NE(0u, [nibPath length]); 303 if (model->AsSubresourceFilterBubbleModel())
289 304 nibPath = @"ContentSubresourceFilter";
290 if ((self = [super initWithWindowNibPath:nibPath 305 return nibPath;
291 parentWindow:parentWindow
292 anchoredAt:anchoredAt])) {
293 contentSettingBubbleModel_.reset(model.release());
294 [self showWindow:nil];
295 }
296 return self;
297 } 306 }
298 307
299 - (void)dealloc { 308 - (void)dealloc {
300 STLDeleteValues(&mediaMenus_); 309 STLDeleteValues(&mediaMenus_);
301 [super dealloc]; 310 [super dealloc];
302 } 311 }
303 312
304 - (void)initializeTitle { 313 - (void)initializeTitle {
305 if (!titleLabel_) 314 if (!titleLabel_)
306 return; 315 return;
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 button, base::SysUTF16ToNSString(it->second->model->GetLabelAt(index))); 858 button, base::SysUTF16ToNSString(it->second->model->GetLabelAt(index)));
850 859
851 it->second->model->ExecuteCommand(index, 0); 860 it->second->model->ExecuteCommand(index, 0);
852 } 861 }
853 862
854 - (content_setting_bubble::MediaMenuPartsMap*)mediaMenus { 863 - (content_setting_bubble::MediaMenuPartsMap*)mediaMenus {
855 return &mediaMenus_; 864 return &mediaMenus_;
856 } 865 }
857 866
858 @end // ContentSettingBubbleController 867 @end // ContentSettingBubbleController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698