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

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

Issue 22429004: Refactor LauncherDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for OpenBrowserUsingShelfOnOhterDisplay fail Created 7 years, 3 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 <vector> 7 #include <vector>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/launcher/launcher.h" 10 #include "ash/launcher/launcher.h"
11 #include "ash/launcher/launcher_item_delegate_manager.h"
11 #include "ash/launcher/launcher_model.h" 12 #include "ash/launcher/launcher_model.h"
12 #include "ash/launcher/launcher_util.h" 13 #include "ash/launcher/launcher_util.h"
13 #include "ash/root_window_controller.h" 14 #include "ash/root_window_controller.h"
14 #include "ash/shelf/shelf_layout_manager.h" 15 #include "ash/shelf/shelf_layout_manager.h"
15 #include "ash/shelf/shelf_widget.h" 16 #include "ash/shelf/shelf_widget.h"
16 #include "ash/shell.h" 17 #include "ash/shell.h"
17 #include "ash/wm/window_util.h" 18 #include "ash/wm/window_util.h"
18 #include "base/command_line.h" 19 #include "base/command_line.h"
19 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 base::Unretained(this))); 237 base::Unretained(this)));
237 pref_change_registrar_.Add( 238 pref_change_registrar_.Add(
238 prefs::kShelfAutoHideBehaviorLocal, 239 prefs::kShelfAutoHideBehaviorLocal,
239 base::Bind(&ChromeLauncherController:: 240 base::Bind(&ChromeLauncherController::
240 SetShelfAutoHideBehaviorFromPrefs, 241 SetShelfAutoHideBehaviorFromPrefs,
241 base::Unretained(this))); 242 base::Unretained(this)));
242 pref_change_registrar_.Add( 243 pref_change_registrar_.Add(
243 prefs::kShelfPreferences, 244 prefs::kShelfPreferences,
244 base::Bind(&ChromeLauncherController::SetShelfBehaviorsFromPrefs, 245 base::Bind(&ChromeLauncherController::SetShelfBehaviorsFromPrefs,
245 base::Unretained(this))); 246 base::Unretained(this)));
247
248 // This check is needed for win7_aura. Without this, all tests in
249 // ChromeLauncherControllerTest will fail by win7_aura.
250 if (ash::Shell::HasInstance())
251 RegisterLauncherItemDelegate();
246 } 252 }
247 253
248 ChromeLauncherController::~ChromeLauncherController() { 254 ChromeLauncherController::~ChromeLauncherController() {
249 // Reset the shell window controller here since it has a weak pointer to this. 255 // Reset the shell window controller here since it has a weak pointer to this.
250 shell_window_controller_.reset(); 256 shell_window_controller_.reset();
251 257
252 for (std::set<ash::Launcher*>::iterator iter = launchers_.begin(); 258 for (std::set<ash::Launcher*>::iterator iter = launchers_.begin();
253 iter != launchers_.end(); 259 iter != launchers_.end();
254 ++iter) 260 ++iter)
255 (*iter)->shelf_widget()->shelf_layout_manager()->RemoveObserver(this); 261 (*iter)->shelf_widget()->shelf_layout_manager()->RemoveObserver(this);
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 browser_to_close.pop_back(); 1650 browser_to_close.pop_back();
1645 } 1651 }
1646 } 1652 }
1647 1653
1648 void 1654 void
1649 ChromeLauncherController::MoveItemWithoutPinnedStateChangeNotification( 1655 ChromeLauncherController::MoveItemWithoutPinnedStateChangeNotification(
1650 int source_index, int target_index) { 1656 int source_index, int target_index) {
1651 base::AutoReset<bool> auto_reset(&ignore_persist_pinned_state_change_, true); 1657 base::AutoReset<bool> auto_reset(&ignore_persist_pinned_state_change_, true);
1652 model_->Move(source_index, target_index); 1658 model_->Move(source_index, target_index);
1653 } 1659 }
1660
1661 void ChromeLauncherController::RegisterLauncherItemDelegate() {
1662 // TODO(simon.hong81): Register LauncherItemDelegate when LauncherItemDelegate
1663 // is created.
1664 ash::LauncherItemDelegateManager* manager =
1665 ash::Shell::GetInstance()->launcher_item_delegate_manager();
1666 manager->RegisterLauncherItemDelegate(ash::TYPE_TABBED, this);
1667 manager->RegisterLauncherItemDelegate(ash::TYPE_APP_PANEL, this);
1668 manager->RegisterLauncherItemDelegate(ash::TYPE_APP_SHORTCUT, this);
1669 manager->RegisterLauncherItemDelegate(ash::TYPE_BROWSER_SHORTCUT, this);
1670 manager->RegisterLauncherItemDelegate(ash::TYPE_PLATFORM_APP, this);
1671 manager->RegisterLauncherItemDelegate(ash::TYPE_WINDOWED_APP, this);
1672 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698