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

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

Issue 2718563008: mash: Use mojo for ShelfItemDelegate and [app] MenuItem. (Closed)
Patch Set: Cleanup; fix ash_shell compile and a couple tests. Created 3 years, 9 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::ShelfItemDelegate {
James Cook 2017/03/09 01:09:47 drive-by: docs?
msw 2017/03/10 06:17:57 It's unused at the moment, and the wrong pattern f
19 public: 19 public:
20 explicit ChromeShelfItemDelegate(const std::string& app_id, 20 explicit ChromeShelfItemDelegate(const std::string& app_id,
James Cook 2017/03/09 01:09:47 drive-by: explicit not needed
msw 2017/03/10 06:17:57 Removed.
21 ChromeLauncherController* controller) 21 ChromeLauncherController* controller)
22 : app_id_(app_id), 22 : app_id_(app_id), controller_(controller) {}
23 item_delegate_binding_(this),
24 controller_(controller) {}
25 ~ChromeShelfItemDelegate() override {} 23 ~ChromeShelfItemDelegate() override {}
26 24
27 ash::mojom::ShelfItemDelegateAssociatedPtrInfo
28 CreateInterfacePtrInfoAndBind() {
29 DCHECK(!item_delegate_binding_.is_bound());
30 ash::mojom::ShelfItemDelegateAssociatedPtrInfo ptr_info;
31 item_delegate_binding_.Bind(&ptr_info);
32 return ptr_info;
33 }
34
35 private: 25 private:
36 // ash::mojom::ShelfItemDelegate: 26 // ash::ShelfItemDelegate:
37 void LaunchItem() override { 27 void ItemSelected(std::unique_ptr<ui::Event> event,
28 int64_t display_id,
29 ash::ShelfLaunchSource source,
30 const ItemSelectedCallback& callback) override {
38 controller_->LaunchApp(ash::AppLauncherId(app_id_), 31 controller_->LaunchApp(ash::AppLauncherId(app_id_),
39 ash::LAUNCH_FROM_UNKNOWN, ui::EF_NONE); 32 ash::LAUNCH_FROM_UNKNOWN, ui::EF_NONE);
33 callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, MenuItemList());
James Cook 2017/03/09 01:09:47 Does this actually create a new window for all ite
msw 2017/03/10 06:17:57 Unused; removed.
40 } 34 }
41 void ExecuteCommand(uint32_t command_id, int event_flags) override { 35 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override {
42 NOTIMPLEMENTED(); 36 NOTIMPLEMENTED();
43 } 37 }
44 void ItemPinned() override { NOTIMPLEMENTED(); } 38 void Close() override { NOTIMPLEMENTED(); }
45 void ItemUnpinned() override { NOTIMPLEMENTED(); }
46 void ItemReordered(uint32_t order) override { NOTIMPLEMENTED(); }
47 39
48 std::string app_id_; 40 std::string app_id_;
49 mojo::AssociatedBinding<ash::mojom::ShelfItemDelegate> item_delegate_binding_;
50 41
51 // Not owned. 42 // Not owned.
52 ChromeLauncherController* controller_; 43 ChromeLauncherController* controller_;
53 44
54 DISALLOW_COPY_AND_ASSIGN(ChromeShelfItemDelegate); 45 DISALLOW_COPY_AND_ASSIGN(ChromeShelfItemDelegate);
55 }; 46 };
56 47
57 ChromeLauncherControllerMus::ChromeLauncherControllerMus() { 48 ChromeLauncherControllerMus::ChromeLauncherControllerMus() {
58 AttachProfile(ProfileManager::GetActiveUserProfile()); 49 AttachProfile(ProfileManager::GetActiveUserProfile());
59 } 50 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void ChromeLauncherControllerMus::ActiveUserChanged( 166 void ChromeLauncherControllerMus::ActiveUserChanged(
176 const std::string& user_email) { 167 const std::string& user_email) {
177 NOTIMPLEMENTED(); 168 NOTIMPLEMENTED();
178 } 169 }
179 170
180 void ChromeLauncherControllerMus::AdditionalUserAddedToSession( 171 void ChromeLauncherControllerMus::AdditionalUserAddedToSession(
181 Profile* profile) { 172 Profile* profile) {
182 NOTIMPLEMENTED(); 173 NOTIMPLEMENTED();
183 } 174 }
184 175
185 ash::ShelfAppMenuItemList 176 ash::ShelfItemDelegate::MenuItemList
186 ChromeLauncherControllerMus::GetAppMenuItemsForTesting( 177 ChromeLauncherControllerMus::GetAppMenuItemsForTesting(
187 const ash::ShelfItem& item) { 178 const ash::ShelfItem& item) {
188 NOTIMPLEMENTED(); 179 NOTIMPLEMENTED();
189 return ash::ShelfAppMenuItemList(); 180 return ash::ShelfItemDelegate::MenuItemList();
190 } 181 }
191 182
192 std::vector<content::WebContents*> 183 std::vector<content::WebContents*>
193 ChromeLauncherControllerMus::GetV1ApplicationsFromAppId( 184 ChromeLauncherControllerMus::GetV1ApplicationsFromAppId(
194 const std::string& app_id) { 185 const std::string& app_id) {
195 NOTIMPLEMENTED(); 186 NOTIMPLEMENTED();
196 return std::vector<content::WebContents*>(); 187 return std::vector<content::WebContents*>();
197 } 188 }
198 189
199 void ChromeLauncherControllerMus::ActivateShellApp(const std::string& app_id, 190 void ChromeLauncherControllerMus::ActivateShellApp(const std::string& app_id,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if (app_launcher_id.app_id() == ash::launcher::kPinnedAppsPlaceholder) 274 if (app_launcher_id.app_id() == ash::launcher::kPinnedAppsPlaceholder)
284 continue; 275 continue;
285 276
286 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New()); 277 ash::mojom::ShelfItemPtr item(ash::mojom::ShelfItem::New());
287 item->app_id = app_id; 278 item->app_id = app_id;
288 item->app_title = base::UTF16ToUTF8( 279 item->app_title = base::UTF16ToUTF8(
289 launcher_controller_helper()->GetAppTitle(profile(), app_id)); 280 launcher_controller_helper()->GetAppTitle(profile(), app_id));
290 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 281 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
291 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON); 282 const gfx::Image& image = rb.GetImageNamed(IDR_APP_DEFAULT_ICON);
292 item->image = *image.ToSkBitmap(); 283 item->image = *image.ToSkBitmap();
284 // TOOD(msw): Actually pin the item and install its delegate; this code is
285 // unused at the moment. See http://crbug.com/647879
293 std::unique_ptr<ChromeShelfItemDelegate> delegate( 286 std::unique_ptr<ChromeShelfItemDelegate> delegate(
294 new ChromeShelfItemDelegate(app_id, this)); 287 new ChromeShelfItemDelegate(app_id, this));
295 shelf_controller()->PinItem(std::move(item),
296 delegate->CreateInterfacePtrInfoAndBind());
297 app_id_to_item_delegate_.insert( 288 app_id_to_item_delegate_.insert(
298 std::make_pair(app_id, std::move(delegate))); 289 std::make_pair(app_id, std::move(delegate)));
299 290
300 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); 291 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
301 if (app_icon_loader) { 292 if (app_icon_loader) {
302 app_icon_loader->FetchImage(app_id); 293 app_icon_loader->FetchImage(app_id);
303 app_icon_loader->UpdateImage(app_id); 294 app_icon_loader->UpdateImage(app_id);
304 } 295 }
305 } 296 }
306 } 297 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698