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

Unified Diff: ash/common/devtools/widget_element.cc

Issue 2776543002: Create a unified UIElement interface for Widget, View and Window. (Closed)
Patch Set: . Created 3 years, 9 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
Index: ash/common/devtools/widget_element.cc
diff --git a/ash/common/devtools/widget_element.cc b/ash/common/devtools/widget_element.cc
new file mode 100644
index 0000000000000000000000000000000000000000..238c60fe1002f6e5cdb3703699fb916304edf895
--- /dev/null
+++ b/ash/common/devtools/widget_element.cc
@@ -0,0 +1,60 @@
+// Copyright 2017 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 "ash/common/devtools/widget_element.h"
+
+namespace ash {
+namespace devtools {
+
+WidgetElement::WidgetElement(views::Widget* widget) : widget_(widget) {}
+
+void WidgetElement::OnWillRemoveView(views::Widget* widget, views::View* view) {
+ if (view == widget->GetRootView())
+ DomAgentDelegate()->NotifyRemoveViewTree(view, nullptr, true);
+}
+
+void WidgetElement::OnWidgetBoundsChanged(views::Widget* widget,
+ const gfx::Rect& new_bounds) {
+ DomAgentDelegate()->NotifyOnWidgetBoundsChanged(widget);
+}
+
+bool WidgetElement::GetBounds(gfx::Rect* bounds) {
+ if (widget_) {
+ *bounds = widget_->GetRestoredBounds();
+ return true;
+ }
+ return false;
+}
+
+bool WidgetElement::SetBounds(const gfx::Rect& bounds) {
+ if (widget_) {
+ widget_->SetBounds(bounds);
+ return true;
+ }
+ return false;
+}
+
+bool WidgetElement::GetVisible(bool* visible) {
+ if (widget_) {
+ *visible = widget_->IsVisible();
+ return true;
+ }
+ return false;
+}
+
+bool WidgetElement::SetVisible(bool visible) {
+ if (widget_) {
+ if (visible != widget_->IsVisible()) {
+ if (visible)
+ widget_->Show();
+ else
+ widget_->Hide();
+ }
+ return true;
+ }
+ return false;
+}
+
+} // namespace devtools
+} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698