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

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

Issue 2052013002: Adding ChromeLauncherController interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome_launcher_smaller_api
Patch Set: Fix method order Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/extension_app_window_launcher_controlle r.h" 5 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_controlle r.h"
6 6
7 #include "ash/shelf/shelf_delegate.h"
7 #include "ash/shelf/shelf_util.h" 8 #include "ash/shelf/shelf_util.h"
8 #include "ash/shell.h" 9 #include "ash/shell.h"
9 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_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/extension_app_window_launcher_item_cont roller.h" 14 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont roller.h"
14 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 15 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
15 #include "extensions/browser/app_window/app_window.h" 16 #include "extensions/browser/app_window/app_window.h"
16 #include "extensions/browser/app_window/native_app_window.h" 17 #include "extensions/browser/app_window/native_app_window.h"
17 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.h"
18 #include "ui/aura/window_event_dispatcher.h" 19 #include "ui/aura/window_event_dispatcher.h"
19 20
20 using extensions::AppWindow; 21 using extensions::AppWindow;
21 using extensions::AppWindowRegistry; 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 } // namespace 32 } // namespace
32 33
33 ExtensionAppWindowLauncherController::ExtensionAppWindowLauncherController( 34 ExtensionAppWindowLauncherController::ExtensionAppWindowLauncherController(
34 ChromeLauncherController* owner) 35 ChromeLauncherController* owner)
35 : AppWindowLauncherController(owner) { 36 : AppWindowLauncherController(owner) {
36 AppWindowRegistry* registry = AppWindowRegistry::Get(owner->profile()); 37 AppWindowRegistry* registry = AppWindowRegistry::Get(owner->GetProfile());
37 registry_.insert(registry); 38 registry_.insert(registry);
38 registry->AddObserver(this); 39 registry->AddObserver(this);
39 } 40 }
40 41
41 ExtensionAppWindowLauncherController::~ExtensionAppWindowLauncherController() { 42 ExtensionAppWindowLauncherController::~ExtensionAppWindowLauncherController() {
42 for (std::set<AppWindowRegistry*>::iterator it = registry_.begin(); 43 for (std::set<AppWindowRegistry*>::iterator it = registry_.begin();
43 it != registry_.end(); ++it) 44 it != registry_.end(); ++it)
44 (*it)->RemoveObserver(this); 45 (*it)->RemoveObserver(this);
45 46
46 for (WindowToAppShelfIdMap::iterator iter = 47 for (WindowToAppShelfIdMap::iterator iter =
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 LauncherItemController::Type type = 132 LauncherItemController::Type type =
132 app_window->window_type_is_panel() 133 app_window->window_type_is_panel()
133 ? LauncherItemController::TYPE_APP_PANEL 134 ? LauncherItemController::TYPE_APP_PANEL
134 : LauncherItemController::TYPE_APP; 135 : LauncherItemController::TYPE_APP;
135 ExtensionAppWindowLauncherItemController* controller = 136 ExtensionAppWindowLauncherItemController* controller =
136 new ExtensionAppWindowLauncherItemController(type, app_shelf_id, app_id, 137 new ExtensionAppWindowLauncherItemController(type, app_shelf_id, app_id,
137 owner()); 138 owner());
138 controller->AddAppWindow(app_window); 139 controller->AddAppWindow(app_window);
139 // If the app shelf id is not unique, and there is already a shelf 140 // If the app shelf id is not unique, and there is already a shelf
140 // item for this app id (e.g. pinned), use that shelf item. 141 // item for this app id (e.g. pinned), use that shelf item.
141 if (app_shelf_id == app_id) 142 if (app_shelf_id == app_id)
msw 2016/06/10 22:44:39 nit: curly braces
mfomitchev 2016/06/13 17:29:18 Done.
142 shelf_id = owner()->GetShelfIDForAppID(app_id); 143 shelf_id =
144 ash::Shell::GetInstance()->GetShelfDelegate()->GetShelfIDForAppID(
145 app_id);
143 if (shelf_id == 0) { 146 if (shelf_id == 0) {
144 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, status); 147 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, status);
145 // Restore any existing app icon and flag as set. 148 // Restore any existing app icon and flag as set.
146 const gfx::Image& app_icon = app_window->app_icon(); 149 const gfx::Image& app_icon = app_window->app_icon();
147 if (!app_icon.IsEmpty()) { 150 if (!app_icon.IsEmpty()) {
148 owner()->SetLauncherItemImage(shelf_id, app_icon.AsImageSkia()); 151 owner()->SetLauncherItemImage(shelf_id, app_icon.AsImageSkia());
149 controller->set_image_set_by_controller(true); 152 controller->set_image_set_by_controller(true);
150 } 153 }
151 } else { 154 } else {
152 owner()->SetItemController(shelf_id, controller); 155 owner()->SetItemController(shelf_id, controller);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 WindowToAppShelfIdMap::iterator iter1 = 196 WindowToAppShelfIdMap::iterator iter1 =
194 window_to_app_shelf_id_map_.find(window); 197 window_to_app_shelf_id_map_.find(window);
195 if (iter1 == window_to_app_shelf_id_map_.end()) 198 if (iter1 == window_to_app_shelf_id_map_.end())
196 return nullptr; 199 return nullptr;
197 std::string app_shelf_id = iter1->second; 200 std::string app_shelf_id = iter1->second;
198 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id); 201 AppControllerMap::iterator iter2 = app_controller_map_.find(app_shelf_id);
199 if (iter2 == app_controller_map_.end()) 202 if (iter2 == app_controller_map_.end())
200 return nullptr; 203 return nullptr;
201 return iter2->second; 204 return iter2->second;
202 } 205 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698