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

Unified Diff: chrome/browser/ui/ash/property_util.cc

Issue 2381183002: mash: Fix shelf window property use in Chrome. (Closed)
Patch Set: Address 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/ash/property_util.h ('k') | chrome/browser/ui/views/task_manager_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/ash/property_util.cc
diff --git a/chrome/browser/ui/ash/property_util.cc b/chrome/browser/ui/ash/property_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..810e79a00cd21b6660bdb9dc41fe28f88ac8510f
--- /dev/null
+++ b/chrome/browser/ui/ash/property_util.cc
@@ -0,0 +1,54 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/ash/property_util.h"
+
+#include "ash/wm/window_properties.h"
+#include "chrome/browser/ui/ash/ash_util.h"
+#include "services/ui/public/cpp/property_type_converters.h"
+#include "services/ui/public/cpp/window.h"
+#include "services/ui/public/cpp/window_property.h"
+#include "services/ui/public/interfaces/window_manager.mojom.h"
+#include "ui/aura/mus/mus_util.h"
+
+namespace {
+
+// Get the corresponding ui::Window property key for an aura::Window key.
+template <typename T>
+const char* GetMusProperty(const aura::WindowProperty<T>* aura_key) {
+ if (aura_key == ash::kShelfIconResourceIdKey)
+ return ui::mojom::WindowManager::kShelfIconResourceId_Property;
+ if (aura_key == ash::kShelfItemTypeKey)
+ return ui::mojom::WindowManager::kShelfItemType_Property;
+ NOTREACHED();
+ return nullptr;
+}
+
+} // namespace
+
+namespace property_util {
+
+void SetIntProperty(aura::Window* window,
+ const aura::WindowProperty<int>* property,
+ int value) {
+ DCHECK(window);
+ if (chrome::IsRunningInMash()) {
+ aura::GetMusWindow(window)->SetSharedProperty<int>(GetMusProperty(property),
+ value);
+ } else {
+ window->SetProperty(property, value);
+ }
+}
+
+void SetTitle(aura::Window* window, const base::string16& value) {
+ DCHECK(window);
+ if (chrome::IsRunningInMash()) {
+ aura::GetMusWindow(window)->SetSharedProperty<base::string16>(
+ ui::mojom::WindowManager::kWindowTitle_Property, value);
+ } else {
+ window->SetTitle(value);
+ }
+}
+
+} // namespace property_util
« no previous file with comments | « chrome/browser/ui/ash/property_util.h ('k') | chrome/browser/ui/views/task_manager_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698