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

Side by Side Diff: chrome/browser/ui/ash/property_util.cc

Issue 2381183002: mash: Fix shelf window property use in Chrome. (Closed)
Patch Set: Sync and rebase; add comments. Created 4 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/ash/property_util.h"
6
7 #include "ash/wm/window_properties.h"
8 #include "services/ui/public/cpp/window.h"
9 #include "services/ui/public/interfaces/window_manager.mojom.h"
10 #include "ui/aura/mus/mus_util.h"
11
12 namespace {
13
14 // Get the corresponding ui::Window property key for an aura::Window key.
15 template <typename T>
16 const char* GetMusProperty(const aura::WindowProperty<T>* aura_key) {
17 if (aura_key == ash::kShelfIconResourceIdKey)
18 return ui::mojom::WindowManager::kShelfIconResourceId_Property;
19 if (aura_key == ash::kShelfItemTypeKey)
20 return ui::mojom::WindowManager::kShelfItemType_Property;
21 NOTREACHED();
22 return nullptr;
23 }
24
25 } // namespace
26
27 void SetIntProperty(aura::Window* window,
28 const aura::WindowProperty<int>* property,
29 int value) {
30 ui::Window* ui_window = aura::GetMusWindow(window);
James Cook 2016/10/01 00:16:21 nit: DCHECK(window)?
msw 2016/10/03 19:14:23 Done.
31 if (ui_window)
James Cook 2016/10/01 00:16:21 I think it would be better to check IsRunningInMas
msw 2016/10/03 19:14:23 Done.
32 ui_window->SetSharedProperty<int>(GetMusProperty(property), value);
33 else
34 window->SetProperty(property, value);
35 }
36
37 void SetTitle(aura::Window* window, const base::string16& value) {
James Cook 2016/10/01 00:16:21 Should these functions take a views::Widget instea
msw 2016/10/03 19:14:23 I'm following the example of ash/mus/property_util
38 ui::Window* ui_window = aura::GetMusWindow(window);
39 if (ui_window) {
James Cook 2016/10/01 00:16:21 ditto re IsRunningInMash, DCHECKS, etc.
msw 2016/10/03 19:14:23 Done.
40 ui_window->SetSharedProperty<base::string16>(
41 ui::mojom::WindowManager::kWindowTitle_Property, value);
42 } else {
43 window->SetTitle(value);
44 }
45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698