| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_PREVIEWABLE_CONTENTS_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_OVERLAYABLE_CONTENTS_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_PREVIEWABLE_CONTENTS_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_OVERLAYABLE_CONTENTS_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/memory/scoped_nsobject.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/common/instant_types.h" | |
| 13 | 12 |
| 14 class Browser; | 13 class Browser; |
| 15 @class BrowserWindowController; | 14 @class BrowserWindowController; |
| 16 class InstantPreviewControllerMac; | 15 class InstantOverlayControllerMac; |
| 17 | 16 |
| 18 namespace content { | 17 namespace content { |
| 19 class WebContents; | 18 class WebContents; |
| 20 } | 19 } |
| 21 | 20 |
| 22 // PreviewableContentsController manages the display of up to two tab contents | 21 // OverlayableContentsController manages the display of up to two tab contents |
| 23 // views. It is primarily for use with Instant results. This class supports | 22 // views. It is primarily for use with Instant results. This class supports the |
| 24 // the notion of an "active" view vs. a "preview" tab contents view. | 23 // notion of an "active" view vs. an "overlay" tab contents view. |
| 25 // | 24 // |
| 26 // The "active" view is a container view that can be retrieved using | 25 // The "active" view is a container view that can be retrieved using |
| 27 // |-activeContainer|. Its contents are meant to be managed by an external | 26 // |-activeContainer|. Its contents are meant to be managed by an external |
| 28 // class. | 27 // class. |
| 29 // | 28 // |
| 30 // The "preview" can be set using |-showPreview:| and |-hidePreview|. When a | 29 // The "overlay" can be set using |-showOverlay:| and |-hideOverlay|. When an |
| 31 // preview is set, the active view is hidden (but stays in the view hierarchy). | 30 // overlay is set, the active view is hidden (but stays in the view hierarchy). |
| 32 // When the preview is removed, the active view is reshown. | 31 // When the overlay is removed, the active view is reshown. |
| 33 @interface PreviewableContentsController : NSViewController { | 32 @interface OverlayableContentsController : NSViewController { |
| 34 @private | 33 @private |
| 35 // Container view for the "active" contents. | 34 // Container view for the "active" contents. |
| 36 scoped_nsobject<NSView> activeContainer_; | 35 scoped_nsobject<NSView> activeContainer_; |
| 37 | 36 |
| 38 // The preview WebContents. Will be NULL if no preview is currently showing. | 37 // The overlay WebContents. Will be NULL if no overlay is currently showing. |
| 39 content::WebContents* previewContents_; // weak | 38 content::WebContents* overlayContents_; // weak |
| 40 | 39 |
| 41 // C++ bridge to the Instant model change interface. | 40 // C++ bridge to the Instant model change interface. |
| 42 scoped_ptr<InstantPreviewControllerMac> instantPreviewController_; | 41 scoped_ptr<InstantOverlayControllerMac> instantOverlayController_; |
| 43 | 42 |
| 44 // The desired height of the preview and units. | 43 // The desired height of the overlay and whether it's in pixels or percent. |
| 45 CGFloat previewHeight_; | 44 CGFloat overlayHeight_; |
| 46 InstantSizeUnits previewHeightUnits_; | 45 BOOL isHeightInPixels_; |
| 47 | 46 |
| 48 // If true then a shadow is drawn below the preview. This is used to make | 47 // If true then a shadow is drawn below the overlay. This is used to make the |
| 49 // instant omnibox "float" over the tab's web contents. | 48 // overlay "float" over the tab's web contents. |
| 50 BOOL drawDropShadow_; | 49 BOOL drawDropShadow_; |
| 51 | 50 |
| 52 // View responsible for drawing a drop shadow. | 51 // View responsible for drawing a drop shadow. |
| 53 scoped_nsobject<NSView> dropShadowView_; | 52 scoped_nsobject<NSView> dropShadowView_; |
| 54 | 53 |
| 55 BrowserWindowController* windowController_; | 54 BrowserWindowController* windowController_; |
| 56 | 55 |
| 57 // The vertical offset between the top of the view and the active container. | 56 // The vertical offset between the top of the view and the active container. |
| 58 // This is used to push the active container below the bookmark bar. Normally | 57 // This is used to push the active container below the bookmark bar. Normally |
| 59 // this is set to the height of the bookmark bar so that the bookmark bar is | 58 // this is set to the height of the bookmark bar so that the bookmark bar is |
| 60 // not obscured. | 59 // not obscured. |
| 61 CGFloat activeContainerOffset_; | 60 CGFloat activeContainerOffset_; |
| 62 } | 61 } |
| 63 | 62 |
| 64 @property(readonly, nonatomic) NSView* activeContainer; | 63 @property(readonly, nonatomic) NSView* activeContainer; |
| 65 @property(readonly, nonatomic) NSView* dropShadowView; | 64 @property(readonly, nonatomic) NSView* dropShadowView; |
| 66 @property(readonly, nonatomic) BOOL drawDropShadow; | 65 @property(readonly, nonatomic) BOOL drawDropShadow; |
| 67 @property(assign, nonatomic) CGFloat activeContainerOffset; | 66 @property(assign, nonatomic) CGFloat activeContainerOffset; |
| 68 | 67 |
| 69 // Initialization. | 68 // Initialization. |
| 70 - (id)initWithBrowser:(Browser*)browser | 69 - (id)initWithBrowser:(Browser*)browser |
| 71 windowController:(BrowserWindowController*)windowController; | 70 windowController:(BrowserWindowController*)windowController; |
| 72 | 71 |
| 73 // Sets the current preview and installs its WebContentsView into the view | 72 // Sets the current overlay and installs its WebContentsView into the view |
| 74 // hierarchy. Hides the active view. If |preview| is NULL then closes the | 73 // hierarchy. Hides the active view. If |overlay| is NULL then closes the |
| 75 // current preview and shows the active view. | 74 // current overlay and shows the active view. |
| 76 - (void)setPreview:(content::WebContents*)preview | 75 - (void)setOverlay:(content::WebContents*)overlay |
| 77 height:(CGFloat)height | 76 height:(CGFloat)height |
| 78 heightUnits:(InstantSizeUnits)heightUnits | 77 isHeightInPixels:(BOOL)isHeightInPixels |
| 79 drawDropShadow:(BOOL)drawDropShadow; | 78 drawDropShadow:(BOOL)drawDropShadow; |
| 80 | 79 |
| 81 // Called when a tab with |contents| is activated, so that we can check to see | 80 // Called when a tab with |contents| is activated, so that we can check to see |
| 82 // if it's the preview being activated (and adjust internal state accordingly). | 81 // if it's the overlay being activated (and adjust internal state accordingly). |
| 83 - (void)onActivateTabWithContents:(content::WebContents*)contents; | 82 - (void)onActivateTabWithContents:(content::WebContents*)contents; |
| 84 | 83 |
| 85 // Returns YES if the preview contents is currently showing. | 84 // Returns YES if the overlay contents is currently showing. |
| 86 - (BOOL)isShowingPreview; | 85 - (BOOL)isShowingOverlay; |
| 87 | 86 |
| 88 - (InstantPreviewControllerMac*)instantPreviewController; | 87 - (InstantOverlayControllerMac*)instantOverlayController; |
| 89 | 88 |
| 90 @end | 89 @end |
| 91 | 90 |
| 92 #endif // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_PREVIEWABLE_CONTENTS_CONTROLLER_
H_ | 91 #endif // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_OVERLAYABLE_CONTENTS_CONTROLLER_
H_ |
| OLD | NEW |