| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_ | 5 #ifndef CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_ |
| 6 #define CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_ | 6 #define CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 public: | 32 public: |
| 33 // Takes ownership of |contents|, which must be heap-allocated (as it lives | 33 // Takes ownership of |contents|, which must be heap-allocated (as it lives |
| 34 // in a scoped_ptr) and can not be NULL. | 34 // in a scoped_ptr) and can not be NULL. |
| 35 explicit TabContentsWrapper(TabContents* contents); | 35 explicit TabContentsWrapper(TabContents* contents); |
| 36 ~TabContentsWrapper(); | 36 ~TabContentsWrapper(); |
| 37 | 37 |
| 38 // Used to retrieve this object from |tab_contents_|, which is placed in | 38 // Used to retrieve this object from |tab_contents_|, which is placed in |
| 39 // its property bag to avoid adding additional interfaces. | 39 // its property bag to avoid adding additional interfaces. |
| 40 static PropertyAccessor<TabContentsWrapper*>* property_accessor(); | 40 static PropertyAccessor<TabContentsWrapper*>* property_accessor(); |
| 41 | 41 |
| 42 static void RegisterUserPrefs(PrefService* prefs); |
| 43 |
| 44 // Initial title assigned to NavigationEntries from Navigate. |
| 45 static string16 GetDefaultTitle(); |
| 46 |
| 47 // Returns a human-readable description the tab's loading state. |
| 48 string16 GetStatusText() const; |
| 49 |
| 42 // Create a TabContentsWrapper with the same state as this one. The returned | 50 // Create a TabContentsWrapper with the same state as this one. The returned |
| 43 // heap-allocated pointer is owned by the caller. | 51 // heap-allocated pointer is owned by the caller. |
| 44 TabContentsWrapper* Clone(); | 52 TabContentsWrapper* Clone(); |
| 45 | 53 |
| 46 // Helper to retrieve the existing instance that wraps a given TabContents. | 54 // Helper to retrieve the existing instance that wraps a given TabContents. |
| 47 // Returns NULL if there is no such existing instance. | 55 // Returns NULL if there is no such existing instance. |
| 48 static TabContentsWrapper* GetCurrentWrapperForContents( | 56 static TabContentsWrapper* GetCurrentWrapperForContents( |
| 49 TabContents* contents); | 57 TabContents* contents); |
| 50 | 58 |
| 51 TabContentsWrapperDelegate* delegate() const { return delegate_; } | 59 TabContentsWrapperDelegate* delegate() const { return delegate_; } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 81 SearchEngineTabHelper* search_engine_tab_helper() { | 89 SearchEngineTabHelper* search_engine_tab_helper() { |
| 82 return search_engine_tab_helper_.get(); | 90 return search_engine_tab_helper_.get(); |
| 83 } | 91 } |
| 84 | 92 |
| 85 // Overrides ----------------------------------------------------------------- | 93 // Overrides ----------------------------------------------------------------- |
| 86 | 94 |
| 87 // TabContentsObserver overrides: | 95 // TabContentsObserver overrides: |
| 88 virtual void DidNavigateMainFramePostCommit( | 96 virtual void DidNavigateMainFramePostCommit( |
| 89 const NavigationController::LoadCommittedDetails& details, | 97 const NavigationController::LoadCommittedDetails& details, |
| 90 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; | 98 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; |
| 99 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 91 | 100 |
| 92 // NotificationObserver overrides: | 101 // NotificationObserver overrides: |
| 93 virtual void Observe(NotificationType type, | 102 virtual void Observe(NotificationType type, |
| 94 const NotificationSource& source, | 103 const NotificationSource& source, |
| 95 const NotificationDetails& details) OVERRIDE; | 104 const NotificationDetails& details) OVERRIDE; |
| 96 | 105 |
| 97 private: | 106 private: |
| 98 // Internal helpers ---------------------------------------------------------- | 107 // Internal helpers ---------------------------------------------------------- |
| 99 | 108 |
| 109 // Message handlers. |
| 110 void OnJSOutOfMemory(); |
| 111 |
| 100 // Updates the starred state from the bookmark bar model. If the state has | 112 // Updates the starred state from the bookmark bar model. If the state has |
| 101 // changed, the delegate is notified. | 113 // changed, the delegate is notified. |
| 102 void UpdateStarredStateForCurrentURL(); | 114 void UpdateStarredStateForCurrentURL(); |
| 103 | 115 |
| 104 // Data for core operation --------------------------------------------------- | 116 // Data for core operation --------------------------------------------------- |
| 105 | 117 |
| 106 // Delegate for notifying our owner about stuff. Not owned by us. | 118 // Delegate for notifying our owner about stuff. Not owned by us. |
| 107 TabContentsWrapperDelegate* delegate_; | 119 TabContentsWrapperDelegate* delegate_; |
| 108 | 120 |
| 109 // Registers and unregisters us for notifications. | 121 // Registers and unregisters us for notifications. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 129 | 141 |
| 130 // The supporting objects need to outlive the TabContents dtor (as they may | 142 // The supporting objects need to outlive the TabContents dtor (as they may |
| 131 // be called upon during its execution). As a result, this must come last | 143 // be called upon during its execution). As a result, this must come last |
| 132 // in the list. | 144 // in the list. |
| 133 scoped_ptr<TabContents> tab_contents_; | 145 scoped_ptr<TabContents> tab_contents_; |
| 134 | 146 |
| 135 DISALLOW_COPY_AND_ASSIGN(TabContentsWrapper); | 147 DISALLOW_COPY_AND_ASSIGN(TabContentsWrapper); |
| 136 }; | 148 }; |
| 137 | 149 |
| 138 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_ | 150 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_TAB_CONTENTS_WRAPPER_H_ |
| OLD | NEW |