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

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

Issue 494033002: Move AppWindow to extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded include in chrome_shell_delegate.cc Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/app_window_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h"
6 6
7 #include "apps/app_window.h"
8 #include "ash/shelf/shelf_util.h" 7 #include "ash/shelf/shelf_util.h"
9 #include "ash/shell.h" 8 #include "ash/shell.h"
10 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
11 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
12 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" 12 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h"
14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
15 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 14 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
16 #include "chrome/browser/ui/host_desktop.h" 15 #include "chrome/browser/ui/host_desktop.h"
16 #include "extensions/browser/app_window/app_window.h"
17 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
18 #include "ui/aura/window_event_dispatcher.h" 18 #include "ui/aura/window_event_dispatcher.h"
19 #include "ui/wm/public/activation_client.h" 19 #include "ui/wm/public/activation_client.h"
20 20
21 using apps::AppWindow; 21 using extensions::AppWindow;
22 using extensions::AppWindowRegistry;
22 23
23 namespace { 24 namespace {
24 25
25 std::string GetAppShelfId(AppWindow* app_window) { 26 std::string GetAppShelfId(AppWindow* app_window) {
26 if (app_window->window_type_is_panel()) 27 if (app_window->window_type_is_panel())
27 return base::StringPrintf("panel:%d", app_window->session_id().id()); 28 return base::StringPrintf("panel:%d", app_window->session_id().id());
28 return app_window->extension_id(); 29 return app_window->extension_id();
29 } 30 }
30 31
31 bool ControlsWindow(aura::Window* window) { 32 bool ControlsWindow(aura::Window* window) {
32 return chrome::GetHostDesktopTypeForNativeWindow(window) == 33 return chrome::GetHostDesktopTypeForNativeWindow(window) ==
33 chrome::HOST_DESKTOP_TYPE_ASH; 34 chrome::HOST_DESKTOP_TYPE_ASH;
34 } 35 }
35 36
36 } // namespace 37 } // namespace
37 38
38 AppWindowLauncherController::AppWindowLauncherController( 39 AppWindowLauncherController::AppWindowLauncherController(
39 ChromeLauncherController* owner) 40 ChromeLauncherController* owner)
40 : owner_(owner), activation_client_(NULL) { 41 : owner_(owner), activation_client_(NULL) {
41 apps::AppWindowRegistry* registry = 42 AppWindowRegistry* registry = AppWindowRegistry::Get(owner->profile());
42 apps::AppWindowRegistry::Get(owner->profile());
43 registry_.insert(registry); 43 registry_.insert(registry);
44 registry->AddObserver(this); 44 registry->AddObserver(this);
45 if (ash::Shell::HasInstance()) { 45 if (ash::Shell::HasInstance()) {
46 if (ash::Shell::GetInstance()->GetPrimaryRootWindow()) { 46 if (ash::Shell::GetInstance()->GetPrimaryRootWindow()) {
47 activation_client_ = aura::client::GetActivationClient( 47 activation_client_ = aura::client::GetActivationClient(
48 ash::Shell::GetInstance()->GetPrimaryRootWindow()); 48 ash::Shell::GetInstance()->GetPrimaryRootWindow());
49 if (activation_client_) 49 if (activation_client_)
50 activation_client_->AddObserver(this); 50 activation_client_->AddObserver(this);
51 } 51 }
52 } 52 }
53 } 53 }
54 54
55 AppWindowLauncherController::~AppWindowLauncherController() { 55 AppWindowLauncherController::~AppWindowLauncherController() {
56 for (std::set<apps::AppWindowRegistry*>::iterator it = registry_.begin(); 56 for (std::set<AppWindowRegistry*>::iterator it = registry_.begin();
57 it != registry_.end(); 57 it != registry_.end();
58 ++it) 58 ++it)
59 (*it)->RemoveObserver(this); 59 (*it)->RemoveObserver(this);
60 60
61 if (activation_client_) 61 if (activation_client_)
62 activation_client_->RemoveObserver(this); 62 activation_client_->RemoveObserver(this);
63 for (WindowToAppShelfIdMap::iterator iter = 63 for (WindowToAppShelfIdMap::iterator iter =
64 window_to_app_shelf_id_map_.begin(); 64 window_to_app_shelf_id_map_.begin();
65 iter != window_to_app_shelf_id_map_.end(); 65 iter != window_to_app_shelf_id_map_.end();
66 ++iter) { 66 ++iter) {
67 iter->first->RemoveObserver(this); 67 iter->first->RemoveObserver(this);
68 } 68 }
69 } 69 }
70 70
71 void AppWindowLauncherController::AdditionalUserAddedToSession( 71 void AppWindowLauncherController::AdditionalUserAddedToSession(
72 Profile* profile) { 72 Profile* profile) {
73 // TODO(skuhne): This was added for the legacy side by side mode in M32. If 73 // TODO(skuhne): This was added for the legacy side by side mode in M32. If
74 // this mode gets no longer pursued this special case can be removed. 74 // this mode gets no longer pursued this special case can be removed.
75 if (chrome::MultiUserWindowManager::GetMultiProfileMode() != 75 if (chrome::MultiUserWindowManager::GetMultiProfileMode() !=
76 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_MIXED) 76 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_MIXED)
77 return; 77 return;
78 78
79 apps::AppWindowRegistry* registry = apps::AppWindowRegistry::Get(profile); 79 AppWindowRegistry* registry = AppWindowRegistry::Get(profile);
80 if (registry_.find(registry) != registry_.end()) 80 if (registry_.find(registry) != registry_.end())
81 return; 81 return;
82 82
83 registry->AddObserver(this); 83 registry->AddObserver(this);
84 registry_.insert(registry); 84 registry_.insert(registry);
85 } 85 }
86 86
87 void AppWindowLauncherController::OnAppWindowIconChanged( 87 void AppWindowLauncherController::OnAppWindowIconChanged(
88 AppWindow* app_window) { 88 AppWindow* app_window) {
89 if (!ControlsWindow(app_window->GetNativeWindow())) 89 if (!ControlsWindow(app_window->GetNativeWindow()))
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 WindowToAppShelfIdMap::iterator iter1 = 227 WindowToAppShelfIdMap::iterator iter1 =
228 window_to_app_shelf_id_map_.find(window); 228 window_to_app_shelf_id_map_.find(window);
229 if (iter1 == window_to_app_shelf_id_map_.end()) 229 if (iter1 == window_to_app_shelf_id_map_.end())
230 return NULL; 230 return NULL;
231 std::string app_shelf_id = iter1->second; 231 std::string app_shelf_id = iter1->second;
232 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id); 232 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id);
233 if (iter2 == app_controller_map_.end()) 233 if (iter2 == app_controller_map_.end())
234 return NULL; 234 return NULL;
235 return iter2->second; 235 return iter2->second;
236 } 236 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698