| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_API_TABS_TABS_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // - distinguish between tab creation and tab insertion | 141 // - distinguish between tab creation and tab insertion |
| 142 // - not send tab-detached after tab-removed | 142 // - not send tab-detached after tab-removed |
| 143 // - reduce the "noise" of TabChangedAt() when sending events to extensions | 143 // - reduce the "noise" of TabChangedAt() when sending events to extensions |
| 144 class TabEntry { | 144 class TabEntry { |
| 145 public: | 145 public: |
| 146 // Create a new tab entry whose initial state is TAB_COMPLETE. This | 146 // Create a new tab entry whose initial state is TAB_COMPLETE. This |
| 147 // constructor is required because TabEntry objects placed inside an | 147 // constructor is required because TabEntry objects placed inside an |
| 148 // std::map<> by value. | 148 // std::map<> by value. |
| 149 TabEntry(); | 149 TabEntry(); |
| 150 | 150 |
| 151 // Update the load state of the tab based on its WebContents. Returns true | 151 // Update 'complete' state baed on its WebContents. |
| 152 // if the state changed, false otherwise. Whether the state has changed or | 152 scoped_ptr<base::DictionaryValue> UpdateComplete( |
| 153 // not is used to determine if events needs to be sent to extensions during | |
| 154 // processing of TabChangedAt(). This method will "hold" a state-change | |
| 155 // to "loading", until the DidNavigate() method which should always follow | |
| 156 // it. Returns NULL if no updates should be sent. | |
| 157 base::DictionaryValue* UpdateLoadState( | |
| 158 const content::WebContents* contents); | 153 const content::WebContents* contents); |
| 159 | 154 |
| 160 // Indicates that a tab load has resulted in a navigation and the | 155 // Detect what has changed by holding onto the previous values. |
| 161 // destination url is available for inspection. Returns NULL if no updates | 156 scoped_ptr<base::DictionaryValue> Update( |
| 162 // should be sent. | 157 const content::WebContents* contents); |
| 163 base::DictionaryValue* DidNavigate(const content::WebContents* contents); | |
| 164 | 158 |
| 165 private: | 159 private: |
| 166 // Whether we are waiting to fire the 'complete' status change. This will | 160 // Whether we are waiting to fire the 'complete' status change. This will |
| 167 // occur the first time the WebContents stops loading after the | 161 // occur the first time the WebContents stops loading after the |
| 168 // NAV_ENTRY_COMMITTED was fired. The tab may go back into and out of the | 162 // NAV_ENTRY_COMMITTED was fired. The tab may go back into and out of the |
| 169 // loading state subsequently, but we will ignore those changes. | 163 // loading state subsequently, but we will ignore those changes. |
| 170 bool complete_waiting_on_load_; | 164 bool complete_waiting_on_load_; |
| 171 | 165 |
| 172 GURL url_; | 166 GURL url_; |
| 173 }; | 167 }; |
| 174 | 168 |
| 175 // Gets the TabEntry for the given |contents|. Returns TabEntry* if | 169 // Gets the TabEntry for the given |contents|. Returns TabEntry* if |
| 176 // found, NULL if not. | 170 // found, NULL if not. |
| 177 TabEntry* GetTabEntry(content::WebContents* contents); | 171 TabEntry* GetTabEntry(content::WebContents* contents); |
| 178 | 172 |
| 179 std::map<int, TabEntry> tab_entries_; | 173 std::map<int, TabEntry> tab_entries_; |
| 180 | 174 |
| 181 // The main profile that owns this event router. | 175 // The main profile that owns this event router. |
| 182 Profile* profile_; | 176 Profile* profile_; |
| 183 | 177 |
| 184 ScopedObserver<favicon::FaviconDriver, TabsEventRouter> | 178 ScopedObserver<favicon::FaviconDriver, TabsEventRouter> |
| 185 favicon_scoped_observer_; | 179 favicon_scoped_observer_; |
| 186 | 180 |
| 187 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); | 181 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); |
| 188 }; | 182 }; |
| 189 | 183 |
| 190 } // namespace extensions | 184 } // namespace extensions |
| 191 | 185 |
| 192 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ | 186 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ |
| OLD | NEW |