OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/views/aura/launcher_icon_updater.h" | 5 #include "chrome/browser/ui/views/aura/launcher_icon_updater.h" |
6 | 6 |
7 #include "ash/launcher/launcher_model.h" | 7 #include "ash/launcher/launcher_model.h" |
8 #include "chrome/browser/extensions/extension_tab_helper.h" | 8 #include "chrome/browser/extensions/extension_tab_helper.h" |
9 #include "chrome/browser/favicon/favicon_tab_helper.h" | 9 #include "chrome/browser/favicon/favicon_tab_helper.h" |
10 #include "chrome/browser/tabs/tab_strip_model.h" | 10 #include "chrome/browser/tabs/tab_strip_model.h" |
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
12 #include "grit/ui_resources.h" | 12 #include "grit/ui_resources.h" |
13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
15 | 15 |
16 LauncherIconUpdater::LauncherIconUpdater( | 16 LauncherIconUpdater::LauncherIconUpdater( |
17 TabStripModel* tab_model, | 17 TabStripModel* tab_model, |
18 aura_shell::LauncherModel* launcher_model, | 18 ash::LauncherModel* launcher_model, |
19 aura::Window* window) | 19 aura::Window* window) |
20 : tab_model_(tab_model), | 20 : tab_model_(tab_model), |
21 launcher_model_(launcher_model), | 21 launcher_model_(launcher_model), |
22 window_(window) { | 22 window_(window) { |
23 tab_model->AddObserver(this); | 23 tab_model->AddObserver(this); |
24 UpdateLauncher(tab_model_->GetActiveTabContents()); | 24 UpdateLauncher(tab_model_->GetActiveTabContents()); |
25 } | 25 } |
26 | 26 |
27 LauncherIconUpdater::~LauncherIconUpdater() { | 27 LauncherIconUpdater::~LauncherIconUpdater() { |
28 tab_model_->RemoveObserver(this); | 28 tab_model_->RemoveObserver(this); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 | 61 |
62 void LauncherIconUpdater::UpdateLauncher(TabContentsWrapper* tab) { | 62 void LauncherIconUpdater::UpdateLauncher(TabContentsWrapper* tab) { |
63 if (!tab) | 63 if (!tab) |
64 return; // Assume the window is going to be closed if there are no tabs. | 64 return; // Assume the window is going to be closed if there are no tabs. |
65 | 65 |
66 int item_index = launcher_model_->ItemIndexByWindow(window_); | 66 int item_index = launcher_model_->ItemIndexByWindow(window_); |
67 if (item_index == -1) | 67 if (item_index == -1) |
68 return; | 68 return; |
69 | 69 |
70 if (launcher_model_->items()[item_index].type == aura_shell::TYPE_APP) { | 70 if (launcher_model_->items()[item_index].type == ash::TYPE_APP) { |
71 // Use the app icon if we can. | 71 // Use the app icon if we can. |
72 SkBitmap image; | 72 SkBitmap image; |
73 if (tab->extension_tab_helper()->GetExtensionAppIcon()) | 73 if (tab->extension_tab_helper()->GetExtensionAppIcon()) |
74 image = *tab->extension_tab_helper()->GetExtensionAppIcon(); | 74 image = *tab->extension_tab_helper()->GetExtensionAppIcon(); |
75 else | 75 else |
76 image = tab->favicon_tab_helper()->GetFavicon(); | 76 image = tab->favicon_tab_helper()->GetFavicon(); |
77 launcher_model_->SetAppImage(item_index, image); | 77 launcher_model_->SetAppImage(item_index, image); |
78 return; | 78 return; |
79 } | 79 } |
80 | 80 |
81 aura_shell::LauncherTabbedImages images; | 81 ash::LauncherTabbedImages images; |
82 if (tab->favicon_tab_helper()->ShouldDisplayFavicon()) { | 82 if (tab->favicon_tab_helper()->ShouldDisplayFavicon()) { |
83 images.resize(1); | 83 images.resize(1); |
84 images[0].image = tab->favicon_tab_helper()->GetFavicon(); | 84 images[0].image = tab->favicon_tab_helper()->GetFavicon(); |
85 if (images[0].image.empty()) { | 85 if (images[0].image.empty()) { |
86 images[0].image = *ResourceBundle::GetSharedInstance().GetBitmapNamed( | 86 images[0].image = *ResourceBundle::GetSharedInstance().GetBitmapNamed( |
87 IDR_DEFAULT_FAVICON); | 87 IDR_DEFAULT_FAVICON); |
88 } | 88 } |
89 images[0].user_data = tab; | 89 images[0].user_data = tab; |
90 } | 90 } |
91 launcher_model_->SetTabbedImages(item_index, images); | 91 launcher_model_->SetTabbedImages(item_index, images); |
92 } | 92 } |
OLD | NEW |