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: ash/mus/shelf_delegate_mus.cc

Issue 2014013002: Add SkBitmap StructTraits for skia::mojo::Bitmap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add mojo/public/cpp/bindings typemap deps. Created 4 years, 7 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 "ash/mus/shelf_delegate_mus.h" 5 #include "ash/mus/shelf_delegate_mus.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/shelf/shelf.h" 9 #include "ash/shelf/shelf.h"
10 #include "ash/shelf/shelf_item_delegate.h" 10 #include "ash/shelf/shelf_item_delegate.h"
11 #include "ash/shelf/shelf_item_delegate_manager.h" 11 #include "ash/shelf/shelf_item_delegate_manager.h"
12 #include "ash/shelf/shelf_layout_manager.h" 12 #include "ash/shelf/shelf_layout_manager.h"
13 #include "ash/shelf/shelf_menu_model.h" 13 #include "ash/shelf/shelf_menu_model.h"
14 #include "ash/shelf/shelf_model.h" 14 #include "ash/shelf/shelf_model.h"
15 #include "ash/shelf/shelf_types.h" 15 #include "ash/shelf/shelf_types.h"
16 #include "ash/shelf/shelf_widget.h" 16 #include "ash/shelf/shelf_widget.h"
17 #include "ash/shell.h" 17 #include "ash/shell.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "components/mus/public/cpp/property_type_converters.h" 19 #include "components/mus/public/cpp/property_type_converters.h"
20 #include "components/mus/public/cpp/window.h" 20 #include "components/mus/public/cpp/window.h"
21 #include "components/mus/public/cpp/window_property.h" 21 #include "components/mus/public/cpp/window_property.h"
22 #include "mojo/common/common_type_converters.h" 22 #include "mojo/common/common_type_converters.h"
23 #include "services/shell/public/cpp/connector.h" 23 #include "services/shell/public/cpp/connector.h"
24 #include "skia/public/type_converters.h"
25 #include "ui/aura/mus/mus_util.h" 24 #include "ui/aura/mus/mus_util.h"
26 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/gfx/image/image_skia.h" 26 #include "ui/gfx/image/image_skia.h"
28 #include "ui/resources/grit/ui_resources.h" 27 #include "ui/resources/grit/ui_resources.h"
29 #include "ui/views/mus/window_manager_connection.h" 28 #include "ui/views/mus/window_manager_connection.h"
30 29
31 using mash::wm::mojom::UserWindowController; 30 using mash::wm::mojom::UserWindowController;
32 31
33 namespace ash { 32 namespace ash {
34 namespace sysui { 33 namespace sysui {
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return; 291 return;
293 } 292 }
294 293
295 ShelfID shelf_id = model_->next_id(); 294 ShelfID shelf_id = model_->next_id();
296 app_id_to_shelf_id_.insert(std::make_pair(app_id, shelf_id)); 295 app_id_to_shelf_id_.insert(std::make_pair(app_id, shelf_id));
297 shelf_id_to_app_id_.insert(std::make_pair(shelf_id, app_id)); 296 shelf_id_to_app_id_.insert(std::make_pair(shelf_id, app_id));
298 297
299 ShelfItem shelf_item; 298 ShelfItem shelf_item;
300 shelf_item.type = TYPE_APP_SHORTCUT; 299 shelf_item.type = TYPE_APP_SHORTCUT;
301 shelf_item.status = STATUS_CLOSED; 300 shelf_item.status = STATUS_CLOSED;
302 shelf_item.image = GetShelfIconFromBitmap(item->image.To<SkBitmap>()); 301 shelf_item.image = GetShelfIconFromBitmap(item->image);
303 model_->Add(shelf_item); 302 model_->Add(shelf_item);
304 303
305 std::unique_ptr<ShelfItemDelegateMus> item_delegate( 304 std::unique_ptr<ShelfItemDelegateMus> item_delegate(
306 new ShelfItemDelegateMus(user_window_controller_.get())); 305 new ShelfItemDelegateMus(user_window_controller_.get()));
307 item_delegate->SetDelegate(std::move(delegate)); 306 item_delegate->SetDelegate(std::move(delegate));
308 item_delegate->set_pinned(true); 307 item_delegate->set_pinned(true);
309 item_delegate->set_title(item->app_title.To<base::string16>()); 308 item_delegate->set_title(item->app_title.To<base::string16>());
310 Shell::GetInstance()->shelf_item_delegate_manager()->SetShelfItemDelegate( 309 Shell::GetInstance()->shelf_item_delegate_manager()->SetShelfItemDelegate(
311 shelf_id, std::move(item_delegate)); 310 shelf_id, std::move(item_delegate));
312 } 311 }
313 312
314 void ShelfDelegateMus::UnpinItem(const mojo::String& app_id) { 313 void ShelfDelegateMus::UnpinItem(const mojo::String& app_id) {
315 if (!app_id_to_shelf_id_.count(app_id.To<std::string>())) 314 if (!app_id_to_shelf_id_.count(app_id.To<std::string>()))
316 return; 315 return;
317 ShelfID shelf_id = app_id_to_shelf_id_[app_id.To<std::string>()]; 316 ShelfID shelf_id = app_id_to_shelf_id_[app_id.To<std::string>()];
318 ShelfItemDelegateMus* item_delegate = GetShelfItemDelegate(shelf_id); 317 ShelfItemDelegateMus* item_delegate = GetShelfItemDelegate(shelf_id);
319 DCHECK(item_delegate->pinned()); 318 DCHECK(item_delegate->pinned());
320 item_delegate->set_pinned(false); 319 item_delegate->set_pinned(false);
321 if (item_delegate->window_id_to_title().empty()) { 320 if (item_delegate->window_id_to_title().empty()) {
322 model_->RemoveItemAt(model_->ItemIndexByID(shelf_id)); 321 model_->RemoveItemAt(model_->ItemIndexByID(shelf_id));
323 app_id_to_shelf_id_.erase(app_id.To<std::string>()); 322 app_id_to_shelf_id_.erase(app_id.To<std::string>());
324 shelf_id_to_app_id_.erase(shelf_id); 323 shelf_id_to_app_id_.erase(shelf_id);
325 } 324 }
326 } 325 }
327 326
328 void ShelfDelegateMus::SetItemImage(const mojo::String& app_id, 327 void ShelfDelegateMus::SetItemImage(const mojo::String& app_id,
329 skia::mojom::BitmapPtr image) { 328 const SkBitmap& image) {
330 if (!app_id_to_shelf_id_.count(app_id.To<std::string>())) 329 if (!app_id_to_shelf_id_.count(app_id.To<std::string>()))
331 return; 330 return;
332 ShelfID shelf_id = app_id_to_shelf_id_[app_id.To<std::string>()]; 331 ShelfID shelf_id = app_id_to_shelf_id_[app_id.To<std::string>()];
333 int index = model_->ItemIndexByID(shelf_id); 332 int index = model_->ItemIndexByID(shelf_id);
334 DCHECK_GE(index, 0); 333 DCHECK_GE(index, 0);
335 ShelfItem item = *model_->ItemByID(shelf_id); 334 ShelfItem item = *model_->ItemByID(shelf_id);
336 item.image = GetShelfIconFromBitmap(image.To<SkBitmap>()); 335 item.image = GetShelfIconFromBitmap(image);
337 model_->Set(index, item); 336 model_->Set(index, item);
338 } 337 }
339 338
340 void ShelfDelegateMus::OnUserWindowObserverAdded( 339 void ShelfDelegateMus::OnUserWindowObserverAdded(
341 mojo::Array<mash::wm::mojom::UserWindowPtr> user_windows) { 340 mojo::Array<mash::wm::mojom::UserWindowPtr> user_windows) {
342 for (size_t i = 0; i < user_windows.size(); ++i) 341 for (size_t i = 0; i < user_windows.size(); ++i)
343 OnUserWindowAdded(std::move(user_windows[i])); 342 OnUserWindowAdded(std::move(user_windows[i]));
344 } 343 }
345 344
346 void ShelfDelegateMus::OnUserWindowAdded( 345 void ShelfDelegateMus::OnUserWindowAdded(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 StatusAreaWidget* status_widget = widget->status_area_widget(); 457 StatusAreaWidget* status_widget = widget->status_area_widget();
459 mus::Window* status_window = 458 mus::Window* status_window =
460 aura::GetMusWindow(status_widget->GetNativeWindow()); 459 aura::GetMusWindow(status_widget->GetNativeWindow());
461 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); 460 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size();
462 status_window->SetSharedProperty<gfx::Size>( 461 status_window->SetSharedProperty<gfx::Size>(
463 mus::mojom::WindowManager::kPreferredSize_Property, status_size); 462 mus::mojom::WindowManager::kPreferredSize_Property, status_size);
464 } 463 }
465 464
466 } // namespace sysui 465 } // namespace sysui
467 } // namespace ash 466 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698