| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_launcher_item_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/launcher/launcher_model.h" | 8 #include "ash/launcher/launcher_model.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/extensions/tab_helper.h" | 12 #include "chrome/browser/extensions/tab_helper.h" |
| 13 #include "chrome/browser/favicon/favicon_tab_helper.h" | 13 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/browser/web_applications/web_app.h" | 19 #include "chrome/browser/web_applications/web_app.h" |
| 21 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 22 #include "grit/ui_resources.h" | 21 #include "grit/ui_resources.h" |
| 23 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
| 24 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 25 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 26 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
| 27 | 26 |
| 28 using extensions::Extension; | 27 using extensions::Extension; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 57 if (type() != TYPE_TABBED) { | 56 if (type() != TYPE_TABBED) { |
| 58 launcher_controller()->CreateAppLauncherItem(this, app_id(), app_status); | 57 launcher_controller()->CreateAppLauncherItem(this, app_id(), app_status); |
| 59 } else { | 58 } else { |
| 60 launcher_controller()->CreateTabbedLauncherItem( | 59 launcher_controller()->CreateTabbedLauncherItem( |
| 61 this, | 60 this, |
| 62 is_incognito_ ? ChromeLauncherController::STATE_INCOGNITO : | 61 is_incognito_ ? ChromeLauncherController::STATE_INCOGNITO : |
| 63 ChromeLauncherController::STATE_NOT_INCOGNITO, | 62 ChromeLauncherController::STATE_NOT_INCOGNITO, |
| 64 app_status); | 63 app_status); |
| 65 } | 64 } |
| 66 // In testing scenarios we can get tab strips with no active contents. | 65 // In testing scenarios we can get tab strips with no active contents. |
| 67 if (tab_model_->GetActiveTabContents()) | 66 if (tab_model_->active_index() != TabStripModel::kNoTab) |
| 68 UpdateLauncher(tab_model_->GetActiveWebContents()); | 67 UpdateLauncher(tab_model_->GetActiveWebContents()); |
| 69 } | 68 } |
| 70 | 69 |
| 71 // static | 70 // static |
| 72 BrowserLauncherItemController* BrowserLauncherItemController::Create( | 71 BrowserLauncherItemController* BrowserLauncherItemController::Create( |
| 73 Browser* browser) { | 72 Browser* browser) { |
| 74 // Under testing this can be called before the controller is created. | 73 // Under testing this can be called before the controller is created. |
| 75 if (!ChromeLauncherController::instance()) | 74 if (!ChromeLauncherController::instance()) |
| 76 return NULL; | 75 return NULL; |
| 77 | 76 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 104 | 103 |
| 105 void BrowserLauncherItemController::BrowserActivationStateChanged() { | 104 void BrowserLauncherItemController::BrowserActivationStateChanged() { |
| 106 content::WebContents* active_contents = tab_model_->GetActiveWebContents(); | 105 content::WebContents* active_contents = tab_model_->GetActiveWebContents(); |
| 107 if (active_contents) | 106 if (active_contents) |
| 108 UpdateAppState(active_contents); | 107 UpdateAppState(active_contents); |
| 109 UpdateItemStatus(); | 108 UpdateItemStatus(); |
| 110 } | 109 } |
| 111 | 110 |
| 112 string16 BrowserLauncherItemController::GetTitle() { | 111 string16 BrowserLauncherItemController::GetTitle() { |
| 113 if (type() == TYPE_TABBED || type() == TYPE_EXTENSION_PANEL) { | 112 if (type() == TYPE_TABBED || type() == TYPE_EXTENSION_PANEL) { |
| 114 if (tab_model_->GetActiveTabContents()) { | 113 if (tab_model_->active_index() != TabStripModel::kNoTab) { |
| 115 const content::WebContents* contents = | 114 const content::WebContents* contents = tab_model_->GetActiveWebContents(); |
| 116 tab_model_->GetActiveTabContents()->web_contents(); | |
| 117 if (contents) | 115 if (contents) |
| 118 return contents->GetTitle(); | 116 return contents->GetTitle(); |
| 119 } | 117 } |
| 120 } | 118 } |
| 121 return GetAppTitle(); | 119 return GetAppTitle(); |
| 122 } | 120 } |
| 123 | 121 |
| 124 bool BrowserLauncherItemController::HasWindow(aura::Window* window) const { | 122 bool BrowserLauncherItemController::HasWindow(aura::Window* window) const { |
| 125 return window_ == window; | 123 return window_ == window; |
| 126 } | 124 } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 app_state = ChromeLauncherController::APP_STATE_ACTIVE; | 300 app_state = ChromeLauncherController::APP_STATE_ACTIVE; |
| 303 } else { | 301 } else { |
| 304 app_state = ChromeLauncherController::APP_STATE_INACTIVE; | 302 app_state = ChromeLauncherController::APP_STATE_INACTIVE; |
| 305 } | 303 } |
| 306 launcher_controller()->UpdateAppState(tab, app_state); | 304 launcher_controller()->UpdateAppState(tab, app_state); |
| 307 } | 305 } |
| 308 | 306 |
| 309 ash::LauncherModel* BrowserLauncherItemController::launcher_model() { | 307 ash::LauncherModel* BrowserLauncherItemController::launcher_model() { |
| 310 return launcher_controller()->model(); | 308 return launcher_controller()->model(); |
| 311 } | 309 } |
| OLD | NEW |