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 "ash/common/shelf/shelf_controller.h" | 5 #include "ash/common/shelf/shelf_controller.h" |
6 | 6 |
7 #include "ash/common/shelf/shelf_item_delegate.h" | 7 #include "ash/common/shelf/shelf_item_delegate.h" |
8 #include "ash/common/shelf/shelf_menu_model.h" | 8 #include "ash/common/shelf/shelf_menu_model.h" |
9 #include "ash/common/shelf/wm_shelf.h" | 9 #include "ash/common/shelf/wm_shelf.h" |
10 #include "ash/common/shell_delegate.h" | |
10 #include "ash/common/wm_lookup.h" | 11 #include "ash/common/wm_lookup.h" |
11 #include "ash/common/wm_root_window_controller.h" | 12 #include "ash/common/wm_root_window_controller.h" |
12 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
13 #include "ash/common/wm_window.h" | 14 #include "ash/common/wm_window.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "services/preferences/public/cpp/pref_observer_store.h" | |
17 #include "services/preferences/public/interfaces/preferences.mojom.h" | |
18 #include "services/service_manager/public/cpp/connector.h" | |
15 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/display/display.h" | 20 #include "ui/display/display.h" |
17 #include "ui/display/screen.h" | 21 #include "ui/display/screen.h" |
18 #include "ui/gfx/image/image_skia.h" | 22 #include "ui/gfx/image/image_skia.h" |
19 #include "ui/resources/grit/ui_resources.h" | 23 #include "ui/resources/grit/ui_resources.h" |
20 | 24 |
21 namespace ash { | 25 namespace ash { |
22 | 26 |
23 namespace { | 27 namespace { |
24 | 28 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 } | 165 } |
162 | 166 |
163 } // namespace | 167 } // namespace |
164 | 168 |
165 ShelfController::ShelfController() {} | 169 ShelfController::ShelfController() {} |
166 | 170 |
167 ShelfController::~ShelfController() {} | 171 ShelfController::~ShelfController() {} |
168 | 172 |
169 void ShelfController::BindRequest(mojom::ShelfControllerRequest request) { | 173 void ShelfController::BindRequest(mojom::ShelfControllerRequest request) { |
170 bindings_.AddBinding(this, std::move(request)); | 174 bindings_.AddBinding(this, std::move(request)); |
175 | |
176 // Sample of connecting to the PreferencesManager | |
177 WmShell* shell = WmShell::Get(); | |
178 service_manager::Connector* connector = | |
179 shell->delegate()->GetShellConnector(); | |
180 if (!connector) | |
181 return; | |
182 prefs::mojom::PreferencesManagerPtr pref_manager_ptr; | |
183 connector->ConnectToInterface("service:content_browser", &pref_manager_ptr); | |
184 store_ = new PrefObserverStore(std::move(pref_manager_ptr)); | |
185 std::set<std::string> keys; | |
186 const std::string key("hey"); | |
187 keys.insert(key); | |
188 store_->Init(keys); | |
jonross
2016/11/02 19:57:30
Once this is connected it can be used as a normal
| |
171 } | 189 } |
172 | 190 |
173 void ShelfController::NotifyShelfCreated(WmShelf* shelf) { | 191 void ShelfController::NotifyShelfCreated(WmShelf* shelf) { |
174 // Notify observers, Chrome will set alignment and auto-hide from prefs. | 192 // Notify observers, Chrome will set alignment and auto-hide from prefs. |
175 int64_t display_id = shelf->GetWindow()->GetDisplayNearestWindow().id(); | 193 int64_t display_id = shelf->GetWindow()->GetDisplayNearestWindow().id(); |
176 observers_.ForAllPtrs([display_id](mojom::ShelfObserver* observer) { | 194 observers_.ForAllPtrs([display_id](mojom::ShelfObserver* observer) { |
177 observer->OnShelfCreated(display_id); | 195 observer->OnShelfCreated(display_id); |
178 }); | 196 }); |
179 } | 197 } |
180 | 198 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 return; | 293 return; |
276 ShelfID shelf_id = app_id_to_shelf_id_[app_id]; | 294 ShelfID shelf_id = app_id_to_shelf_id_[app_id]; |
277 int index = model_.ItemIndexByID(shelf_id); | 295 int index = model_.ItemIndexByID(shelf_id); |
278 DCHECK_GE(index, 0); | 296 DCHECK_GE(index, 0); |
279 ShelfItem item = *model_.ItemByID(shelf_id); | 297 ShelfItem item = *model_.ItemByID(shelf_id); |
280 item.image = GetShelfIconFromBitmap(image); | 298 item.image = GetShelfIconFromBitmap(image); |
281 model_.Set(index, item); | 299 model_.Set(index, item); |
282 } | 300 } |
283 | 301 |
284 } // namespace ash | 302 } // namespace ash |
OLD | NEW |