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/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 Loading... |
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 } |
OLD | NEW |