OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/task_manager.h" | 5 #include "chrome/browser/task_manager.h" |
6 | 6 |
7 #include "base/stats_table.h" | 7 #include "base/stats_table.h" |
8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 void Init(); | 177 void Init(); |
178 virtual void Layout(); | 178 virtual void Layout(); |
179 virtual gfx::Size GetPreferredSize(); | 179 virtual gfx::Size GetPreferredSize(); |
180 virtual void ViewHierarchyChanged(bool is_add, views::View* parent, | 180 virtual void ViewHierarchyChanged(bool is_add, views::View* parent, |
181 views::View* child); | 181 views::View* child); |
182 | 182 |
183 // TaskManagerView | 183 // TaskManagerView |
184 virtual void GetSelection(std::vector<int>* selection); | 184 virtual void GetSelection(std::vector<int>* selection); |
185 virtual void GetFocused(std::vector<int>* focused); | 185 virtual void GetFocused(std::vector<int>* focused); |
186 virtual void OpenWindow(); | 186 virtual void OpenWindow(); |
| 187 virtual void CloseWindow(); |
187 | 188 |
188 // ButtonListener implementation. | 189 // ButtonListener implementation. |
189 virtual void ButtonPressed(views::Button* sender); | 190 virtual void ButtonPressed(views::Button* sender); |
190 | 191 |
191 // views::DialogDelegate | 192 // views::DialogDelegate |
192 virtual bool CanResize() const; | 193 virtual bool CanResize() const; |
193 virtual bool CanMaximize() const; | 194 virtual bool CanMaximize() const; |
194 virtual bool ExecuteWindowsCommand(int command_id); | 195 virtual bool ExecuteWindowsCommand(int command_id); |
195 virtual std::wstring GetWindowTitle() const; | 196 virtual std::wstring GetWindowTitle() const; |
196 virtual std::wstring GetWindowName() const; | 197 virtual std::wstring GetWindowName() const; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 if (window()) { | 428 if (window()) { |
428 window()->Activate(); | 429 window()->Activate(); |
429 } else { | 430 } else { |
430 views::Window::CreateChromeWindow(NULL, gfx::Rect(), this); | 431 views::Window::CreateChromeWindow(NULL, gfx::Rect(), this); |
431 InitAlwaysOnTopState(); | 432 InitAlwaysOnTopState(); |
432 model_->StartUpdating(); | 433 model_->StartUpdating(); |
433 window()->Show(); | 434 window()->Show(); |
434 } | 435 } |
435 } | 436 } |
436 | 437 |
| 438 void TaskManagerViewImpl::CloseWindow() { |
| 439 if (!window()) |
| 440 return; |
| 441 window()->HideWindow(); |
| 442 } |
| 443 |
437 // ButtonListener implementation. | 444 // ButtonListener implementation. |
438 void TaskManagerViewImpl::ButtonPressed(views::Button* sender) { | 445 void TaskManagerViewImpl::ButtonPressed(views::Button* sender) { |
439 if (sender == kill_button_.get()) | 446 if (sender == kill_button_.get()) |
440 task_manager_->KillSelectedProcesses(); | 447 task_manager_->KillSelectedProcesses(); |
441 } | 448 } |
442 | 449 |
443 // DialogDelegate implementation. | 450 // DialogDelegate implementation. |
444 bool TaskManagerViewImpl::CanResize() const { | 451 bool TaskManagerViewImpl::CanResize() const { |
445 return true; | 452 return true; |
446 } | 453 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 | 498 |
492 int TaskManagerViewImpl::GetDialogButtons() const { | 499 int TaskManagerViewImpl::GetDialogButtons() const { |
493 return MessageBoxFlags::DIALOGBUTTON_NONE; | 500 return MessageBoxFlags::DIALOGBUTTON_NONE; |
494 } | 501 } |
495 | 502 |
496 void TaskManagerViewImpl::WindowClosing() { | 503 void TaskManagerViewImpl::WindowClosing() { |
497 // Remove the view from its parent to trigger the contents' | 504 // Remove the view from its parent to trigger the contents' |
498 // ViewHierarchyChanged notification to unhook the extra buttons from the | 505 // ViewHierarchyChanged notification to unhook the extra buttons from the |
499 // non-client view. | 506 // non-client view. |
500 GetParent()->RemoveChildView(this); | 507 GetParent()->RemoveChildView(this); |
501 task_manager_->Close(); | 508 task_manager_->OnWindowClosed(); |
502 } | 509 } |
503 | 510 |
504 void TaskManagerViewImpl::DeleteDelegate() { | 511 void TaskManagerViewImpl::DeleteDelegate() { |
505 ReleaseWindow(); | 512 ReleaseWindow(); |
506 } | 513 } |
507 | 514 |
508 views::View* TaskManagerViewImpl::GetContentsView() { | 515 views::View* TaskManagerViewImpl::GetContentsView() { |
509 return this; | 516 return this; |
510 } | 517 } |
511 | 518 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 g_browser_process->local_state()->GetDictionary(GetWindowName().c_str()); | 611 g_browser_process->local_state()->GetDictionary(GetWindowName().c_str()); |
605 return dictionary && | 612 return dictionary && |
606 dictionary->GetBoolean(L"always_on_top", always_on_top) && always_on_top; | 613 dictionary->GetBoolean(L"always_on_top", always_on_top) && always_on_top; |
607 } | 614 } |
608 | 615 |
609 } // namespace | 616 } // namespace |
610 | 617 |
611 void TaskManager::Init() { | 618 void TaskManager::Init() { |
612 view_.reset(new TaskManagerViewImpl(this, model_.get())); | 619 view_.reset(new TaskManagerViewImpl(this, model_.get())); |
613 } | 620 } |
OLD | NEW |