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

Unified Diff: ui/aura/window.cc

Issue 2502413005: Use aura::WindowProperty for title and name strings. (Closed)
Patch Set: Update comment Created 4 years, 1 month 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 | « ui/aura/window.h ('k') | ui/views/accessibility/ax_window_obj_wrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window.cc
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index 67fd26292ac06772170f1c14063572300cd25d0f..0f26981b55882f1765437c96cbd3695e0c35f066 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -18,6 +18,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/event_client.h"
@@ -158,16 +159,28 @@ void Window::SetType(ui::wm::WindowType type) {
type_ = type;
}
+const std::string& Window::GetName() const {
+ std::string* name = GetProperty(client::kNameKey);
+ return name ? *name : base::EmptyString();
+}
+
void Window::SetName(const std::string& name) {
- name_ = name;
+ if (name == GetName())
+ return;
+ SetProperty(client::kNameKey, new std::string(name));
if (layer())
UpdateLayerName();
}
+const base::string16& Window::GetTitle() const {
+ base::string16* title = GetProperty(client::kTitleKey);
+ return title ? *title : base::EmptyString16();
+}
+
void Window::SetTitle(const base::string16& title) {
- if (title == title_)
+ if (title == GetTitle())
return;
- title_ = title;
+ SetProperty(client::kTitleKey, new base::string16(title));
for (WindowObserver& observer : observers_)
observer.OnWindowTitleChanged(this);
}
@@ -609,12 +622,12 @@ void Window::OnDeviceScaleFactorChanged(float device_scale_factor) {
std::string Window::GetDebugInfo() const {
return base::StringPrintf(
"%s<%d> bounds(%d, %d, %d, %d) %s %s opacity=%.1f",
- name().empty() ? "Unknown" : name().c_str(), id(),
- bounds().x(), bounds().y(), bounds().width(), bounds().height(),
+ GetName().empty() ? "Unknown" : GetName().c_str(), id(), bounds().x(),
+ bounds().y(), bounds().width(), bounds().height(),
visible_ ? "WindowVisible" : "WindowHidden",
- layer() ?
- (layer()->GetTargetVisibility() ? "LayerVisible" : "LayerHidden") :
- "NoLayer",
+ layer()
+ ? (layer()->GetTargetVisibility() ? "LayerVisible" : "LayerHidden")
+ : "NoLayer",
layer() ? layer()->opacity() : 1.0f);
}
@@ -1098,7 +1111,7 @@ void Window::UpdateLayerName() {
#if !defined(NDEBUG)
DCHECK(layer());
- std::string layer_name(name_);
+ std::string layer_name(GetName());
if (layer_name.empty())
layer_name = "Unnamed Window";
« no previous file with comments | « ui/aura/window.h ('k') | ui/views/accessibility/ax_window_obj_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698