| 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/shelf/shelf_util.h" | 7 #include "ash/shelf/shelf_util.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 LocalWebContentsObserver(content::WebContents* contents, | 36 LocalWebContentsObserver(content::WebContents* contents, |
| 37 BrowserStatusMonitor* monitor) | 37 BrowserStatusMonitor* monitor) |
| 38 : content::WebContentsObserver(contents), | 38 : content::WebContentsObserver(contents), |
| 39 monitor_(monitor) {} | 39 monitor_(monitor) {} |
| 40 | 40 |
| 41 virtual ~LocalWebContentsObserver() {} | 41 virtual ~LocalWebContentsObserver() {} |
| 42 | 42 |
| 43 // content::WebContentsObserver | 43 // content::WebContentsObserver |
| 44 virtual void DidNavigateMainFrame( | 44 virtual void DidNavigateMainFrame( |
| 45 const content::LoadCommittedDetails& details, | 45 const content::LoadCommittedDetails& details, |
| 46 const content::FrameNavigateParams& params) OVERRIDE { | 46 const content::FrameNavigateParams& params) override { |
| 47 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 47 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
| 48 ChromeLauncherController::AppState state = | 48 ChromeLauncherController::AppState state = |
| 49 ChromeLauncherController::APP_STATE_INACTIVE; | 49 ChromeLauncherController::APP_STATE_INACTIVE; |
| 50 if (browser->window()->IsActive() && | 50 if (browser->window()->IsActive() && |
| 51 browser->tab_strip_model()->GetActiveWebContents() == web_contents()) | 51 browser->tab_strip_model()->GetActiveWebContents() == web_contents()) |
| 52 state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE; | 52 state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE; |
| 53 else if (browser->window()->IsActive()) | 53 else if (browser->window()->IsActive()) |
| 54 state = ChromeLauncherController::APP_STATE_ACTIVE; | 54 state = ChromeLauncherController::APP_STATE_ACTIVE; |
| 55 | 55 |
| 56 monitor_->UpdateAppItemState(web_contents(), state); | 56 monitor_->UpdateAppItemState(web_contents(), state); |
| 57 monitor_->UpdateBrowserItemState(); | 57 monitor_->UpdateBrowserItemState(); |
| 58 | 58 |
| 59 // Navigating may change the ShelfID associated with the WebContents. | 59 // Navigating may change the ShelfID associated with the WebContents. |
| 60 if (browser->tab_strip_model()->GetActiveWebContents() == web_contents()) | 60 if (browser->tab_strip_model()->GetActiveWebContents() == web_contents()) |
| 61 monitor_->SetShelfIDForBrowserWindowContents(browser, web_contents()); | 61 monitor_->SetShelfIDForBrowserWindowContents(browser, web_contents()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual void WebContentsDestroyed() OVERRIDE { | 64 virtual void WebContentsDestroyed() override { |
| 65 // We can only come here when there was a non standard termination like | 65 // We can only come here when there was a non standard termination like |
| 66 // an app got un-installed while running, etc. | 66 // an app got un-installed while running, etc. |
| 67 monitor_->WebContentsDestroyed(web_contents()); | 67 monitor_->WebContentsDestroyed(web_contents()); |
| 68 // |this| is gone now. | 68 // |this| is gone now. |
| 69 } | 69 } |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 BrowserStatusMonitor* monitor_; | 72 BrowserStatusMonitor* monitor_; |
| 73 | 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(LocalWebContentsObserver); | 74 DISALLOW_COPY_AND_ASSIGN(LocalWebContentsObserver); |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 // Observes any new settings windows and sets their shelf icon (since they | 77 // Observes any new settings windows and sets their shelf icon (since they |
| 78 // are excluded from BrowserShortcutLauncherItem). | 78 // are excluded from BrowserShortcutLauncherItem). |
| 79 class BrowserStatusMonitor::SettingsWindowObserver | 79 class BrowserStatusMonitor::SettingsWindowObserver |
| 80 : public chrome::SettingsWindowManagerObserver { | 80 : public chrome::SettingsWindowManagerObserver { |
| 81 public: | 81 public: |
| 82 SettingsWindowObserver() {} | 82 SettingsWindowObserver() {} |
| 83 virtual ~SettingsWindowObserver() {} | 83 virtual ~SettingsWindowObserver() {} |
| 84 | 84 |
| 85 // SettingsWindowManagerObserver | 85 // SettingsWindowManagerObserver |
| 86 virtual void OnNewSettingsWindow(Browser* settings_browser) OVERRIDE { | 86 virtual void OnNewSettingsWindow(Browser* settings_browser) override { |
| 87 ash::SetShelfItemDetailsForDialogWindow( | 87 ash::SetShelfItemDetailsForDialogWindow( |
| 88 settings_browser->window()->GetNativeWindow(), | 88 settings_browser->window()->GetNativeWindow(), |
| 89 IDR_ASH_SHELF_ICON_SETTINGS, | 89 IDR_ASH_SHELF_ICON_SETTINGS, |
| 90 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); | 90 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 DISALLOW_COPY_AND_ASSIGN(SettingsWindowObserver); | 94 DISALLOW_COPY_AND_ASSIGN(SettingsWindowObserver); |
| 95 }; | 95 }; |
| 96 | 96 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 content::WebContents* contents) { | 384 content::WebContents* contents) { |
| 385 return launcher_controller_->GetShelfIDForWebContents(contents); | 385 return launcher_controller_->GetShelfIDForWebContents(contents); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void BrowserStatusMonitor::SetShelfIDForBrowserWindowContents( | 388 void BrowserStatusMonitor::SetShelfIDForBrowserWindowContents( |
| 389 Browser* browser, | 389 Browser* browser, |
| 390 content::WebContents* web_contents) { | 390 content::WebContents* web_contents) { |
| 391 launcher_controller_->GetBrowserShortcutLauncherItemController()-> | 391 launcher_controller_->GetBrowserShortcutLauncherItemController()-> |
| 392 SetShelfIDForBrowserWindowContents(browser, web_contents); | 392 SetShelfIDForBrowserWindowContents(browser, web_contents); |
| 393 } | 393 } |
| OLD | NEW |