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

Side by Side Diff: ui/aura/window.cc

Issue 8585007: Added hotkey support to 8508009 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compile issue Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (parent_) 68 if (parent_)
69 parent_->RemoveChild(this); 69 parent_->RemoveChild(this);
70 70
71 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this)); 71 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this));
72 } 72 }
73 73
74 void Window::Init(ui::Layer::LayerType layer_type) { 74 void Window::Init(ui::Layer::LayerType layer_type) {
75 layer_.reset(new ui::Layer(Desktop::GetInstance()->compositor(), layer_type)); 75 layer_.reset(new ui::Layer(Desktop::GetInstance()->compositor(), layer_type));
76 layer_->SetVisible(false); 76 layer_->SetVisible(false);
77 layer_->set_delegate(this); 77 layer_->set_delegate(this);
78 #if !defined(NDEBUG) 78 UpdateLayerName(name_);
79 std::string layer_name(name_);
80 if (layer_name.empty())
81 layer_name.append("Unnamed Window");
82
83 if (id_ != -1) {
84 char id_buf[10];
85 base::snprintf(id_buf, sizeof(id_buf), " %d", id_);
86 layer_name.append(id_buf);
87 }
88 layer_->set_name(layer_name);
89 #endif
90 } 79 }
91 80
92 void Window::SetType(WindowType type) { 81 void Window::SetType(WindowType type) {
93 // Cannot change type after the window is initialized. 82 // Cannot change type after the window is initialized.
94 DCHECK(!layer()); 83 DCHECK(!layer());
95 type_ = type; 84 type_ = type;
96 } 85 }
97 86
87 void Window::SetName(const std::string& name) {
88 name_ = name;
89
90 if (layer())
91 UpdateLayerName(name_);
92 }
93
98 void Window::Show() { 94 void Window::Show() {
99 SetVisible(true); 95 SetVisible(true);
100 } 96 }
101 97
102 void Window::Hide() { 98 void Window::Hide() {
103 SetVisible(false); 99 SetVisible(false);
104 ReleaseCapture(); 100 ReleaseCapture();
105 if (Desktop::GetInstance()->active_window() == this || 101 if (Desktop::GetInstance()->active_window() == this ||
106 !Desktop::GetInstance()->active_window()) { 102 !Desktop::GetInstance()->active_window()) {
107 Desktop::GetInstance()->ActivateTopmostWindow(); 103 Desktop::GetInstance()->ActivateTopmostWindow();
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 } 497 }
502 498
503 return delegate_ ? this : NULL; 499 return delegate_ ? this : NULL;
504 } 500 }
505 501
506 void Window::OnPaintLayer(gfx::Canvas* canvas) { 502 void Window::OnPaintLayer(gfx::Canvas* canvas) {
507 if (delegate_) 503 if (delegate_)
508 delegate_->OnPaint(canvas); 504 delegate_->OnPaint(canvas);
509 } 505 }
510 506
507 void Window::UpdateLayerName(const std::string& name) {
508 #if !defined(NDEBUG)
509 DCHECK(layer());
510
511 std::string layer_name(name_);
512 if (layer_name.empty())
513 layer_name.append("Unnamed Window");
514
515 if (id_ != -1) {
516 char id_buf[10];
517 base::snprintf(id_buf, sizeof(id_buf), " %d", id_);
518 layer_name.append(id_buf);
519 }
520 layer()->set_name(layer_name);
521 #endif
522 }
523
511 } // namespace aura 524 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698