| 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/website_settings/permission_bubble_controller.h
" | 5 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h
" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/mac/bind_objc_block.h" | 9 #include "base/mac/bind_objc_block.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 const CGFloat kBetweenButtonsPadding = 10.0f; | 46 const CGFloat kBetweenButtonsPadding = 10.0f; |
| 47 const CGFloat kButtonRightEdgePadding = 17.0f; | 47 const CGFloat kButtonRightEdgePadding = 17.0f; |
| 48 const CGFloat kTitlePaddingX = 50.0f; | 48 const CGFloat kTitlePaddingX = 50.0f; |
| 49 const CGFloat kBubbleMinWidth = 315.0f; | 49 const CGFloat kBubbleMinWidth = 315.0f; |
| 50 const NSSize kPermissionIconSize = {18, 18}; | 50 const NSSize kPermissionIconSize = {18, 18}; |
| 51 | 51 |
| 52 class MenuDelegate : public ui::SimpleMenuModel::Delegate { | 52 class MenuDelegate : public ui::SimpleMenuModel::Delegate { |
| 53 public: | 53 public: |
| 54 explicit MenuDelegate(PermissionBubbleController* bubble) | 54 explicit MenuDelegate(PermissionBubbleController* bubble) |
| 55 : bubble_controller_(bubble) {} | 55 : bubble_controller_(bubble) {} |
| 56 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE { | 56 virtual bool IsCommandIdChecked(int command_id) const override { |
| 57 return false; | 57 return false; |
| 58 } | 58 } |
| 59 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE { | 59 virtual bool IsCommandIdEnabled(int command_id) const override { |
| 60 return true; | 60 return true; |
| 61 } | 61 } |
| 62 virtual bool GetAcceleratorForCommandId( | 62 virtual bool GetAcceleratorForCommandId( |
| 63 int command_id, | 63 int command_id, |
| 64 ui::Accelerator* accelerator) OVERRIDE { | 64 ui::Accelerator* accelerator) override { |
| 65 return false; | 65 return false; |
| 66 } | 66 } |
| 67 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE { | 67 virtual void ExecuteCommand(int command_id, int event_flags) override { |
| 68 [bubble_controller_ onMenuItemClicked:command_id]; | 68 [bubble_controller_ onMenuItemClicked:command_id]; |
| 69 } | 69 } |
| 70 private: | 70 private: |
| 71 PermissionBubbleController* bubble_controller_; // Weak, owns us. | 71 PermissionBubbleController* bubble_controller_; // Weak, owns us. |
| 72 DISALLOW_COPY_AND_ASSIGN(MenuDelegate); | 72 DISALLOW_COPY_AND_ASSIGN(MenuDelegate); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 } // namespace | 75 } // namespace |
| 76 | 76 |
| 77 // NSPopUpButton with a menu containing two items: allow and block. | 77 // NSPopUpButton with a menu containing two items: allow and block. |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 595 |
| 596 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { | 596 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { |
| 597 NSRect frameA = [viewA frame]; | 597 NSRect frameA = [viewA frame]; |
| 598 NSRect frameB = [viewB frame]; | 598 NSRect frameB = [viewB frame]; |
| 599 frameA.origin.y = | 599 frameA.origin.y = |
| 600 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); | 600 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); |
| 601 [viewA setFrameOrigin:frameA.origin]; | 601 [viewA setFrameOrigin:frameA.origin]; |
| 602 } | 602 } |
| 603 | 603 |
| 604 @end // implementation PermissionBubbleController | 604 @end // implementation PermissionBubbleController |
| OLD | NEW |