Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.cc

Issue 10392173: Flash window by pulsing their launcher icon state indicator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some cleanup Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/views/ash/launcher/browser_launcher_item_controller. h" 5 #include "chrome/browser/ui/views/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/extension_tab_helper.h" 12 #include "chrome/browser/extensions/extension_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/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" 18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
19 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h" 19 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h"
20 #include "chrome/browser/web_applications/web_app.h" 20 #include "chrome/browser/web_applications/web_app.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "grit/ui_resources.h" 22 #include "grit/ui_resources.h"
23 #include "ui/aura/client/aura_constants.h"
23 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
24 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
25 26
26 BrowserLauncherItemController::BrowserLauncherItemController( 27 BrowserLauncherItemController::BrowserLauncherItemController(
27 aura::Window* window, 28 aura::Window* window,
28 TabStripModel* tab_model, 29 TabStripModel* tab_model,
29 ChromeLauncherController* launcher_controller, 30 ChromeLauncherController* launcher_controller,
30 Type type, 31 Type type,
31 const std::string& app_id) 32 const std::string& app_id)
32 : window_(window), 33 : window_(window),
33 tab_model_(tab_model), 34 tab_model_(tab_model),
34 launcher_controller_(launcher_controller), 35 launcher_controller_(launcher_controller),
35 type_(type), 36 type_(type),
36 app_id_(app_id), 37 app_id_(app_id),
37 is_incognito_(tab_model->profile()->GetOriginalProfile() != 38 is_incognito_(tab_model->profile()->GetOriginalProfile() !=
38 tab_model->profile() && !Profile::IsGuestSession()), 39 tab_model->profile() && !Profile::IsGuestSession()),
39 item_id_(-1) { 40 item_id_(-1) {
41 window_->AddObserver(this);
sky 2012/05/18 22:29:42 We're going to want to support this for windows ot
40 } 42 }
41 43
42 BrowserLauncherItemController::~BrowserLauncherItemController() { 44 BrowserLauncherItemController::~BrowserLauncherItemController() {
43 tab_model_->RemoveObserver(this); 45 tab_model_->RemoveObserver(this);
46 window_->RemoveObserver(this);
44 if (item_id_ != -1) 47 if (item_id_ != -1)
45 launcher_controller_->LauncherItemClosed(item_id_); 48 launcher_controller_->LauncherItemClosed(item_id_);
46 } 49 }
47 50
48 void BrowserLauncherItemController::Init() { 51 void BrowserLauncherItemController::Init() {
49 tab_model_->AddObserver(this); 52 tab_model_->AddObserver(this);
50 ash::LauncherItemStatus app_status = 53 ash::LauncherItemStatus app_status =
51 ash::wm::IsActiveWindow(window_) ? 54 ash::wm::IsActiveWindow(window_) ?
52 ash::STATUS_ACTIVE : ash::STATUS_RUNNING; 55 ash::STATUS_ACTIVE : ash::STATUS_RUNNING;
53 if (type_ != TYPE_TABBED) { 56 if (type_ != TYPE_TABBED) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 91 }
89 BrowserLauncherItemController* icon_updater = 92 BrowserLauncherItemController* icon_updater =
90 new BrowserLauncherItemController( 93 new BrowserLauncherItemController(
91 browser->window()->GetNativeHandle(), browser->tab_strip_model(), 94 browser->window()->GetNativeHandle(), browser->tab_strip_model(),
92 ChromeLauncherController::instance(), type, app_id); 95 ChromeLauncherController::instance(), type, app_id);
93 icon_updater->Init(); 96 icon_updater->Init();
94 return icon_updater; 97 return icon_updater;
95 } 98 }
96 99
97 void BrowserLauncherItemController::BrowserActivationStateChanged() { 100 void BrowserLauncherItemController::BrowserActivationStateChanged() {
98 launcher_controller_->SetItemStatus( 101 UpdateItemStatus();
99 item_id_,
100 ash::wm::IsActiveWindow(window_) ?
101 ash::STATUS_ACTIVE : ash::STATUS_RUNNING);
102 } 102 }
103 103
104 void BrowserLauncherItemController::ActiveTabChanged( 104 void BrowserLauncherItemController::ActiveTabChanged(
105 TabContentsWrapper* old_contents, 105 TabContentsWrapper* old_contents,
106 TabContentsWrapper* new_contents, 106 TabContentsWrapper* new_contents,
107 int index, 107 int index,
108 bool user_gesture) { 108 bool user_gesture) {
109 // Update immediately on a tab change. 109 // Update immediately on a tab change.
110 UpdateLauncher(new_contents); 110 UpdateLauncher(new_contents);
111 } 111 }
(...skipping 19 matching lines...) Expand all
131 ash::LauncherItem item = launcher_model()->items()[item_index]; 131 ash::LauncherItem item = launcher_model()->items()[item_index];
132 item.image = SkBitmap(); 132 item.image = SkBitmap();
133 launcher_model()->Set(item_index, item); 133 launcher_model()->Set(item_index, item);
134 } 134 }
135 } 135 }
136 136
137 void BrowserLauncherItemController::FaviconUpdated() { 137 void BrowserLauncherItemController::FaviconUpdated() {
138 UpdateLauncher(tab_model_->GetActiveTabContents()); 138 UpdateLauncher(tab_model_->GetActiveTabContents());
139 } 139 }
140 140
141 void BrowserLauncherItemController::OnWindowPropertyChanged(
142 aura::Window* window,
143 const void* key,
144 intptr_t old) {
145 if (key == aura::client::kDrawAttentionKey)
146 UpdateItemStatus();
147 }
148
149 void BrowserLauncherItemController::UpdateItemStatus() {
150 ash::LauncherItemStatus status;
151 if (ash::wm::IsActiveWindow(window_)) {
152 // Clear attention state if active.
153 if (window_->GetProperty(aura::client::kDrawAttentionKey))
154 window_->SetProperty(aura::client::kDrawAttentionKey, false);
155 status = ash::STATUS_ACTIVE;
156 } else if (window_->GetProperty(aura::client::kDrawAttentionKey)) {
157 status = ash::STATUS_ATTENTION;
158 } else {
159 status = ash::STATUS_RUNNING;
160 }
161 launcher_controller_->SetItemStatus(item_id_, status);
162 }
163
141 void BrowserLauncherItemController::UpdateLauncher(TabContentsWrapper* tab) { 164 void BrowserLauncherItemController::UpdateLauncher(TabContentsWrapper* tab) {
142 if (type_ == TYPE_APP_PANEL) 165 if (type_ == TYPE_APP_PANEL)
143 return; // Maintained entirely by ChromeLauncherController. 166 return; // Maintained entirely by ChromeLauncherController.
144 167
145 if (!tab) 168 if (!tab)
146 return; // Assume the window is going to be closed if there are no tabs. 169 return; // Assume the window is going to be closed if there are no tabs.
147 170
148 int item_index = launcher_model()->ItemIndexByID(item_id_); 171 int item_index = launcher_model()->ItemIndexByID(item_id_);
149 if (item_index == -1) 172 if (item_index == -1)
150 return; 173 return;
(...skipping 26 matching lines...) Expand all
177 } else { 200 } else {
178 item.image = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); 201 item.image = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
179 } 202 }
180 } 203 }
181 launcher_model()->Set(item_index, item); 204 launcher_model()->Set(item_index, item);
182 } 205 }
183 206
184 ash::LauncherModel* BrowserLauncherItemController::launcher_model() { 207 ash::LauncherModel* BrowserLauncherItemController::launcher_model() {
185 return launcher_controller_->model(); 208 return launcher_controller_->model();
186 } 209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698