| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "ios/chrome/browser/ui/tools_menu/tools_menu_context.h" | |
| 6 | |
| 7 #import "base/ios/weak_nsobject.h" | |
| 8 #import "base/logging.h" | |
| 9 #import "ios/chrome/browser/ui/reading_list/reading_list_menu_notifier.h" | |
| 10 | |
| 11 @implementation ToolsMenuContext { | |
| 12 base::WeakNSObject<UIView> _displayView; | |
| 13 base::WeakNSObject<UIButton> _toolsMenuButton; | |
| 14 base::WeakNSObject<ReadingListMenuNotifier> _readingListMenuNotifier; | |
| 15 } | |
| 16 | |
| 17 @synthesize inTabSwitcher = _inTabSwitcher; | |
| 18 @synthesize noOpenedTabs = _noOpenedTabs; | |
| 19 @synthesize inIncognito = _inIncognito; | |
| 20 | |
| 21 - (instancetype)initWithDisplayView:(UIView*)displayView { | |
| 22 if (self = [super init]) { | |
| 23 _displayView.reset(displayView); | |
| 24 _readingListMenuNotifier.reset(); | |
| 25 } | |
| 26 return self; | |
| 27 } | |
| 28 | |
| 29 - (instancetype)init { | |
| 30 NOTREACHED(); | |
| 31 return nil; | |
| 32 } | |
| 33 | |
| 34 - (UIEdgeInsets)toolsButtonInsets { | |
| 35 return self.toolsMenuButton ? [self.toolsMenuButton imageEdgeInsets] | |
| 36 : UIEdgeInsetsZero; | |
| 37 } | |
| 38 | |
| 39 - (CGRect)sourceRect { | |
| 40 // Set the origin for the tools popup to the horizontal center of the tools | |
| 41 // menu button. | |
| 42 return self.toolsMenuButton | |
| 43 ? [self.displayView convertRect:self.toolsMenuButton.bounds | |
| 44 fromView:self.toolsMenuButton] | |
| 45 : CGRectZero; | |
| 46 } | |
| 47 | |
| 48 - (void)setToolsMenuButton:(UIButton*)toolsMenuButton { | |
| 49 _toolsMenuButton.reset(toolsMenuButton); | |
| 50 } | |
| 51 | |
| 52 - (UIButton*)toolsMenuButton { | |
| 53 return _toolsMenuButton; | |
| 54 } | |
| 55 | |
| 56 - (UIView*)displayView { | |
| 57 return _displayView; | |
| 58 } | |
| 59 | |
| 60 - (void)setReadingListMenuNotifier: | |
| 61 (ReadingListMenuNotifier*)readingListMenuNotifier { | |
| 62 _readingListMenuNotifier.reset(readingListMenuNotifier); | |
| 63 } | |
| 64 | |
| 65 - (ReadingListMenuNotifier*)readingListMenuNotifier { | |
| 66 return _readingListMenuNotifier; | |
| 67 } | |
| 68 | |
| 69 @end | |
| OLD | NEW |