OLD | NEW |
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/chrome_mash_shelf_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_app_icon_loader.h" | 7 #include "chrome/browser/extensions/extension_app_icon_loader.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h" | 9 #include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h" |
10 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 10 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" | 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" |
12 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 12 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
13 #include "chrome/grit/theme_resources.h" | 13 #include "chrome/grit/theme_resources.h" |
14 #include "content/public/common/mojo_shell_connection.h" | 14 #include "content/public/common/mojo_shell_connection.h" |
15 #include "extensions/common/constants.h" | 15 #include "extensions/common/constants.h" |
16 #include "extensions/grit/extensions_browser_resources.h" | 16 #include "extensions/grit/extensions_browser_resources.h" |
17 #include "mojo/common/common_type_converters.h" | 17 #include "mojo/common/common_type_converters.h" |
18 #include "services/shell/public/cpp/connector.h" | 18 #include "services/shell/public/cpp/connector.h" |
19 #include "skia/public/type_converters.h" | |
20 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/display/display.h" | 20 #include "ui/display/display.h" |
22 #include "ui/display/screen.h" | 21 #include "ui/display/screen.h" |
23 | 22 |
24 class ChromeShelfItemDelegate : public mash::shelf::mojom::ShelfItemDelegate { | 23 class ChromeShelfItemDelegate : public mash::shelf::mojom::ShelfItemDelegate { |
25 public: | 24 public: |
26 explicit ChromeShelfItemDelegate(const std::string& app_id) | 25 explicit ChromeShelfItemDelegate(const std::string& app_id) |
27 : app_id_(app_id), item_delegate_binding_(this) {} | 26 : app_id_(app_id), item_delegate_binding_(this) {} |
28 ~ChromeShelfItemDelegate() override {} | 27 ~ChromeShelfItemDelegate() override {} |
29 | 28 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 117 |
119 for (const auto& app : pinned_apps) { | 118 for (const auto& app : pinned_apps) { |
120 if (app == ash::kPinnedAppsPlaceholder) | 119 if (app == ash::kPinnedAppsPlaceholder) |
121 continue; | 120 continue; |
122 | 121 |
123 mash::shelf::mojom::ShelfItemPtr item(mash::shelf::mojom::ShelfItem::New()); | 122 mash::shelf::mojom::ShelfItemPtr item(mash::shelf::mojom::ShelfItem::New()); |
124 item->app_id = app; | 123 item->app_id = app; |
125 item->app_title = mojo::String::From(helper_.GetAppTitle(profile, app)); | 124 item->app_title = mojo::String::From(helper_.GetAppTitle(profile, app)); |
126 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 125 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
127 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); | 126 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); |
128 item->image = skia::mojom::Bitmap::From(*image.ToSkBitmap()); | 127 item->image = *image.ToSkBitmap(); |
129 std::unique_ptr<ChromeShelfItemDelegate> delegate( | 128 std::unique_ptr<ChromeShelfItemDelegate> delegate( |
130 new ChromeShelfItemDelegate(app)); | 129 new ChromeShelfItemDelegate(app)); |
131 shelf_controller_->PinItem(std::move(item), | 130 shelf_controller_->PinItem(std::move(item), |
132 delegate->CreateInterfacePtrInfoAndBind( | 131 delegate->CreateInterfacePtrInfoAndBind( |
133 shelf_controller_.associated_group())); | 132 shelf_controller_.associated_group())); |
134 app_id_to_item_delegate_.insert(std::make_pair(app, std::move(delegate))); | 133 app_id_to_item_delegate_.insert(std::make_pair(app, std::move(delegate))); |
135 | 134 |
136 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app); | 135 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app); |
137 if (app_icon_loader) { | 136 if (app_icon_loader) { |
138 app_icon_loader->FetchImage(app); | 137 app_icon_loader->FetchImage(app); |
(...skipping 23 matching lines...) Expand all Loading... |
162 void ChromeMashShelfController::OnAutoHideBehaviorChanged( | 161 void ChromeMashShelfController::OnAutoHideBehaviorChanged( |
163 mash::shelf::mojom::AutoHideBehavior auto_hide) { | 162 mash::shelf::mojom::AutoHideBehavior auto_hide) { |
164 ash::SetShelfAutoHideBehaviorPref( | 163 ash::SetShelfAutoHideBehaviorPref( |
165 ProfileManager::GetActiveUserProfile()->GetPrefs(), | 164 ProfileManager::GetActiveUserProfile()->GetPrefs(), |
166 display::Screen::GetScreen()->GetPrimaryDisplay().id(), | 165 display::Screen::GetScreen()->GetPrimaryDisplay().id(), |
167 static_cast<ash::ShelfAutoHideBehavior>(auto_hide)); | 166 static_cast<ash::ShelfAutoHideBehavior>(auto_hide)); |
168 } | 167 } |
169 | 168 |
170 void ChromeMashShelfController::OnAppImageUpdated(const std::string& app_id, | 169 void ChromeMashShelfController::OnAppImageUpdated(const std::string& app_id, |
171 const gfx::ImageSkia& image) { | 170 const gfx::ImageSkia& image) { |
172 shelf_controller_->SetItemImage(app_id, | 171 shelf_controller_->SetItemImage(app_id, *image.bitmap()); |
173 skia::mojom::Bitmap::From(*image.bitmap())); | |
174 } | 172 } |
OLD | NEW |