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

Unified Diff: components/exo/shell_surface.cc

Issue 1491843002: exo: Add ShellSurface::SetApplicationId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years 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 | « components/exo/shell_surface.h ('k') | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/shell_surface.cc
diff --git a/components/exo/shell_surface.cc b/components/exo/shell_surface.cc
index cf11569eddcc4e7b05cfd54c775f857efd404cc8..40bbd7f01dd034cbad5bc006063ee7afb0e971a1 100644
--- a/components/exo/shell_surface.cc
+++ b/components/exo/shell_surface.cc
@@ -13,9 +13,12 @@
#include "base/trace_event/trace_event_argument.h"
#include "components/exo/surface.h"
#include "ui/aura/window.h"
+#include "ui/aura/window_property.h"
#include "ui/base/hit_test.h"
#include "ui/views/widget/widget.h"
+DECLARE_WINDOW_PROPERTY_TYPE(std::string*)
+
namespace exo {
namespace {
@@ -64,6 +67,8 @@ views::Widget::InitParams CreateWidgetInitParams(
////////////////////////////////////////////////////////////////////////////////
// ShellSurface, public:
+DEFINE_LOCAL_WINDOW_PROPERTY_KEY(std::string*, kApplicationIdKey, nullptr)
+
ShellSurface::ShellSurface(Surface* surface) : surface_(surface) {
surface_->SetSurfaceDelegate(this);
surface_->AddSurfaceObserver(this);
@@ -95,6 +100,7 @@ void ShellSurface::SetToplevel() {
widget_->GetNativeWindow()->set_owned_by_parent(false);
widget_->GetNativeWindow()->SetName("ExoShellSurface");
widget_->GetNativeWindow()->AddChild(surface_);
+ SetApplicationId(widget_->GetNativeWindow(), &application_id_);
// The position of a standard top level shell surface is managed by Ash.
ash::wm::GetWindowState(widget_->GetNativeWindow())
@@ -116,6 +122,7 @@ void ShellSurface::SetMaximized() {
widget_->GetNativeWindow()->set_owned_by_parent(false);
widget_->GetNativeWindow()->SetName("ExoShellSurface");
widget_->GetNativeWindow()->AddChild(surface_);
+ SetApplicationId(widget_->GetNativeWindow(), &application_id_);
}
void ShellSurface::SetFullscreen() {
@@ -133,6 +140,7 @@ void ShellSurface::SetFullscreen() {
widget_->GetNativeWindow()->set_owned_by_parent(false);
widget_->GetNativeWindow()->SetName("ExoShellSurface");
widget_->GetNativeWindow()->AddChild(surface_);
+ SetApplicationId(widget_->GetNativeWindow(), &application_id_);
}
void ShellSurface::SetTitle(const base::string16& title) {
@@ -144,6 +152,25 @@ void ShellSurface::SetTitle(const base::string16& title) {
widget_->UpdateWindowTitle();
}
+// static
+void ShellSurface::SetApplicationId(aura::Window* window,
+ std::string* application_id) {
+ window->SetProperty(kApplicationIdKey, application_id);
+}
+
+// static
+const std::string ShellSurface::GetApplicationId(aura::Window* window) {
+ std::string* string_ptr = window->GetProperty(kApplicationIdKey);
+ return string_ptr ? *string_ptr : std::string();
+}
+
+void ShellSurface::SetApplicationId(const std::string& application_id) {
+ TRACE_EVENT1("exo", "ShellSurface::SetApplicationId", "application_id",
+ application_id);
+
+ application_id_ = application_id;
+}
+
void ShellSurface::Move() {
TRACE_EVENT0("exo", "ShellSurface::Move");
@@ -158,6 +185,7 @@ scoped_refptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue()
scoped_refptr<base::trace_event::TracedValue> value =
new base::trace_event::TracedValue;
value->SetString("title", base::UTF16ToUTF8(title_));
+ value->SetString("application_id", application_id_);
return value;
}
« no previous file with comments | « components/exo/shell_surface.h ('k') | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698