Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6088)

Unified Diff: chrome/browser/ui/ash/launcher/browser_status_monitor.h

Issue 23708028: Reduce calling count of UpdateAppState() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Monitor active tab's webcontents by using WebContenetsObserver. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/launcher/browser_status_monitor.h
diff --git a/chrome/browser/ui/ash/launcher/browser_status_monitor.h b/chrome/browser/ui/ash/launcher/browser_status_monitor.h
index 64098c3e331da93ed16f306fe29d74bba77dae0b..b3ec3e36995dffbd6d06675f3439bbcfbe8eaec0 100644
--- a/chrome/browser/ui/ash/launcher/browser_status_monitor.h
+++ b/chrome/browser/ui/ash/launcher/browser_status_monitor.h
@@ -14,6 +14,7 @@
#include "base/scoped_observer.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
+#include "content/public/browser/web_contents_observer.h"
#include "ui/aura/client/activation_change_observer.h"
#include "ui/aura/window_observer.h"
#include "ui/gfx/display_observer.h"
@@ -62,26 +63,46 @@ class BrowserStatusMonitor : public aura::client::ActivationChangeObserver,
content::WebContents* new_contents,
int index,
int reason) OVERRIDE;
+
virtual void TabInsertedAt(content::WebContents* contents,
int index,
bool foreground) OVERRIDE;
- virtual void TabDetachedAt(content::WebContents* contents,
- int index) OVERRIDE;
- virtual void TabChangedAt(
- content::WebContents* contents,
- int index,
- TabStripModelObserver::TabChangeType change_type) OVERRIDE;
- virtual void TabReplacedAt(TabStripModel* tab_strip_model,
- content::WebContents* old_contents,
- content::WebContents* new_contents,
- int index) OVERRIDE;
- private:
- typedef std::map<Browser*, std::string> BrowserToAppIDMap;
+ virtual void TabClosingAt(TabStripModel* tab_strip_mode,
+ content::WebContents* contents,
+ int index) OVERRIDE;
// Update app state for |contents| and browser state.
void UpdateAppAndBrowserState(content::WebContents* contents);
+ private:
+ // ActiveWebContentsObserver monitors active tab's WebContents to notify
+ // a navigation changing to BrowserStatusMonitor.
Mr4D (OOO till 08-26) 2013/09/13 14:35:18 This class monitors the WebContent of the active t
simonhong_ 2013/09/15 17:27:08 Done.
+ class ActiveWebContentsObserver : public content::WebContentsObserver {
+ public:
+ ActiveWebContentsObserver(content::WebContents* contents,
+ BrowserStatusMonitor* monitor);
+ virtual ~ActiveWebContentsObserver();
+
+ // content::WebContentsObserver overrides:
+ virtual void NavigateToPendingEntry(
+ const GURL& url,
+ content::NavigationController::ReloadType reload_type) OVERRIDE;
+
+ virtual void DidNavigateMainFrame(
+ const content::LoadCommittedDetails& details,
+ const content::FrameNavigateParams& params) OVERRIDE;
+
+ private:
+ BrowserStatusMonitor* monitor_;
+
+ DISALLOW_COPY_AND_ASSIGN(ActiveWebContentsObserver);
+ };
+
+ typedef std::map<Browser*, std::string> BrowserToAppIDMap;
+ typedef std::map<content::WebContents*, ActiveWebContentsObserver*>
+ WebContentsToObserverMap;
+
// A shortcut to call the BrowserShortcutLauncherItemController's
// UpdateBrowserItemState().
void UpdateBrowserItemState();
@@ -97,6 +118,8 @@ class BrowserStatusMonitor : public aura::client::ActivationChangeObserver,
BrowserToAppIDMap browser_to_app_id_map_;
+ WebContentsToObserverMap webcontents_to_observer_map_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserStatusMonitor);
};

Powered by Google App Engine
This is Rietveld 408576698