Chromium Code Reviews| Index: chrome/browser/extensions/api/tabs/tabs_event_router.h |
| diff --git a/chrome/browser/extensions/api/tabs/tabs_event_router.h b/chrome/browser/extensions/api/tabs/tabs_event_router.h |
| index 73ee2c95945800530d26e0e89ebcf410b8c8dc4a..8e335f4dfb4b9a195d4c02e54b0a89e0706731bc 100644 |
| --- a/chrome/browser/extensions/api/tabs/tabs_event_router.h |
| +++ b/chrome/browser/extensions/api/tabs/tabs_event_router.h |
| @@ -82,7 +82,9 @@ class TabsEventRouter : public TabStripModelObserver, |
| // Internal processing of tab updated events. Is called by both TabChangedAt |
| // and Observe/NAV_ENTRY_COMMITTED. |
| - void TabUpdated(content::WebContents* contents, bool did_navigate); |
| + class TabEntry; |
| + void TabUpdated(TabEntry* entry, |
| + scoped_ptr<base::DictionaryValue> changed_properties); |
| // Triggers a tab updated event if the favicon URL changes. |
| void FaviconUrlUpdated(content::WebContents* contents); |
| @@ -129,6 +131,7 @@ class TabsEventRouter : public TabStripModelObserver, |
| // - distinguish between tab creation and tab insertion |
| // - not send tab-detached after tab-removed |
| // - reduce the "noise" of TabChangedAt() when sending events to extensions |
| + // - remember last muted and audible states to know if there was a change |
| class TabEntry { |
| public: |
| // Create a new tab entry whose initial state is TAB_COMPLETE. This |
| @@ -136,27 +139,43 @@ class TabsEventRouter : public TabStripModelObserver, |
| // std::map<> by value. |
| TabEntry(); |
|
miu
2015/05/26 21:28:46
nit: Can you move this zero-arg constructor to the
Jared Sohn
2015/05/27 14:52:02
Done.
|
| - // Update the load state of the tab based on its WebContents. Returns true |
| - // if the state changed, false otherwise. Whether the state has changed or |
| - // not is used to determine if events needs to be sent to extensions during |
| - // processing of TabChangedAt(). This method will "hold" a state-change |
| - // to "loading", until the DidNavigate() method which should always follow |
| - // it. Returns NULL if no updates should be sent. |
| - base::DictionaryValue* UpdateLoadState( |
| - const content::WebContents* contents); |
| + // Allow creating a TabEntry via a webcontents. Used when moving |
|
miu
2015/05/26 21:28:46
This comment isn't quite accurate since the implem
Jared Sohn
2015/05/27 14:52:02
Done. This code is the inspiration for including a
|
| + // tabs between windows. |
| + explicit TabEntry(content::WebContents* contents); |
| - // Indicates that a tab load has resulted in a navigation and the |
| - // destination url is available for inspection. Returns NULL if no updates |
| - // should be sent. |
| - base::DictionaryValue* DidNavigate(const content::WebContents* contents); |
| + // Indicate via a list of key/value pairs if a tab is loading based on its |
| + // WebContents. Whether the state has changed or not is used to determine |
| + // if events needs to be sent to extensions during processing of |
| + // TabChangedAt(). If this method indicates that a tab should "hold" a |
| + // state-change to "loading", the DidNavigate() method should eventually |
| + // send a similar message to undo it. If false, the returned key/value |
| + // pairs list is empty. |
| + scoped_ptr<base::DictionaryValue> UpdateLoadState(); |
| + |
| + // Indicate via a list of key/value pairs that a tab load has resulted in a |
| + // navigation and the destination url is available for inspection. The list |
| + // is empty if no updates should be sent. |
| + scoped_ptr<base::DictionaryValue> DidNavigate(); |
| + |
| + // Update the audible and muted states and return whether they were changed |
| + bool SetAudible(bool new_val); |
| + bool SetMuted(bool new_val); |
| + |
| + content::WebContents* web_contents() { return contents_; } |
| private: |
| + content::WebContents* contents_; |
| + |
| // Whether we are waiting to fire the 'complete' status change. This will |
| // occur the first time the WebContents stops loading after the |
| // NAV_ENTRY_COMMITTED was fired. The tab may go back into and out of the |
| // loading state subsequently, but we will ignore those changes. |
| bool complete_waiting_on_load_; |
| + // Previous audible and muted states |
| + bool was_audible_; |
| + bool was_muted_; |
| + |
| GURL url_; |
| }; |