OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // - distinguish between tab creation and tab insertion | 108 // - distinguish between tab creation and tab insertion |
109 // - not send tab-detached after tab-removed | 109 // - not send tab-detached after tab-removed |
110 // - reduce the "noise" of TabChangedAt() when sending events to extensions | 110 // - reduce the "noise" of TabChangedAt() when sending events to extensions |
111 class TabEntry { | 111 class TabEntry { |
112 public: | 112 public: |
113 // Create a new tab entry whose initial state is TAB_COMPLETE. This | 113 // Create a new tab entry whose initial state is TAB_COMPLETE. This |
114 // constructor is required because TabEntry objects placed inside an | 114 // constructor is required because TabEntry objects placed inside an |
115 // std::map<> by value. | 115 // std::map<> by value. |
116 TabEntry(); | 116 TabEntry(); |
117 | 117 |
118 // Create a new tab entry whose initial state is derived from the given | |
119 // tab contents. | |
120 explicit TabEntry(const TabContents* contents); | |
121 | |
122 // Returns the current state of the tab. | |
123 ExtensionTabUtil::TabStatus state() const { return state_; } | |
124 | |
125 // Update the load state of the tab based on its TabContents. Returns true | 118 // Update the load state of the tab based on its TabContents. Returns true |
126 // if the state changed, false otherwise. Whether the state has changed or | 119 // if the state changed, false otherwise. Whether the state has changed or |
127 // not is used to determine if events needs to be sent to extensions during | 120 // not is used to determine if events needs to be sent to extensions during |
128 // processing of TabChangedAt(). This method will "hold" a state-change | 121 // processing of TabChangedAt(). This method will "hold" a state-change |
129 // to "loading", until the DidNavigate() method which should always follow | 122 // to "loading", until the DidNavigate() method which should always follow |
130 // it. Returns NULL if no updates should be sent. | 123 // it. Returns NULL if no updates should be sent. |
131 DictionaryValue* UpdateLoadState(const TabContents* contents); | 124 DictionaryValue* UpdateLoadState(const TabContents* contents); |
132 | 125 |
133 // Indicates that a tab load has resulted in a navigation and the | 126 // Indicates that a tab load has resulted in a navigation and the |
134 // destination url is available for inspection. Returns NULL if no updates | 127 // destination url is available for inspection. Returns NULL if no updates |
135 // should be sent. | 128 // should be sent. |
136 DictionaryValue* DidNavigate(const TabContents* contents); | 129 DictionaryValue* DidNavigate(const TabContents* contents); |
137 | 130 |
138 private: | 131 private: |
139 // Tab state used for last notification to extensions. | 132 // Whether we are waiting to fire the 'complete' status change. This will |
140 ExtensionTabUtil::TabStatus state_; | 133 // occur the first time the TabContents stops loading after the |
141 | 134 // NAV_ENTRY_COMMITTED was fired. The tab may go back into and out of the |
142 // Remember that the LOADING state has been captured, but not yet reported | 135 // loading state subsequently, but we will ignore those changes. |
143 // because it is waiting on the navigation event to know what the | 136 bool complete_waiting_on_load_; |
144 // destination url is. | |
145 bool pending_navigate_; | |
146 | 137 |
147 GURL url_; | 138 GURL url_; |
148 }; | 139 }; |
149 | 140 |
150 std::map<int, TabEntry> tab_entries_; | 141 std::map<int, TabEntry> tab_entries_; |
151 | 142 |
152 DISALLOW_COPY_AND_ASSIGN(ExtensionBrowserEventRouter); | 143 DISALLOW_COPY_AND_ASSIGN(ExtensionBrowserEventRouter); |
153 }; | 144 }; |
154 | 145 |
155 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_ | 146 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_EVENT_ROUTER_H_ |
OLD | NEW |