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

Side by Side Diff: components/exo/shell_surface.cc

Issue 2889523003: Add kApplicationIdKey for ShellSurface::GetApplicationId and SetApplicationId (Closed)
Patch Set: Address comments. Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « components/exo/shell_surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/exo/shell_surface.h" 5 #include "components/exo/shell_surface.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/frame/custom_frame_view_ash.h" 9 #include "ash/frame/custom_frame_view_ash.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "ui/wm/core/window_animations.h" 44 #include "ui/wm/core/window_animations.h"
45 #include "ui/wm/core/window_util.h" 45 #include "ui/wm/core/window_util.h"
46 46
47 #if defined(OS_CHROMEOS) 47 #if defined(OS_CHROMEOS)
48 #include "chromeos/audio/chromeos_sounds.h" 48 #include "chromeos/audio/chromeos_sounds.h"
49 #endif 49 #endif
50 50
51 namespace exo { 51 namespace exo {
52 namespace { 52 namespace {
53 53
54 DEFINE_LOCAL_UI_CLASS_PROPERTY_KEY(Surface*, kMainSurfaceKey, nullptr)
55
56 // Application Id set by the client.
57 DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(std::string, kExoAppIdKey, nullptr);
reveman 2017/05/18 03:53:12 nit: s/kExoAppIdKey/kApplicationIdKey/ as exo pref
yawano 2017/05/18 04:07:36 Done.
58
54 // This is a struct for accelerator keys used to close ShellSurfaces. 59 // This is a struct for accelerator keys used to close ShellSurfaces.
55 const struct Accelerator { 60 const struct Accelerator {
56 ui::KeyboardCode keycode; 61 ui::KeyboardCode keycode;
57 int modifiers; 62 int modifiers;
58 } kCloseWindowAccelerators[] = { 63 } kCloseWindowAccelerators[] = {
59 {ui::VKEY_W, ui::EF_CONTROL_DOWN}, 64 {ui::VKEY_W, ui::EF_CONTROL_DOWN},
60 {ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN}, 65 {ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN},
61 {ui::VKEY_F4, ui::EF_ALT_DOWN}}; 66 {ui::VKEY_F4, ui::EF_ALT_DOWN}};
62 67
63 class CustomFrameView : public views::NonClientFrameView { 68 class CustomFrameView : public views::NonClientFrameView {
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 aura::Window* window = shell_surface_->widget_->GetNativeWindow(); 309 aura::Window* window = shell_surface_->widget_->GetNativeWindow();
305 DCHECK_EQ(window->GetProperty(aura::client::kAnimationsDisabledKey), true); 310 DCHECK_EQ(window->GetProperty(aura::client::kAnimationsDisabledKey), true);
306 window->SetProperty(aura::client::kAnimationsDisabledKey, 311 window->SetProperty(aura::client::kAnimationsDisabledKey,
307 saved_animations_disabled_); 312 saved_animations_disabled_);
308 } 313 }
309 } 314 }
310 315
311 //////////////////////////////////////////////////////////////////////////////// 316 ////////////////////////////////////////////////////////////////////////////////
312 // ShellSurface, public: 317 // ShellSurface, public:
313 318
314 DEFINE_LOCAL_UI_CLASS_PROPERTY_KEY(Surface*, kMainSurfaceKey, nullptr)
315
316 ShellSurface::ShellSurface(Surface* surface, 319 ShellSurface::ShellSurface(Surface* surface,
317 ShellSurface* parent, 320 ShellSurface* parent,
318 BoundsMode bounds_mode, 321 BoundsMode bounds_mode,
319 const gfx::Point& origin, 322 const gfx::Point& origin,
320 bool activatable, 323 bool activatable,
321 bool can_minimize, 324 bool can_minimize,
322 int container) 325 int container)
323 : widget_(nullptr), 326 : widget_(nullptr),
324 surface_(surface), 327 surface_(surface),
325 parent_(parent ? parent->GetWidget()->GetNativeWindow() : nullptr), 328 parent_(parent ? parent->GetWidget()->GetNativeWindow() : nullptr),
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 DCHECK_EQ(container_, ash::kShellWindowId_SystemModalContainer); 551 DCHECK_EQ(container_, ash::kShellWindowId_SystemModalContainer);
549 widget_->GetNativeWindow()->SetProperty( 552 widget_->GetNativeWindow()->SetProperty(
550 aura::client::kModalKey, 553 aura::client::kModalKey,
551 system_modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE); 554 system_modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE);
552 } 555 }
553 556
554 // static 557 // static
555 void ShellSurface::SetApplicationId(aura::Window* window, 558 void ShellSurface::SetApplicationId(aura::Window* window,
556 const std::string& id) { 559 const std::string& id) {
557 TRACE_EVENT1("exo", "ShellSurface::SetApplicationId", "application_id", id); 560 TRACE_EVENT1("exo", "ShellSurface::SetApplicationId", "application_id", id);
558 const ash::ShelfID shelf_id(id); 561 window->SetProperty(kExoAppIdKey, new std::string(id));
559 window->SetProperty(ash::kShelfIDKey, new std::string(shelf_id.Serialize()));
560 } 562 }
561 563
562 // static 564 // static
563 const std::string ShellSurface::GetApplicationId(aura::Window* window) { 565 const std::string* ShellSurface::GetApplicationId(aura::Window* window) {
564 return ash::ShelfID::Deserialize(window->GetProperty(ash::kShelfIDKey)) 566 return window->GetProperty(kExoAppIdKey);
565 .app_id;
566 } 567 }
567 568
568 void ShellSurface::SetApplicationId(const std::string& application_id) { 569 void ShellSurface::SetApplicationId(const std::string& application_id) {
569 // Store the value in |application_id_| in case the window does not exist yet. 570 // Store the value in |application_id_| in case the window does not exist yet.
570 application_id_ = application_id; 571 application_id_ = application_id;
571 if (widget_ && widget_->GetNativeWindow()) 572 if (widget_ && widget_->GetNativeWindow())
572 SetApplicationId(widget_->GetNativeWindow(), application_id); 573 SetApplicationId(widget_->GetNativeWindow(), application_id);
573 } 574 }
574 575
575 void ShellSurface::Move() { 576 void ShellSurface::Move() {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 // static 707 // static
707 Surface* ShellSurface::GetMainSurface(const aura::Window* window) { 708 Surface* ShellSurface::GetMainSurface(const aura::Window* window) {
708 return window->GetProperty(kMainSurfaceKey); 709 return window->GetProperty(kMainSurfaceKey);
709 } 710 }
710 711
711 std::unique_ptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue() 712 std::unique_ptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue()
712 const { 713 const {
713 std::unique_ptr<base::trace_event::TracedValue> value( 714 std::unique_ptr<base::trace_event::TracedValue> value(
714 new base::trace_event::TracedValue()); 715 new base::trace_event::TracedValue());
715 value->SetString("title", base::UTF16ToUTF8(title_)); 716 value->SetString("title", base::UTF16ToUTF8(title_));
716 std::string application_id; 717 const std::string* application_id = nullptr;
717 if (GetWidget() && GetWidget()->GetNativeWindow()) 718 if (GetWidget() && GetWidget()->GetNativeWindow())
718 application_id = GetApplicationId(GetWidget()->GetNativeWindow()); 719 application_id = GetApplicationId(GetWidget()->GetNativeWindow());
719 value->SetString("application_id", application_id); 720 value->SetString("application_id",
reveman 2017/05/18 03:53:12 nit: empty application_id value is not worth much
yawano 2017/05/18 04:07:36 Done.
721 application_id ? *application_id : std::string());
720 return value; 722 return value;
721 } 723 }
722 724
723 //////////////////////////////////////////////////////////////////////////////// 725 ////////////////////////////////////////////////////////////////////////////////
724 // SurfaceDelegate overrides: 726 // SurfaceDelegate overrides:
725 727
726 void ShellSurface::OnSurfaceCommit() { 728 void ShellSurface::OnSurfaceCommit() {
727 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); 729 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces();
728 surface_->CommitSurfaceHierarchy(); 730 surface_->CommitSurfaceHierarchy();
729 731
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 gfx::Point ShellSurface::GetMouseLocation() const { 1739 gfx::Point ShellSurface::GetMouseLocation() const {
1738 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); 1740 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow();
1739 gfx::Point location = 1741 gfx::Point location =
1740 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); 1742 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot();
1741 aura::Window::ConvertPointToTarget( 1743 aura::Window::ConvertPointToTarget(
1742 root_window, widget_->GetNativeWindow()->parent(), &location); 1744 root_window, widget_->GetNativeWindow()->parent(), &location);
1743 return location; 1745 return location;
1744 } 1746 }
1745 1747
1746 } // namespace exo 1748 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/shell_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698