OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_CHROME_BROWSER_UI_OMNIBOX_PAGE_INFO_VIEW_CONTROLLER_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_OMNIBOX_PAGE_INFO_VIEW_CONTROLLER_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 |
| 10 #include <memory> |
| 11 |
| 12 #include "base/mac/scoped_nsobject.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "ios/chrome/browser/ui/omnibox/page_info_model_observer.h" |
| 15 #import "ios/chrome/browser/ui/popup_menu/popup_menu_controller.h" |
| 16 |
| 17 @class BidiContainerView; |
| 18 class PageInfoModel; |
| 19 |
| 20 // TODO(crbug.com/227827) Merge 178763: PageInfoModel has been removed in |
| 21 // upstream; check if we should use PageInfoModel. |
| 22 // The view controller for the page info view. |
| 23 @interface PageInfoViewController : NSObject |
| 24 // Designated initializer. |
| 25 // The |source| parameter should be in the coordinate system of the parent. |
| 26 // Typically this would be the frame of a button that resulted in this popup |
| 27 // being displayed. |
| 28 - (id)initWithModel:(PageInfoModel*)model |
| 29 bridge:(PageInfoModelObserver*)bridge |
| 30 sourceFrame:(CGRect)source |
| 31 parentView:(UIView*)parent; |
| 32 |
| 33 // Dismisses the view. |
| 34 - (void)dismiss; |
| 35 |
| 36 // Layout the page info view. |
| 37 - (void)performLayout; |
| 38 |
| 39 @end |
| 40 |
| 41 // Bridge that listens for change notifications from the model. |
| 42 class PageInfoModelBubbleBridge : public PageInfoModelObserver { |
| 43 public: |
| 44 PageInfoModelBubbleBridge(); |
| 45 ~PageInfoModelBubbleBridge() override; |
| 46 |
| 47 // PageInfoModelObserver implementation. |
| 48 void OnPageInfoModelChanged() override; |
| 49 |
| 50 // Sets the controller. |
| 51 void set_controller(PageInfoViewController* controller) { |
| 52 controller_ = controller; |
| 53 } |
| 54 |
| 55 private: |
| 56 void PerformLayout() { |
| 57 // If the window is animating closed when this is called, the |
| 58 // animation could be holding the last reference to |controller_| |
| 59 // (and thus |this|). Pin it until the task is completed. |
| 60 base::scoped_nsobject<PageInfoViewController> keep_alive( |
| 61 [controller_ retain]); |
| 62 [controller_ performLayout]; |
| 63 } |
| 64 |
| 65 PageInfoViewController* controller_; // weak |
| 66 |
| 67 base::WeakPtrFactory<PageInfoModelBubbleBridge> weak_ptr_factory_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(PageInfoModelBubbleBridge); |
| 70 }; |
| 71 |
| 72 #endif // IOS_CHROME_BROWSER_UI_OMNIBOX_PAGE_INFO_VIEW_CONTROLLER_H_ |
OLD | NEW |