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..3dc8a08c3ff9762e656832c9dd91b4e0b4767dbb 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,34 +131,53 @@ 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 TabEntry associated with, and tracking state changes to, |
+ // |contents|. |
+ explicit TabEntry(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: |
+ friend class std::map<int, TabEntry>; |
+ |
// Create a new tab entry whose initial state is TAB_COMPLETE. This |
// constructor is required because TabEntry objects placed inside an |
// std::map<> by value. |
TabEntry(); |
- // 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); |
+ 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); |
- |
- private: |
// 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_; |
}; |