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_UI_ASH_LAUNCHER_BROWSER_STATUS_MONITOR_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_STATUS_MONITOR_H_ |
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_STATUS_MONITOR_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_STATUS_MONITOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ash/shelf/scoped_observer_with_duplicated_sources.h" | 11 #include "ash/shelf/scoped_observer_with_duplicated_sources.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/scoped_observer.h" | 14 #include "base/scoped_observer.h" |
15 #include "chrome/browser/ui/browser_list_observer.h" | 15 #include "chrome/browser/ui/browser_list_observer.h" |
16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
17 #include "content/public/browser/web_contents_observer.h" | |
17 #include "ui/aura/client/activation_change_observer.h" | 18 #include "ui/aura/client/activation_change_observer.h" |
18 #include "ui/aura/window_observer.h" | 19 #include "ui/aura/window_observer.h" |
19 #include "ui/gfx/display_observer.h" | 20 #include "ui/gfx/display_observer.h" |
20 | 21 |
21 namespace aura { | 22 namespace aura { |
22 class Window; | 23 class Window; |
23 | 24 |
24 namespace client { | 25 namespace client { |
25 class ActivationClient; | 26 class ActivationClient; |
26 } | 27 } |
(...skipping 28 matching lines...) Expand all Loading... | |
55 // gfx::DisplayObserver overrides: | 56 // gfx::DisplayObserver overrides: |
56 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; | 57 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; |
57 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE; | 58 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE; |
58 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE; | 59 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE; |
59 | 60 |
60 // TabStripModelObserver overrides: | 61 // TabStripModelObserver overrides: |
61 virtual void ActiveTabChanged(content::WebContents* old_contents, | 62 virtual void ActiveTabChanged(content::WebContents* old_contents, |
62 content::WebContents* new_contents, | 63 content::WebContents* new_contents, |
63 int index, | 64 int index, |
64 int reason) OVERRIDE; | 65 int reason) OVERRIDE; |
66 | |
65 virtual void TabInsertedAt(content::WebContents* contents, | 67 virtual void TabInsertedAt(content::WebContents* contents, |
66 int index, | 68 int index, |
67 bool foreground) OVERRIDE; | 69 bool foreground) OVERRIDE; |
68 virtual void TabDetachedAt(content::WebContents* contents, | |
69 int index) OVERRIDE; | |
70 virtual void TabChangedAt( | |
71 content::WebContents* contents, | |
72 int index, | |
73 TabStripModelObserver::TabChangeType change_type) OVERRIDE; | |
74 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | |
75 content::WebContents* old_contents, | |
76 content::WebContents* new_contents, | |
77 int index) OVERRIDE; | |
78 | 70 |
79 private: | 71 virtual void TabClosingAt(TabStripModel* tab_strip_mode, |
80 typedef std::map<Browser*, std::string> BrowserToAppIDMap; | 72 content::WebContents* contents, |
73 int index) OVERRIDE; | |
81 | 74 |
82 // Update app state for |contents| and browser state. | 75 // Update app state for |contents| and browser state. |
83 void UpdateAppAndBrowserState(content::WebContents* contents); | 76 void UpdateAppAndBrowserState(content::WebContents* contents); |
84 | 77 |
78 private: | |
79 // ActiveWebContentsObserver monitors active tab's WebContents to notify | |
80 // 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.
| |
81 class ActiveWebContentsObserver : public content::WebContentsObserver { | |
82 public: | |
83 ActiveWebContentsObserver(content::WebContents* contents, | |
84 BrowserStatusMonitor* monitor); | |
85 virtual ~ActiveWebContentsObserver(); | |
86 | |
87 // content::WebContentsObserver overrides: | |
88 virtual void NavigateToPendingEntry( | |
89 const GURL& url, | |
90 content::NavigationController::ReloadType reload_type) OVERRIDE; | |
91 | |
92 virtual void DidNavigateMainFrame( | |
93 const content::LoadCommittedDetails& details, | |
94 const content::FrameNavigateParams& params) OVERRIDE; | |
95 | |
96 private: | |
97 BrowserStatusMonitor* monitor_; | |
98 | |
99 DISALLOW_COPY_AND_ASSIGN(ActiveWebContentsObserver); | |
100 }; | |
101 | |
102 typedef std::map<Browser*, std::string> BrowserToAppIDMap; | |
103 typedef std::map<content::WebContents*, ActiveWebContentsObserver*> | |
104 WebContentsToObserverMap; | |
105 | |
85 // A shortcut to call the BrowserShortcutLauncherItemController's | 106 // A shortcut to call the BrowserShortcutLauncherItemController's |
86 // UpdateBrowserItemState(). | 107 // UpdateBrowserItemState(). |
87 void UpdateBrowserItemState(); | 108 void UpdateBrowserItemState(); |
88 | 109 |
89 ChromeLauncherController* launcher_controller_; | 110 ChromeLauncherController* launcher_controller_; |
90 | 111 |
91 // Hold all observed activation clients. | 112 // Hold all observed activation clients. |
92 ScopedObserverWithDuplicatedSources<aura::client::ActivationClient, | 113 ScopedObserverWithDuplicatedSources<aura::client::ActivationClient, |
93 aura::client::ActivationChangeObserver> observed_activation_clients_; | 114 aura::client::ActivationChangeObserver> observed_activation_clients_; |
94 | 115 |
95 // Hold all observed root windows. | 116 // Hold all observed root windows. |
96 ScopedObserver<aura::Window, aura::WindowObserver> observed_root_windows_; | 117 ScopedObserver<aura::Window, aura::WindowObserver> observed_root_windows_; |
97 | 118 |
98 BrowserToAppIDMap browser_to_app_id_map_; | 119 BrowserToAppIDMap browser_to_app_id_map_; |
99 | 120 |
121 WebContentsToObserverMap webcontents_to_observer_map_; | |
122 | |
100 DISALLOW_COPY_AND_ASSIGN(BrowserStatusMonitor); | 123 DISALLOW_COPY_AND_ASSIGN(BrowserStatusMonitor); |
101 }; | 124 }; |
102 | 125 |
103 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_STATUS_MONITOR_H_ | 126 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_STATUS_MONITOR_H_ |
OLD | NEW |