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

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

Issue 1743493002: Cleanup ash shelf accessor functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert ash/shelf/shelf_widget.cc for browser_tests crash... Created 4 years, 9 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
OLDNEW
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/chrome_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/ash_switches.h" 11 #include "ash/ash_switches.h"
12 #include "ash/desktop_background/desktop_background_controller.h" 12 #include "ash/desktop_background/desktop_background_controller.h"
13 #include "ash/multi_profile_uma.h" 13 #include "ash/multi_profile_uma.h"
14 #include "ash/root_window_controller.h" 14 #include "ash/root_window_controller.h"
15 #include "ash/shelf/shelf.h" 15 #include "ash/shelf/shelf.h"
16 #include "ash/shelf/shelf_item_delegate_manager.h" 16 #include "ash/shelf/shelf_item_delegate_manager.h"
17 #include "ash/shelf/shelf_layout_manager.h" 17 #include "ash/shelf/shelf_layout_manager.h"
18 #include "ash/shelf/shelf_model.h" 18 #include "ash/shelf/shelf_model.h"
19 #include "ash/shelf/shelf_widget.h"
20 #include "ash/shell.h" 19 #include "ash/shell.h"
21 #include "ash/system/tray/system_tray_delegate.h" 20 #include "ash/system/tray/system_tray_delegate.h"
22 #include "ash/wm/window_util.h" 21 #include "ash/wm/window_util.h"
23 #include "base/command_line.h" 22 #include "base/command_line.h"
24 #include "base/macros.h" 23 #include "base/macros.h"
25 #include "base/strings/pattern.h" 24 #include "base/strings/pattern.h"
26 #include "base/strings/string_number_conversions.h" 25 #include "base/strings/string_number_conversions.h"
27 #include "base/strings/string_util.h" 26 #include "base/strings/string_util.h"
28 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
29 #include "base/values.h" 28 #include "base/values.h"
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 ChromeLauncherController::~ChromeLauncherController() { 496 ChromeLauncherController::~ChromeLauncherController() {
498 if (item_delegate_manager_) 497 if (item_delegate_manager_)
499 item_delegate_manager_->RemoveObserver(this); 498 item_delegate_manager_->RemoveObserver(this);
500 499
501 // Reset the BrowserStatusMonitor as it has a weak pointer to this. 500 // Reset the BrowserStatusMonitor as it has a weak pointer to this.
502 browser_status_monitor_.reset(); 501 browser_status_monitor_.reset();
503 502
504 // Reset the app window controller here since it has a weak pointer to this. 503 // Reset the app window controller here since it has a weak pointer to this.
505 app_window_controller_.reset(); 504 app_window_controller_.reset();
506 505
507 for (std::set<ash::Shelf*>::iterator iter = shelves_.begin(); 506 for (auto iter : shelves_)
508 iter != shelves_.end(); 507 iter->shelf_layout_manager()->RemoveObserver(this);
509 ++iter)
510 (*iter)->shelf_widget()->shelf_layout_manager()->RemoveObserver(this);
511 508
512 model_->RemoveObserver(this); 509 model_->RemoveObserver(this);
513 if (ash::Shell::HasInstance()) 510 if (ash::Shell::HasInstance())
514 ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); 511 ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
515 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin(); 512 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin();
516 i != id_to_item_controller_map_.end(); ++i) { 513 i != id_to_item_controller_map_.end(); ++i) {
517 int index = model_->ItemIndexByID(i->first); 514 int index = model_->ItemIndexByID(i->first);
518 // A "browser proxy" is not known to the model and this removal does 515 // A "browser proxy" is not known to the model and this removal does
519 // therefore not need to be propagated to the model. 516 // therefore not need to be propagated to the model.
520 if (index != -1 && 517 if (index != -1 &&
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 return ash::ShelfItemDelegate::kNoAction; 1160 return ash::ShelfItemDelegate::kNoAction;
1164 } 1161 }
1165 1162
1166 window->Show(); 1163 window->Show();
1167 window->Activate(); 1164 window->Activate();
1168 return ash::ShelfItemDelegate::kExistingWindowActivated; 1165 return ash::ShelfItemDelegate::kExistingWindowActivated;
1169 } 1166 }
1170 1167
1171 void ChromeLauncherController::OnShelfCreated(ash::Shelf* shelf) { 1168 void ChromeLauncherController::OnShelfCreated(ash::Shelf* shelf) {
1172 shelves_.insert(shelf); 1169 shelves_.insert(shelf);
1173 shelf->shelf_widget()->shelf_layout_manager()->AddObserver(this); 1170 shelf->shelf_layout_manager()->AddObserver(this);
1174 } 1171 }
1175 1172
1176 void ChromeLauncherController::OnShelfDestroyed(ash::Shelf* shelf) { 1173 void ChromeLauncherController::OnShelfDestroyed(ash::Shelf* shelf) {
1177 shelves_.erase(shelf); 1174 shelves_.erase(shelf);
1178 // RemoveObserver is not called here, since by the time this method is called 1175 // RemoveObserver is not called here, since by the time this method is called
1179 // Shelf is already in its destructor. 1176 // Shelf is already in its destructor.
1180 } 1177 }
1181 1178
1182 void ChromeLauncherController::ShelfItemAdded(int index) { 1179 void ChromeLauncherController::ShelfItemAdded(int index) {
1183 // The app list launcher can get added to the shelf after we applied the 1180 // The app list launcher can get added to the shelf after we applied the
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 2250
2254 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp( 2251 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp(
2255 const std::string& app_id) { 2252 const std::string& app_id) {
2256 for (const auto& app_icon_loader : app_icon_loaders_) { 2253 for (const auto& app_icon_loader : app_icon_loaders_) {
2257 if (app_icon_loader->CanLoadImageForApp(app_id)) 2254 if (app_icon_loader->CanLoadImageForApp(app_id))
2258 return app_icon_loader.get(); 2255 return app_icon_loader.get();
2259 } 2256 }
2260 2257
2261 return nullptr; 2258 return nullptr;
2262 } 2259 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/accessibility/chromevox_panel.cc ('k') | chrome/browser/ui/ash/shelf_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698