Chromium Code Reviews| 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/common/shelf/shelf_item_types.h" | 7 #include "ash/common/shelf/shelf_item_types.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/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" | 12 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" |
| 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" | 14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
| 17 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
| 18 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/browser/web_applications/web_app.h" | 20 #include "chrome/browser/web_applications/web_app.h" |
| 21 #include "content/public/browser/navigation_handle.h" | |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
| 23 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 24 #include "ui/aura/window_event_dispatcher.h" | 25 #include "ui/aura/window_event_dispatcher.h" |
| 25 #include "ui/wm/public/activation_client.h" | 26 #include "ui/wm/public/activation_client.h" |
| 26 | 27 |
| 27 // This class monitors the WebContent of the all tab and notifies a navigation | 28 // This class monitors the WebContent of the all tab and notifies a navigation |
| 28 // to the BrowserStatusMonitor. | 29 // to the BrowserStatusMonitor. |
| 29 class BrowserStatusMonitor::LocalWebContentsObserver | 30 class BrowserStatusMonitor::LocalWebContentsObserver |
| 30 : public content::WebContentsObserver { | 31 : public content::WebContentsObserver { |
| 31 public: | 32 public: |
| 32 LocalWebContentsObserver(content::WebContents* contents, | 33 LocalWebContentsObserver(content::WebContents* contents, |
| 33 BrowserStatusMonitor* monitor) | 34 BrowserStatusMonitor* monitor) |
| 34 : content::WebContentsObserver(contents), | 35 : content::WebContentsObserver(contents), |
| 35 monitor_(monitor) {} | 36 monitor_(monitor) {} |
| 36 | 37 |
| 37 ~LocalWebContentsObserver() override {} | 38 ~LocalWebContentsObserver() override {} |
| 38 | 39 |
| 39 // content::WebContentsObserver | 40 // content::WebContentsObserver |
| 40 void DidNavigateMainFrame( | 41 void DidFinishNavigation( |
| 41 const content::LoadCommittedDetails& details, | 42 content::NavigationHandle* navigation_handle) override { |
| 42 const content::FrameNavigateParams& params) override { | 43 if (!navigation_handle->IsInMainFrame() || |
| 44 !navigation_handle->HasCommitted()) | |
|
Mr4D (OOO till 08-26)
2017/01/30 16:28:25
Just checking: Is it guaranteed that we will be ca
jam
2017/01/30 16:36:59
This line is to keep parity between the old code:
| |
| 45 return; | |
| 46 | |
| 43 ChromeLauncherController::AppState state = | 47 ChromeLauncherController::AppState state = |
| 44 ChromeLauncherController::APP_STATE_INACTIVE; | 48 ChromeLauncherController::APP_STATE_INACTIVE; |
| 45 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 49 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
| 46 // Don't assume that |browser| still exists. | 50 // Don't assume that |browser| still exists. |
| 47 if (browser) { | 51 if (browser) { |
| 48 if (browser->window()->IsActive() && | 52 if (browser->window()->IsActive() && |
| 49 browser->tab_strip_model()->GetActiveWebContents() == web_contents()) | 53 browser->tab_strip_model()->GetActiveWebContents() == web_contents()) |
| 50 state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE; | 54 state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE; |
| 51 else if (browser->window()->IsActive()) | 55 else if (browser->window()->IsActive()) |
| 52 state = ChromeLauncherController::APP_STATE_ACTIVE; | 56 state = ChromeLauncherController::APP_STATE_ACTIVE; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 content::WebContents* contents) { | 290 content::WebContents* contents) { |
| 287 return launcher_controller_->GetShelfIDForWebContents(contents); | 291 return launcher_controller_->GetShelfIDForWebContents(contents); |
| 288 } | 292 } |
| 289 | 293 |
| 290 void BrowserStatusMonitor::SetShelfIDForBrowserWindowContents( | 294 void BrowserStatusMonitor::SetShelfIDForBrowserWindowContents( |
| 291 Browser* browser, | 295 Browser* browser, |
| 292 content::WebContents* web_contents) { | 296 content::WebContents* web_contents) { |
| 293 launcher_controller_->GetBrowserShortcutLauncherItemController()-> | 297 launcher_controller_->GetBrowserShortcutLauncherItemController()-> |
| 294 SetShelfIDForBrowserWindowContents(browser, web_contents); | 298 SetShelfIDForBrowserWindowContents(browser, web_contents); |
| 295 } | 299 } |
| OLD | NEW |