| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 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 CHROME_BROWSER_TAB_CONTENTS_MATCH_PREVIEW_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_MATCH_PREVIEW_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/scoped_ptr.h" |
| 10 #include "googleurl/src/gurl.h" |
| 11 |
| 12 class TabContents; |
| 13 |
| 14 // MatchPreview maintains a TabContents that is intended to give a preview of |
| 15 // a URL. MatchPreview is owned by TabContents. |
| 16 // |
| 17 // As the user types in the omnibox the LocationBar updates MatchPreview by |
| 18 // way of 'Update'. If the user does a gesture on the preview, say clicks a |
| 19 // link, the TabContentsDelegate of the hosting TabContents is notified with |
| 20 // CommitMatchPreview and the TabContents maintained by MatchPreview replaces |
| 21 // the current TabContents in the TabStripModel. |
| 22 // |
| 23 // At any time the TabContents maintained by MatchPreview may be destroyed by |
| 24 // way of 'DestroyPreviewContents'. Consumers of MatchPreview can detect the |
| 25 // preview TabContents was destroyed by observing TAB_CONTENTS_DESTROYED. |
| 26 // |
| 27 // Consumers of MatchPreview can detect a new TabContents was created by |
| 28 // MatchPreview by listening for MATCH_PREVIEW_TAB_CONTENTS_CREATED. |
| 29 class MatchPreview { |
| 30 public: |
| 31 explicit MatchPreview(TabContents* host); |
| 32 ~MatchPreview(); |
| 33 |
| 34 // Is MatchPreview enabled? |
| 35 static bool IsEnabled(); |
| 36 |
| 37 // Invoked as the user types in the omnibox with the url to navigate to. If |
| 38 // the url is empty and there is a preview TabContents it is destroyed. If url |
| 39 // is non-empty and the preview TabContents has not been created it is |
| 40 // created. |
| 41 void Update(const GURL& url); |
| 42 |
| 43 // Destroys the preview TabContents. Does nothing if the preview TabContents |
| 44 // has not been created. |
| 45 void DestroyPreviewContents(); |
| 46 |
| 47 // Invoked when the user does some gesture that should trigger making the |
| 48 // current previewed page the permanent page. |
| 49 void CommitCurrentPreview(); |
| 50 |
| 51 // Releases the preview TabContents passing ownership to the caller. This is |
| 52 // intended to be called when the preview TabContents is committed. |
| 53 TabContents* ReleasePreviewContents(); |
| 54 |
| 55 // The TabContents we're maintaining the preview for. |
| 56 TabContents* host() { return host_; } |
| 57 |
| 58 // The preview TabContents; may be null. |
| 59 TabContents* preview_contents() { return preview_contents_.get(); } |
| 60 |
| 61 private: |
| 62 class TabContentsDelegateImpl; |
| 63 |
| 64 // The url we're displaying. |
| 65 GURL url_; |
| 66 |
| 67 // The TabContents we're providing the preview for. |
| 68 TabContents* host_; |
| 69 |
| 70 // Delegate of the preview TabContents. Used to detect when the user does some |
| 71 // gesture on the TabContents and the preview needs to be activated. |
| 72 scoped_ptr<TabContentsDelegateImpl> delegate_; |
| 73 |
| 74 // The preview TabContents; may be null. |
| 75 scoped_ptr<TabContents> preview_contents_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(MatchPreview); |
| 78 }; |
| 79 |
| 80 #endif // CHROME_BROWSER_TAB_CONTENTS_MATCH_PREVIEW_H_ |
| OLD | NEW |