| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/mus/public/cpp/window.h" | 5 #include "components/mus/public/cpp/window.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <set> | 10 #include <set> |
| 8 #include <string> | 11 #include <string> |
| 9 | 12 |
| 10 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/macros.h" |
| 11 #include "components/mus/common/transient_window_utils.h" | 15 #include "components/mus/common/transient_window_utils.h" |
| 12 #include "components/mus/public/cpp/lib/window_private.h" | 16 #include "components/mus/public/cpp/lib/window_private.h" |
| 13 #include "components/mus/public/cpp/lib/window_tree_client_impl.h" | 17 #include "components/mus/public/cpp/lib/window_tree_client_impl.h" |
| 14 #include "components/mus/public/cpp/window_observer.h" | 18 #include "components/mus/public/cpp/window_observer.h" |
| 15 #include "components/mus/public/cpp/window_surface.h" | 19 #include "components/mus/public/cpp/window_surface.h" |
| 16 #include "components/mus/public/cpp/window_tracker.h" | 20 #include "components/mus/public/cpp/window_tracker.h" |
| 17 #include "mojo/application/public/cpp/service_provider_impl.h" | 21 #include "mojo/application/public/cpp/service_provider_impl.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/gfx/geometry/size.h" | 23 #include "ui/gfx/geometry/size.h" |
| 20 | 24 |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 transport_value.resize(value->size()); | 491 transport_value.resize(value->size()); |
| 488 if (value->size()) | 492 if (value->size()) |
| 489 memcpy(&transport_value.front(), &(value->front()), value->size()); | 493 memcpy(&transport_value.front(), &(value->front()), value->size()); |
| 490 } | 494 } |
| 491 // TODO: add test coverage of this (450303). | 495 // TODO: add test coverage of this (450303). |
| 492 tree_client()->SetProperty(this, name, std::move(transport_value)); | 496 tree_client()->SetProperty(this, name, std::move(transport_value)); |
| 493 } | 497 } |
| 494 LocalSetSharedProperty(name, value); | 498 LocalSetSharedProperty(name, value); |
| 495 } | 499 } |
| 496 | 500 |
| 497 int64 Window::SetLocalPropertyInternal(const void* key, | 501 int64_t Window::SetLocalPropertyInternal(const void* key, |
| 498 const char* name, | 502 const char* name, |
| 499 PropertyDeallocator deallocator, | 503 PropertyDeallocator deallocator, |
| 500 int64 value, | 504 int64_t value, |
| 501 int64 default_value) { | 505 int64_t default_value) { |
| 502 int64 old = GetLocalPropertyInternal(key, default_value); | 506 int64_t old = GetLocalPropertyInternal(key, default_value); |
| 503 if (value == default_value) { | 507 if (value == default_value) { |
| 504 prop_map_.erase(key); | 508 prop_map_.erase(key); |
| 505 } else { | 509 } else { |
| 506 Value prop_value; | 510 Value prop_value; |
| 507 prop_value.name = name; | 511 prop_value.name = name; |
| 508 prop_value.value = value; | 512 prop_value.value = value; |
| 509 prop_value.deallocator = deallocator; | 513 prop_value.deallocator = deallocator; |
| 510 prop_map_[key] = prop_value; | 514 prop_map_[key] = prop_value; |
| 511 } | 515 } |
| 512 FOR_EACH_OBSERVER(WindowObserver, observers_, | 516 FOR_EACH_OBSERVER(WindowObserver, observers_, |
| 513 OnWindowLocalPropertyChanged(this, key, old)); | 517 OnWindowLocalPropertyChanged(this, key, old)); |
| 514 return old; | 518 return old; |
| 515 } | 519 } |
| 516 | 520 |
| 517 int64 Window::GetLocalPropertyInternal(const void* key, | 521 int64_t Window::GetLocalPropertyInternal(const void* key, |
| 518 int64 default_value) const { | 522 int64_t default_value) const { |
| 519 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 523 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
| 520 if (iter == prop_map_.end()) | 524 if (iter == prop_map_.end()) |
| 521 return default_value; | 525 return default_value; |
| 522 return iter->second.value; | 526 return iter->second.value; |
| 523 } | 527 } |
| 524 | 528 |
| 525 void Window::LocalDestroy() { | 529 void Window::LocalDestroy() { |
| 526 delete this; | 530 delete this; |
| 527 } | 531 } |
| 528 | 532 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 notifier->NotifyWindowReordered(); | 802 notifier->NotifyWindowReordered(); |
| 799 | 803 |
| 800 return true; | 804 return true; |
| 801 } | 805 } |
| 802 | 806 |
| 803 // static | 807 // static |
| 804 Window** Window::GetStackingTarget(Window* window) { | 808 Window** Window::GetStackingTarget(Window* window) { |
| 805 return &window->stacking_target_; | 809 return &window->stacking_target_; |
| 806 } | 810 } |
| 807 } // namespace mus | 811 } // namespace mus |
| OLD | NEW |