| 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   //  - remember last muted and audible states to know if there was a change |  144   //  - remember last muted and audible states to know if there was a change | 
|  145   class TabEntry { |  145   class TabEntry { | 
|  146    public: |  146    public: | 
|  147     // Create a TabEntry associated with, and tracking state changes to, |  147     // Create a TabEntry associated with, and tracking state changes to, | 
|  148     // |contents|. |  148     // |contents|. | 
|  149     explicit TabEntry(content::WebContents* contents); |  149     explicit TabEntry(content::WebContents* contents); | 
|  150  |  150  | 
|  151     // Indicate via a list of key/value pairs if a tab is loading based on its |  151     // Indicate via a list of key/value pairs that being changed when called. | 
|  152     // WebContents. Whether the state has changed or not is used to determine |  152     scoped_ptr<base::DictionaryValue> Update(); | 
|  153     // if events needs to be sent to extensions during processing of |  | 
|  154     // TabChangedAt(). If this method indicates that a tab should "hold" a |  | 
|  155     // state-change to "loading", the DidNavigate() method should eventually |  | 
|  156     // send a similar message to undo it. If false, the returned key/value |  | 
|  157     // pairs list is empty. |  | 
|  158     scoped_ptr<base::DictionaryValue> UpdateLoadState(); |  | 
|  159  |  | 
|  160     // Indicate via a list of key/value pairs that a tab load has resulted in a |  | 
|  161     // navigation and the destination url is available for inspection. The list |  | 
|  162     // is empty if no updates should be sent. |  | 
|  163     scoped_ptr<base::DictionaryValue> DidNavigate(); |  | 
|  164  |  153  | 
|  165     // Update the audible and muted states and return whether they were changed |  154     // Update the audible and muted states and return whether they were changed | 
|  166     bool SetAudible(bool new_val); |  155     bool SetAudible(bool new_val); | 
|  167     bool SetMuted(bool new_val); |  156     bool SetMuted(bool new_val); | 
|  168  |  157  | 
|  169     content::WebContents* web_contents() { return contents_; } |  158     content::WebContents* web_contents() { return contents_; } | 
|  170  |  159  | 
|  171    private: |  160    private: | 
|  172     content::WebContents* contents_; |  161     content::WebContents* contents_; | 
|  173  |  162  | 
|  174     // Whether we are waiting to fire the 'complete' status change. This will |  | 
|  175     // occur the first time the WebContents stops loading after the |  | 
|  176     // NAV_ENTRY_COMMITTED was fired. The tab may go back into and out of the |  | 
|  177     // loading state subsequently, but we will ignore those changes. |  | 
|  178     bool complete_waiting_on_load_; |  | 
|  179  |  | 
|  180     // Previous audible and muted states |  163     // Previous audible and muted states | 
|  181     bool was_audible_; |  164     bool was_audible_; | 
|  182     bool was_muted_; |  165     bool was_muted_; | 
|  183  |  166  | 
|  184     GURL url_; |  167     GURL url_; | 
 |  168  | 
 |  169     // Indicate the last 'status' value. | 
 |  170     std::string status_; | 
|  185   }; |  171   }; | 
|  186  |  172  | 
|  187   // Gets the TabEntry for the given |contents|. Returns linked_ptr<TabEntry> |  173   // Gets the TabEntry for the given |contents|. Returns linked_ptr<TabEntry> | 
|  188   // if found, NULL if not. |  174   // if found, NULL if not. | 
|  189   linked_ptr<TabEntry> GetTabEntry(content::WebContents* contents); |  175   linked_ptr<TabEntry> GetTabEntry(content::WebContents* contents); | 
|  190  |  176  | 
|  191   using TabEntryMap = std::map<int, linked_ptr<TabEntry>>; |  177   using TabEntryMap = std::map<int, linked_ptr<TabEntry>>; | 
|  192   TabEntryMap tab_entries_; |  178   TabEntryMap tab_entries_; | 
|  193  |  179  | 
|  194   // The main profile that owns this event router. |  180   // The main profile that owns this event router. | 
|  195   Profile* profile_; |  181   Profile* profile_; | 
|  196  |  182  | 
|  197   ScopedObserver<favicon::FaviconDriver, TabsEventRouter> |  183   ScopedObserver<favicon::FaviconDriver, TabsEventRouter> | 
|  198       favicon_scoped_observer_; |  184       favicon_scoped_observer_; | 
|  199  |  185  | 
|  200   DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); |  186   DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); | 
|  201 }; |  187 }; | 
|  202  |  188  | 
|  203 }  // namespace extensions |  189 }  // namespace extensions | 
|  204  |  190  | 
|  205 #endif  // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ |  191 #endif  // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ | 
| OLD | NEW |