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 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" | 5 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" |
6 | 6 |
7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/shelf/shelf_item_types.h" | 8 #include "ash/common/shelf/shelf_item_types.h" |
9 #include "ash/common/wm_window_property.h" | 9 #include "ash/common/wm_window_property.h" |
10 #include "ash/resources/grit/ash_resources.h" | 10 #include "ash/resources/grit/ash_resources.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/stl_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" | 15 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" |
16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" | 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" |
18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
20 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
21 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
22 #include "chrome/browser/ui/settings_window_manager.h" | 22 #include "chrome/browser/ui/settings_window_manager.h" |
23 #include "chrome/browser/ui/settings_window_manager_observer.h" | 23 #include "chrome/browser/ui/settings_window_manager_observer.h" |
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 browser_tab_strip_tracker_.Init( | 118 browser_tab_strip_tracker_.Init( |
119 BrowserTabStripTracker::InitWith::ALL_BROWERS); | 119 BrowserTabStripTracker::InitWith::ALL_BROWERS); |
120 } | 120 } |
121 | 121 |
122 BrowserStatusMonitor::~BrowserStatusMonitor() { | 122 BrowserStatusMonitor::~BrowserStatusMonitor() { |
123 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); | 123 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); |
124 chrome::SettingsWindowManager::GetInstance()->RemoveObserver( | 124 chrome::SettingsWindowManager::GetInstance()->RemoveObserver( |
125 settings_window_observer_.get()); | 125 settings_window_observer_.get()); |
126 | 126 |
127 browser_tab_strip_tracker_.StopObservingAndSendOnBrowserRemoved(); | 127 browser_tab_strip_tracker_.StopObservingAndSendOnBrowserRemoved(); |
128 | |
129 base::STLDeleteContainerPairSecondPointers( | |
130 webcontents_to_observer_map_.begin(), webcontents_to_observer_map_.end()); | |
131 } | 128 } |
132 | 129 |
133 void BrowserStatusMonitor::UpdateAppItemState( | 130 void BrowserStatusMonitor::UpdateAppItemState( |
134 content::WebContents* contents, | 131 content::WebContents* contents, |
135 ChromeLauncherController::AppState app_state) { | 132 ChromeLauncherController::AppState app_state) { |
136 DCHECK(contents); | 133 DCHECK(contents); |
137 // It is possible to come here from Browser::SwapTabContent where the contents | 134 // It is possible to come here from Browser::SwapTabContent where the contents |
138 // cannot be associated with a browser. A removal however should be properly | 135 // cannot be associated with a browser. A removal however should be properly |
139 // processed. | 136 // processed. |
140 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 137 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 300 |
304 bool BrowserStatusMonitor::IsV1AppInShelf(Browser* browser) { | 301 bool BrowserStatusMonitor::IsV1AppInShelf(Browser* browser) { |
305 return browser_to_app_id_map_.find(browser) != browser_to_app_id_map_.end(); | 302 return browser_to_app_id_map_.find(browser) != browser_to_app_id_map_.end(); |
306 } | 303 } |
307 | 304 |
308 void BrowserStatusMonitor::AddWebContentsObserver( | 305 void BrowserStatusMonitor::AddWebContentsObserver( |
309 content::WebContents* contents) { | 306 content::WebContents* contents) { |
310 if (webcontents_to_observer_map_.find(contents) == | 307 if (webcontents_to_observer_map_.find(contents) == |
311 webcontents_to_observer_map_.end()) { | 308 webcontents_to_observer_map_.end()) { |
312 webcontents_to_observer_map_[contents] = | 309 webcontents_to_observer_map_[contents] = |
313 new LocalWebContentsObserver(contents, this); | 310 base::MakeUnique<LocalWebContentsObserver>(contents, this); |
314 } | 311 } |
315 } | 312 } |
316 | 313 |
317 void BrowserStatusMonitor::RemoveWebContentsObserver( | 314 void BrowserStatusMonitor::RemoveWebContentsObserver( |
318 content::WebContents* contents) { | 315 content::WebContents* contents) { |
319 DCHECK(webcontents_to_observer_map_.find(contents) != | 316 DCHECK(webcontents_to_observer_map_.find(contents) != |
320 webcontents_to_observer_map_.end()); | 317 webcontents_to_observer_map_.end()); |
321 delete webcontents_to_observer_map_[contents]; | |
322 webcontents_to_observer_map_.erase(contents); | 318 webcontents_to_observer_map_.erase(contents); |
323 } | 319 } |
324 | 320 |
325 ash::ShelfID BrowserStatusMonitor::GetShelfIDForWebContents( | 321 ash::ShelfID BrowserStatusMonitor::GetShelfIDForWebContents( |
326 content::WebContents* contents) { | 322 content::WebContents* contents) { |
327 return launcher_controller_->GetShelfIDForWebContents(contents); | 323 return launcher_controller_->GetShelfIDForWebContents(contents); |
328 } | 324 } |
329 | 325 |
330 void BrowserStatusMonitor::SetShelfIDForBrowserWindowContents( | 326 void BrowserStatusMonitor::SetShelfIDForBrowserWindowContents( |
331 Browser* browser, | 327 Browser* browser, |
332 content::WebContents* web_contents) { | 328 content::WebContents* web_contents) { |
333 launcher_controller_->GetBrowserShortcutLauncherItemController()-> | 329 launcher_controller_->GetBrowserShortcutLauncherItemController()-> |
334 SetShelfIDForBrowserWindowContents(browser, web_contents); | 330 SetShelfIDForBrowserWindowContents(browser, web_contents); |
335 } | 331 } |
OLD | NEW |