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

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

Issue 10824204: Move small c/b/extensions classes into extensions namespace no.2 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq + nitfix Created 8 years, 4 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 (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/chrome_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/launcher/launcher_model.h" 10 #include "ash/launcher/launcher_model.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 : model_(model), 69 : model_(model),
70 profile_(profile), 70 profile_(profile),
71 activation_client_(NULL) { 71 activation_client_(NULL) {
72 if (!profile_) { 72 if (!profile_) {
73 // Use the original profile as on chromeos we may get a temporary off the 73 // Use the original profile as on chromeos we may get a temporary off the
74 // record profile. 74 // record profile.
75 profile_ = ProfileManager::GetDefaultProfile()->GetOriginalProfile(); 75 profile_ = ProfileManager::GetDefaultProfile()->GetOriginalProfile();
76 } 76 }
77 instance_ = this; 77 instance_ = this;
78 model_->AddObserver(this); 78 model_->AddObserver(this);
79 ShellWindowRegistry::Get(profile_)->AddObserver(this); 79 extensions::ShellWindowRegistry::Get(profile_)->AddObserver(this);
80 app_tab_helper_.reset(new LauncherAppTabHelper(profile_)); 80 app_tab_helper_.reset(new LauncherAppTabHelper(profile_));
81 app_icon_loader_.reset(new LauncherAppIconLoader(profile_, this)); 81 app_icon_loader_.reset(new LauncherAppIconLoader(profile_, this));
82 82
83 notification_registrar_.Add(this, 83 notification_registrar_.Add(this,
84 chrome::NOTIFICATION_EXTENSION_LOADED, 84 chrome::NOTIFICATION_EXTENSION_LOADED,
85 content::Source<Profile>(profile_)); 85 content::Source<Profile>(profile_));
86 notification_registrar_.Add(this, 86 notification_registrar_.Add(this,
87 chrome::NOTIFICATION_EXTENSION_UNLOADED, 87 chrome::NOTIFICATION_EXTENSION_UNLOADED,
88 content::Source<Profile>(profile_)); 88 content::Source<Profile>(profile_));
89 pref_change_registrar_.Init(profile_->GetPrefs()); 89 pref_change_registrar_.Init(profile_->GetPrefs());
90 pref_change_registrar_.Add(prefs::kPinnedLauncherApps, this); 90 pref_change_registrar_.Add(prefs::kPinnedLauncherApps, this);
91 pref_change_registrar_.Add(prefs::kShelfAlignment, this); 91 pref_change_registrar_.Add(prefs::kShelfAlignment, this);
92 pref_change_registrar_.Add(prefs::kShelfAutoHideBehavior, this); 92 pref_change_registrar_.Add(prefs::kShelfAutoHideBehavior, this);
93 } 93 }
94 94
95 ChromeLauncherController::~ChromeLauncherController() { 95 ChromeLauncherController::~ChromeLauncherController() {
96 ShellWindowRegistry::Get(profile_)->RemoveObserver(this); 96 extensions::ShellWindowRegistry::Get(profile_)->RemoveObserver(this);
97 model_->RemoveObserver(this); 97 model_->RemoveObserver(this);
98 for (IDToItemMap::iterator i = id_to_item_map_.begin(); 98 for (IDToItemMap::iterator i = id_to_item_map_.begin();
99 i != id_to_item_map_.end(); ++i) { 99 i != id_to_item_map_.end(); ++i) {
100 model_->RemoveItemAt(model_->ItemIndexByID(i->first)); 100 model_->RemoveItemAt(model_->ItemIndexByID(i->first));
101 } 101 }
102 if (instance_ == this) 102 if (instance_ == this)
103 instance_ = NULL; 103 instance_ = NULL;
104 if (activation_client_) 104 if (activation_client_)
105 activation_client_->RemoveObserver(this); 105 activation_client_->RemoveObserver(this);
106 106
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 void ChromeLauncherController::LauncherItemClosed(ash::LauncherID id) { 190 void ChromeLauncherController::LauncherItemClosed(ash::LauncherID id) {
191 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); 191 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end());
192 id_to_item_map_.erase(id); 192 id_to_item_map_.erase(id);
193 model_->RemoveItemAt(model_->ItemIndexByID(id)); 193 model_->RemoveItemAt(model_->ItemIndexByID(id));
194 } 194 }
195 195
196 void ChromeLauncherController::Unpin(ash::LauncherID id) { 196 void ChromeLauncherController::Unpin(ash::LauncherID id) {
197 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); 197 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end());
198 DCHECK(!id_to_item_map_[id].controller); 198 DCHECK(!id_to_item_map_[id].controller);
199 199
200 if (ShellWindowRegistry::Get(profile_)->GetShellWindowsForApp( 200 if (extensions::ShellWindowRegistry::Get(profile_)->GetShellWindowsForApp(
201 id_to_item_map_[id].app_id).size() > 0) { 201 id_to_item_map_[id].app_id).size() > 0) {
202 int index = model_->ItemIndexByID(id); 202 int index = model_->ItemIndexByID(id);
203 ash::LauncherItem item = model_->items()[index]; 203 ash::LauncherItem item = model_->items()[index];
204 item.type = ash::TYPE_PLATFORM_APP; 204 item.type = ash::TYPE_PLATFORM_APP;
205 model_->Set(index, item); 205 model_->Set(index, item);
206 } else { 206 } else {
207 LauncherItemClosed(id); 207 LauncherItemClosed(id);
208 } 208 }
209 if (CanPin()) 209 if (CanPin())
210 PersistPinnedState(); 210 PersistPinnedState();
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 699
700 void ChromeLauncherController::OnWindowRemovingFromRootWindow( 700 void ChromeLauncherController::OnWindowRemovingFromRootWindow(
701 aura::Window* window) { 701 aura::Window* window) {
702 window->RemoveObserver(this); 702 window->RemoveObserver(this);
703 DCHECK(window_to_id_map_.find(window) != window_to_id_map_.end()); 703 DCHECK(window_to_id_map_.find(window) != window_to_id_map_.end());
704 ash::LauncherID id = window_to_id_map_[window]; 704 ash::LauncherID id = window_to_id_map_[window];
705 window_to_id_map_.erase(window); 705 window_to_id_map_.erase(window);
706 706
707 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); 707 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end());
708 platform_app_windows_.remove(window); 708 platform_app_windows_.remove(window);
709 ShellWindowRegistry::ShellWindowSet remaining_windows = 709 extensions::ShellWindowRegistry::ShellWindowSet remaining_windows =
710 ShellWindowRegistry::Get(profile_)->GetShellWindowsForApp( 710 extensions::ShellWindowRegistry::Get(profile_)->GetShellWindowsForApp(
711 id_to_item_map_[id].app_id); 711 id_to_item_map_[id].app_id);
712 712
713 // We can't count on getting called before or after the ShellWindowRegistry. 713 // We can't count on getting called before or after the ShellWindowRegistry.
714 if (remaining_windows.size() > 1 || 714 if (remaining_windows.size() > 1 ||
715 (remaining_windows.size() == 1 && 715 (remaining_windows.size() == 1 &&
716 (*remaining_windows.begin())->GetNativeWindow() != window)) { 716 (*remaining_windows.begin())->GetNativeWindow() != window)) {
717 return; 717 return;
718 } 718 }
719 719
720 // Close or remove item. 720 // Close or remove item.
721 int index = model_->ItemIndexByID(id); 721 int index = model_->ItemIndexByID(id);
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 } 989 }
990 model_->AddAt(index, item); 990 model_->AddAt(index, item);
991 991
992 if (!controller || controller->type() != 992 if (!controller || controller->type() !=
993 BrowserLauncherItemController::TYPE_EXTENSION_PANEL) { 993 BrowserLauncherItemController::TYPE_EXTENSION_PANEL) {
994 if (item.status != ash::STATUS_IS_PENDING) 994 if (item.status != ash::STATUS_IS_PENDING)
995 app_icon_loader_->FetchImage(app_id); 995 app_icon_loader_->FetchImage(app_id);
996 } 996 }
997 return id; 997 return id;
998 } 998 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698