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

Unified Diff: chrome/browser/ui/cocoa/subresource_filter/subresource_filter_bubble_controller.mm

Issue 2826233002: [subresource_filter] Mac UI updated and xib replaced with code based layout. (Closed)
Patch Set: Feedback addressed. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/subresource_filter/subresource_filter_bubble_controller.mm
diff --git a/chrome/browser/ui/cocoa/subresource_filter/subresource_filter_bubble_controller.mm b/chrome/browser/ui/cocoa/subresource_filter/subresource_filter_bubble_controller.mm
new file mode 100644
index 0000000000000000000000000000000000000000..50d4d29db9fd9bcbf7ebede4c78b886eb16d83a9
--- /dev/null
+++ b/chrome/browser/ui/cocoa/subresource_filter/subresource_filter_bubble_controller.mm
@@ -0,0 +1,111 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/ui/cocoa/subresource_filter/subresource_filter_bubble_controller.h"
Robert Sesek 2017/05/03 22:05:11 nit: blank line after
shivanisha 2017/05/04 20:20:57 done
+#include "base/strings/sys_string_conversions.h"
+#import "chrome/browser/ui/cocoa/info_bubble_window.h"
+#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
+#include "components/strings/grit/components_strings.h"
+#import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTweaker.h"
+#include "ui/base/l10n/l10n_util_mac.h"
+
+@interface SubresourceFilterBubbleController (Private)
+- (void)loadView;
+@end
+
+@implementation SubresourceFilterBubbleController
+
+- (void)awakeFromNib {
+ [self loadView];
+ [super awakeFromNib];
+}
+
+- (void)layoutView {
+ [super layoutView];
+ [self initializeManageCheckbox];
+}
+
+- (void)initializeManageCheckbox {
+ if (!manageCheckbox_)
+ return;
+
+ NSString* label = base::SysUTF16ToNSString(
+ contentSettingBubbleModel_->bubble_content().manage_text);
+ [manageCheckbox_ setTitle:label];
+
+ CGFloat deltaY =
+ [GTMUILocalizerAndLayoutTweaker sizeToFitView:manageCheckbox_].height;
+ NSRect windowFrame = [[self window] frame];
+ windowFrame.size.height += deltaY;
+ [[self window] setFrame:windowFrame display:NO];
+ NSRect manageCheckboxFrame = [manageCheckbox_ frame];
+ manageCheckboxFrame.origin.y -= deltaY;
+ [manageCheckbox_ setFrame:manageCheckboxFrame];
+}
+
+- (void)loadView {
Robert Sesek 2017/05/03 22:05:11 method ordering: Move this above initializeManageC
shivanisha 2017/05/04 20:20:57 done
+ titleLabel_ =
+ [[NSTextField alloc] initWithFrame:NSMakeRect(18, 120, 282, 14)];
+ [titleLabel_ setEditable:NO];
+ [titleLabel_ setBordered:NO];
+ [self.window.contentView addSubview:titleLabel_];
+ [titleLabel_ autorelease];
Robert Sesek 2017/05/03 22:05:11 You can switch the |autorelease| calls to direct |
shivanisha 2017/05/04 20:20:58 Done. So it will be released when subview goes out
+
+ messageLabel_ =
+ [[NSTextField alloc] initWithFrame:NSMakeRect(18, 85, 282, 28)];
+ [messageLabel_ setEditable:NO];
+ [messageLabel_ setBordered:NO];
+ [self.window.contentView addSubview:messageLabel_];
+ [messageLabel_ autorelease];
+
+ manageCheckbox_ =
+ [[NSButton alloc] initWithFrame:NSMakeRect(18, 35, 282, 28)];
+ [manageCheckbox_ setButtonType:NSSwitchButton];
+ [manageCheckbox_ setState:NSOffState];
+ [self.window.contentView addSubview:manageCheckbox_];
+ [manageCheckbox_ setAction:@selector(manageCheckboxChecked:)];
+ [manageCheckbox_ autorelease];
+
+ doneButton_ = [[NSButton alloc] initWithFrame:NSMakeRect(210, 10, 90, 28)];
+ [doneButton_ setBezelStyle:NSRoundedBezelStyle];
+ [doneButton_ highlight:YES];
+ [doneButton_ setTitle:l10n_util::GetNSString(IDS_OK)];
+ [self.window.contentView addSubview:doneButton_];
+ [doneButton_ setAction:@selector(closeBubble:)];
+ [doneButton_ autorelease];
+}
+
+- (id)initWithModel:(ContentSettingBubbleModel*)contentSettingBubbleModel
Robert Sesek 2017/05/03 22:05:11 method ordering: Move this to be the first method
shivanisha 2017/05/04 20:20:58 done
+ webContents:(content::WebContents*)webContents
+ parentWindow:(NSWindow*)parentWindow
+ decoration:(ContentSettingDecoration*)decoration
+ anchoredAt:(NSPoint)anchoredAt {
+ NSRect contentRect = NSMakeRect(196, 376, 316, 154);
+ base::scoped_nsobject<InfoBubbleWindow> window([[InfoBubbleWindow alloc]
+ initWithContentRect:contentRect
+ styleMask:NSBorderlessWindowMask
+ backing:NSBackingStoreBuffered
+ defer:NO]);
+
+ // Disable animations - otherwise, the window/controller will outlive the web
+ // contents it's associated with.
+ [window setAllowedAnimations:info_bubble::kAnimateNone];
+
+ [super initWithModel:contentSettingBubbleModel
+ webContents:webContents
+ window:window
+ parentWindow:parentWindow
+ decoration:decoration
+ anchoredAt:anchoredAt];
+ return self;
+}
+
+// Callback for "manage" checkbox button.
+- (IBAction)manageCheckboxChecked:(id)sender {
Robert Sesek 2017/05/03 22:05:11 Similar to |IBOutlet|, you can drop the |IBAction|
shivanisha 2017/05/04 20:20:57 done
+ bool isChecked = [sender state] == NSOnState;
+ contentSettingBubbleModel_->OnManageCheckboxChecked(isChecked);
+ [self layoutView];
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698