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

Side by Side Diff: trunk/src/chrome/browser/ui/ash/launcher/shell_window_launcher_controller.cc

Issue 25716004: Revert 226547 "Refactor LauncherItemController and LauncherItemD..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 2 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/ash/launcher/shell_window_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h"
6 6
7 #include "apps/shell_window.h" 7 #include "apps/shell_window.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "base/stl_util.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
13 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h " 14 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h "
14 #include "ui/aura/client/activation_client.h" 15 #include "ui/aura/client/activation_client.h"
15 16
16 using apps::ShellWindow; 17 using apps::ShellWindow;
17 18
18 namespace { 19 namespace {
19 20
(...skipping 14 matching lines...) Expand all
34 if (ash::Shell::HasInstance()) { 35 if (ash::Shell::HasInstance()) {
35 if (ash::Shell::GetInstance()->GetPrimaryRootWindow()) { 36 if (ash::Shell::GetInstance()->GetPrimaryRootWindow()) {
36 activation_client_ = aura::client::GetActivationClient( 37 activation_client_ = aura::client::GetActivationClient(
37 ash::Shell::GetInstance()->GetPrimaryRootWindow()); 38 ash::Shell::GetInstance()->GetPrimaryRootWindow());
38 if (activation_client_) 39 if (activation_client_)
39 activation_client_->AddObserver(this); 40 activation_client_->AddObserver(this);
40 } 41 }
41 } 42 }
42 } 43 }
43 44
45
44 ShellWindowLauncherController::~ShellWindowLauncherController() { 46 ShellWindowLauncherController::~ShellWindowLauncherController() {
45 registry_->RemoveObserver(this); 47 registry_->RemoveObserver(this);
46 if (activation_client_) 48 if (activation_client_)
47 activation_client_->RemoveObserver(this); 49 activation_client_->RemoveObserver(this);
48 for (WindowToAppLauncherIdMap::iterator iter = 50 for (WindowToAppLauncherIdMap::iterator iter =
49 window_to_app_launcher_id_map_.begin(); 51 window_to_app_launcher_id_map_.begin();
50 iter != window_to_app_launcher_id_map_.end(); ++iter) { 52 iter != window_to_app_launcher_id_map_.end(); ++iter) {
51 iter->first->RemoveObserver(this); 53 iter->first->RemoveObserver(this);
52 } 54 }
55 STLDeleteContainerPairSecondPointers(
56 app_controller_map_.begin(), app_controller_map_.end());
53 } 57 }
54 58
55 void ShellWindowLauncherController::OnShellWindowAdded( 59 void ShellWindowLauncherController::OnShellWindowAdded(
56 ShellWindow* shell_window) { 60 ShellWindow* shell_window) {
57 aura::Window* window = shell_window->GetNativeWindow(); 61 aura::Window* window = shell_window->GetNativeWindow();
58 // Get the app's launcher identifier and add an entry to the map. 62 // Get the app's launcher identifier and add an entry to the map.
59 DCHECK(window_to_app_launcher_id_map_.find(window) == 63 DCHECK(window_to_app_launcher_id_map_.find(window) ==
60 window_to_app_launcher_id_map_.end()); 64 window_to_app_launcher_id_map_.end());
61 const std::string app_launcher_id = GetAppLauncherId(shell_window); 65 const std::string app_launcher_id = GetAppLauncherId(shell_window);
62 window_to_app_launcher_id_map_[window] = app_launcher_id; 66 window_to_app_launcher_id_map_[window] = app_launcher_id;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 AppControllerMap::iterator iter2 = app_controller_map_.find(app_launcher_id); 131 AppControllerMap::iterator iter2 = app_controller_map_.find(app_launcher_id);
128 DCHECK(iter2 != app_controller_map_.end()); 132 DCHECK(iter2 != app_controller_map_.end());
129 ShellWindowLauncherItemController* controller = iter2->second; 133 ShellWindowLauncherItemController* controller = iter2->second;
130 controller->RemoveShellWindowForWindow(window); 134 controller->RemoveShellWindowForWindow(window);
131 if (controller->shell_window_count() == 0) { 135 if (controller->shell_window_count() == 0) {
132 // If this is the last window associated with the app launcher id, close the 136 // If this is the last window associated with the app launcher id, close the
133 // launcher item. 137 // launcher item.
134 ash::LauncherID launcher_id = controller->launcher_id(); 138 ash::LauncherID launcher_id = controller->launcher_id();
135 owner_->CloseLauncherItem(launcher_id); 139 owner_->CloseLauncherItem(launcher_id);
136 app_controller_map_.erase(iter2); 140 app_controller_map_.erase(iter2);
141 delete controller;
137 } 142 }
138 } 143 }
139 144
140 void ShellWindowLauncherController::OnWindowActivated( 145 void ShellWindowLauncherController::OnWindowActivated(
141 aura::Window* new_active, 146 aura::Window* new_active,
142 aura::Window* old_active) { 147 aura::Window* old_active) {
143 // Make the newly active window the active (first) entry in the controller. 148 // Make the newly active window the active (first) entry in the controller.
144 ShellWindowLauncherItemController* new_controller = 149 ShellWindowLauncherItemController* new_controller =
145 ControllerForWindow(new_active); 150 ControllerForWindow(new_active);
146 if (new_controller) { 151 if (new_controller) {
(...skipping 16 matching lines...) Expand all
163 WindowToAppLauncherIdMap::iterator iter1 = 168 WindowToAppLauncherIdMap::iterator iter1 =
164 window_to_app_launcher_id_map_.find(window); 169 window_to_app_launcher_id_map_.find(window);
165 if (iter1 == window_to_app_launcher_id_map_.end()) 170 if (iter1 == window_to_app_launcher_id_map_.end())
166 return NULL; 171 return NULL;
167 std::string app_launcher_id = iter1->second; 172 std::string app_launcher_id = iter1->second;
168 AppControllerMap::iterator iter2 = app_controller_map_.find(app_launcher_id); 173 AppControllerMap::iterator iter2 = app_controller_map_.find(app_launcher_id);
169 if (iter2 == app_controller_map_.end()) 174 if (iter2 == app_controller_map_.end())
170 return NULL; 175 return NULL;
171 return iter2->second; 176 return iter2->second;
172 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698