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

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

Issue 1899323002: Add mash shelf application id support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address simpler comments. Created 4 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
« no previous file with comments | « ash/mus/sysui_application.cc ('k') | components/mus/public/cpp/window_property.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_mash_shelf_controller.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.h"
6 6
7 #include "chrome/browser/profiles/profile_manager.h" 7 #include "chrome/browser/profiles/profile_manager.h"
8 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 8 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
9 #include "chrome/grit/theme_resources.h" 9 #include "chrome/grit/theme_resources.h"
10 #include "content/public/common/mojo_shell_connection.h" 10 #include "content/public/common/mojo_shell_connection.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 int64_t display_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 67 int64_t display_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id();
68 shelf_controller_->SetAlignment(static_cast<mash::shelf::mojom::Alignment>( 68 shelf_controller_->SetAlignment(static_cast<mash::shelf::mojom::Alignment>(
69 ash::GetShelfAlignmentPref(profile->GetPrefs(), display_id))); 69 ash::GetShelfAlignmentPref(profile->GetPrefs(), display_id)));
70 shelf_controller_->SetAutoHideBehavior( 70 shelf_controller_->SetAutoHideBehavior(
71 static_cast<mash::shelf::mojom::AutoHideBehavior>( 71 static_cast<mash::shelf::mojom::AutoHideBehavior>(
72 ash::GetShelfAutoHideBehaviorPref(profile->GetPrefs(), display_id))); 72 ash::GetShelfAutoHideBehaviorPref(profile->GetPrefs(), display_id)));
73 73
74 // Create a test shortcut item to a fake application. 74 // Create a test shortcut item to a fake application.
75 mash::shelf::mojom::ShelfItemPtr item(mash::shelf::mojom::ShelfItem::New()); 75 mash::shelf::mojom::ShelfItemPtr item(mash::shelf::mojom::ShelfItem::New());
76 std::string item_id("mojo:fake_app"); 76 std::string item_id("mojo:fake_app");
77 item->id = item_id; 77 item->app_id = item_id;
78 item->title = "Fake Mojo App (test pinned shelf item)"; 78 item->app_title = "Fake Mojo App (test pinned shelf item)";
79 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 79 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
80 const gfx::Image& image = rb.GetImageNamed(IDR_PRODUCT_LOGO_32); 80 const gfx::Image& image = rb.GetImageNamed(IDR_PRODUCT_LOGO_32);
81 item->image = skia::mojom::Bitmap::From(*image.ToSkBitmap()); 81 item->image = skia::mojom::Bitmap::From(*image.ToSkBitmap());
82 std::unique_ptr<ChromeShelfItemDelegate> delegate( 82 std::unique_ptr<ChromeShelfItemDelegate> delegate(
83 new ChromeShelfItemDelegate()); 83 new ChromeShelfItemDelegate());
84 shelf_controller_->AddItem(std::move(item), 84 shelf_controller_->PinItem(std::move(item),
85 delegate->CreateInterfacePtrInfoAndBind( 85 delegate->CreateInterfacePtrInfoAndBind(
86 shelf_controller_.associated_group())); 86 shelf_controller_.associated_group()));
87 app_id_to_item_delegate_.insert(std::make_pair(item_id, std::move(delegate))); 87 app_id_to_item_delegate_.insert(std::make_pair(item_id, std::move(delegate)));
88 88
89 // Start observing the shelf now that it has been initialized. 89 // Start observing the shelf now that it has been initialized.
90 mash::shelf::mojom::ShelfObserverAssociatedPtrInfo ptr_info; 90 mash::shelf::mojom::ShelfObserverAssociatedPtrInfo ptr_info;
91 observer_binding_.Bind(&ptr_info, shelf_controller_.associated_group()); 91 observer_binding_.Bind(&ptr_info, shelf_controller_.associated_group());
92 shelf_controller_->AddObserver(std::move(ptr_info)); 92 shelf_controller_->AddObserver(std::move(ptr_info));
93 } 93 }
94 94
95 void ChromeMashShelfController::OnAlignmentChanged( 95 void ChromeMashShelfController::OnAlignmentChanged(
96 mash::shelf::mojom::Alignment alignment) { 96 mash::shelf::mojom::Alignment alignment) {
97 ash::SetShelfAlignmentPref(ProfileManager::GetActiveUserProfile()->GetPrefs(), 97 ash::SetShelfAlignmentPref(ProfileManager::GetActiveUserProfile()->GetPrefs(),
98 gfx::Screen::GetScreen()->GetPrimaryDisplay().id(), 98 gfx::Screen::GetScreen()->GetPrimaryDisplay().id(),
99 static_cast<ash::ShelfAlignment>(alignment)); 99 static_cast<ash::ShelfAlignment>(alignment));
100 } 100 }
101 101
102 void ChromeMashShelfController::OnAutoHideBehaviorChanged( 102 void ChromeMashShelfController::OnAutoHideBehaviorChanged(
103 mash::shelf::mojom::AutoHideBehavior auto_hide) { 103 mash::shelf::mojom::AutoHideBehavior auto_hide) {
104 ash::SetShelfAutoHideBehaviorPref( 104 ash::SetShelfAutoHideBehaviorPref(
105 ProfileManager::GetActiveUserProfile()->GetPrefs(), 105 ProfileManager::GetActiveUserProfile()->GetPrefs(),
106 gfx::Screen::GetScreen()->GetPrimaryDisplay().id(), 106 gfx::Screen::GetScreen()->GetPrimaryDisplay().id(),
107 static_cast<ash::ShelfAutoHideBehavior>(auto_hide)); 107 static_cast<ash::ShelfAutoHideBehavior>(auto_hide));
108 } 108 }
OLDNEW
« no previous file with comments | « ash/mus/sysui_application.cc ('k') | components/mus/public/cpp/window_property.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698