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

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

Issue 2696233002: Mojo C++ bindings: remove some usage of AssociatedGroup from user code. (Closed)
Patch Set: . Created 3 years, 10 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/chrome_launcher_controller_mus.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
11 #include "chrome/browser/ui/ash/app_launcher_id.h" 11 #include "chrome/browser/ui/ash/app_launcher_id.h"
12 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 12 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
13 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" 13 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
14 #include "extensions/grit/extensions_browser_resources.h" 14 #include "extensions/grit/extensions_browser_resources.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/events/event_constants.h" 16 #include "ui/events/event_constants.h"
17 17
18 class ChromeShelfItemDelegate : public ash::mojom::ShelfItemDelegate { 18 class ChromeShelfItemDelegate : public ash::mojom::ShelfItemDelegate {
19 public: 19 public:
20 explicit ChromeShelfItemDelegate(const std::string& app_id, 20 explicit ChromeShelfItemDelegate(const std::string& app_id,
21 ChromeLauncherController* controller) 21 ChromeLauncherController* controller)
22 : app_id_(app_id), 22 : app_id_(app_id),
23 item_delegate_binding_(this), 23 item_delegate_binding_(this),
24 controller_(controller) {} 24 controller_(controller) {}
25 ~ChromeShelfItemDelegate() override {} 25 ~ChromeShelfItemDelegate() override {}
26 26
27 ash::mojom::ShelfItemDelegateAssociatedPtrInfo CreateInterfacePtrInfoAndBind( 27 ash::mojom::ShelfItemDelegateAssociatedPtrInfo
28 mojo::AssociatedGroup* associated_group) { 28 CreateInterfacePtrInfoAndBind() {
29 DCHECK(!item_delegate_binding_.is_bound()); 29 DCHECK(!item_delegate_binding_.is_bound());
30 ash::mojom::ShelfItemDelegateAssociatedPtrInfo ptr_info; 30 ash::mojom::ShelfItemDelegateAssociatedPtrInfo ptr_info;
31 item_delegate_binding_.Bind(&ptr_info, associated_group); 31 item_delegate_binding_.Bind(&ptr_info);
32 return ptr_info; 32 return ptr_info;
33 } 33 }
34 34
35 private: 35 private:
36 // ash::mojom::ShelfItemDelegate: 36 // ash::mojom::ShelfItemDelegate:
37 void LaunchItem() override { 37 void LaunchItem() override {
38 controller_->LaunchApp(ash::AppLauncherId(app_id_), 38 controller_->LaunchApp(ash::AppLauncherId(app_id_),
39 ash::LAUNCH_FROM_UNKNOWN, ui::EF_NONE); 39 ash::LAUNCH_FROM_UNKNOWN, ui::EF_NONE);
40 } 40 }
41 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override { 41 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); 287 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New());
288 item->app_id = app_id; 288 item->app_id = app_id;
289 item->app_title = base::UTF16ToUTF8( 289 item->app_title = base::UTF16ToUTF8(
290 launcher_controller_helper()->GetAppTitle(profile(), app_id)); 290 launcher_controller_helper()->GetAppTitle(profile(), app_id));
291 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 291 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
292 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); 292 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON);
293 item->image = *image.ToSkBitmap(); 293 item->image = *image.ToSkBitmap();
294 std::unique_ptr<ChromeShelfItemDelegate> delegate( 294 std::unique_ptr<ChromeShelfItemDelegate> delegate(
295 new ChromeShelfItemDelegate(app_id, this)); 295 new ChromeShelfItemDelegate(app_id, this));
296 shelf_controller()->PinItem(std::move(item), 296 shelf_controller()->PinItem(std::move(item),
297 delegate->CreateInterfacePtrInfoAndBind( 297 delegate->CreateInterfacePtrInfoAndBind());
298 shelf_controller().associated_group()));
299 app_id_to_item_delegate_.insert( 298 app_id_to_item_delegate_.insert(
300 std::make_pair(app_id, std::move(delegate))); 299 std::make_pair(app_id, std::move(delegate)));
301 300
302 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); 301 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
303 if (app_icon_loader) { 302 if (app_icon_loader) {
304 app_icon_loader->FetchImage(app_id); 303 app_icon_loader->FetchImage(app_id);
305 app_icon_loader->UpdateImage(app_id); 304 app_icon_loader->UpdateImage(app_id);
306 } 305 }
307 } 306 }
308 } 307 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc ('k') | chrome/browser/ui/ash/media_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698