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

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

Issue 2804623004: arc: Restore Chrome badging for apps that have peer in Android apps. (Closed)
Patch Set: minor updates Created 3 years, 8 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/common/shelf/shelf_delegate.h" 7 #include "ash/common/shelf/shelf_delegate.h"
8 #include "ash/common/wm_window.h" 8 #include "ash/common/wm_window.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/window_properties.h" 10 #include "ash/wm/window_properties.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 registry->AddObserver(this); 85 registry->AddObserver(this);
86 registry_.insert(registry); 86 registry_.insert(registry);
87 } 87 }
88 88
89 void ExtensionAppWindowLauncherController::OnAppWindowIconChanged( 89 void ExtensionAppWindowLauncherController::OnAppWindowIconChanged(
90 AppWindow* app_window) { 90 AppWindow* app_window) {
91 const std::string app_shelf_id = GetAppShelfId(app_window); 91 const std::string app_shelf_id = GetAppShelfId(app_window);
92 AppControllerMap::iterator iter = app_controller_map_.find(app_shelf_id); 92 AppControllerMap::iterator iter = app_controller_map_.find(app_shelf_id);
93 if (iter == app_controller_map_.end()) 93 if (iter == app_controller_map_.end())
94 return; 94 return;
95
96 // Check if the window actually overrides its default icon. Otherwise use app
97 // icon loader provided by owner.
98 if (!app_window->HasCustomIcon() || app_window->app_icon().IsEmpty())
99 return;
100
95 ExtensionAppWindowLauncherItemController* controller = iter->second; 101 ExtensionAppWindowLauncherItemController* controller = iter->second;
96 controller->set_image_set_by_controller(true); 102 controller->set_image_set_by_controller(true);
97 owner()->SetLauncherItemImage(controller->shelf_id(), 103 owner()->SetLauncherItemImage(controller->shelf_id(),
98 app_window->app_icon().AsImageSkia()); 104 app_window->app_icon().AsImageSkia());
99 } 105 }
100 106
101 void ExtensionAppWindowLauncherController::OnAppWindowShown( 107 void ExtensionAppWindowLauncherController::OnAppWindowShown(
102 AppWindow* app_window, 108 AppWindow* app_window,
103 bool was_hidden) { 109 bool was_hidden) {
104 aura::Window* window = app_window->GetNativeWindow(); 110 aura::Window* window = app_window->GetNativeWindow();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 controller->AddAppWindow(app_window); 181 controller->AddAppWindow(app_window);
176 // If there is already a shelf id mapped to this AppLaunchId (e.g. pinned), 182 // If there is already a shelf id mapped to this AppLaunchId (e.g. pinned),
177 // use that shelf item. 183 // use that shelf item.
178 shelf_id = 184 shelf_id =
179 ash::Shell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID( 185 ash::Shell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID(
180 app_id, launch_id); 186 app_id, launch_id);
181 187
182 if (shelf_id == 0) { 188 if (shelf_id == 0) {
183 shelf_id = owner()->CreateAppLauncherItem(std::move(controller), status); 189 shelf_id = owner()->CreateAppLauncherItem(std::move(controller), status);
184 // Restore any existing app icon and flag as set. 190 // Restore any existing app icon and flag as set.
185 const gfx::Image& app_icon = app_window->app_icon(); 191 if (app_window->HasCustomIcon() && !app_window->app_icon().IsEmpty()) {
186 if (!app_icon.IsEmpty()) { 192 owner()->SetLauncherItemImage(shelf_id,
187 owner()->SetLauncherItemImage(shelf_id, app_icon.AsImageSkia()); 193 app_window->app_icon().AsImageSkia());
188 item_controller->set_image_set_by_controller(true); 194 item_controller->set_image_set_by_controller(true);
189 } 195 }
190 } else { 196 } else {
191 owner()->SetShelfItemDelegate(shelf_id, std::move(controller)); 197 owner()->SetShelfItemDelegate(shelf_id, std::move(controller));
192 } 198 }
193 199
194 // We need to change the controller associated with app_shelf_id. 200 // We need to change the controller associated with app_shelf_id.
195 app_controller_map_[app_shelf_id] = item_controller; 201 app_controller_map_[app_shelf_id] = item_controller;
196 } 202 }
197 owner()->SetItemStatus(shelf_id, status); 203 owner()->SetItemStatus(shelf_id, status);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 WindowToAppShelfIdMap::iterator window_iter = 243 WindowToAppShelfIdMap::iterator window_iter =
238 window_to_app_shelf_id_map_.find(window); 244 window_to_app_shelf_id_map_.find(window);
239 if (window_iter == window_to_app_shelf_id_map_.end()) 245 if (window_iter == window_to_app_shelf_id_map_.end())
240 return nullptr; 246 return nullptr;
241 AppControllerMap::iterator app_controller_iter = 247 AppControllerMap::iterator app_controller_iter =
242 app_controller_map_.find(window_iter->second); 248 app_controller_map_.find(window_iter->second);
243 if (app_controller_iter == app_controller_map_.end()) 249 if (app_controller_iter == app_controller_map_.end())
244 return nullptr; 250 return nullptr;
245 return app_controller_iter->second; 251 return app_controller_iter->second;
246 } 252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698