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

Side by Side Diff: chrome/browser/ui/views/task_manager_view.cc

Issue 137993009: Remove more non-aura windows code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: renable the disabled tests Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/task_manager.h" 5 #include "chrome/browser/task_manager/task_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/metrics/stats_table.h" 9 #include "base/metrics/stats_table.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 private: 210 private:
211 // Creates the child controls. 211 // Creates the child controls.
212 void Init(); 212 void Init();
213 213
214 // Initializes the state of the always-on-top setting as the window is shown. 214 // Initializes the state of the always-on-top setting as the window is shown.
215 void InitAlwaysOnTopState(); 215 void InitAlwaysOnTopState();
216 216
217 // Activates the tab associated with the focused row. 217 // Activates the tab associated with the focused row.
218 void ActivateFocusedTab(); 218 void ActivateFocusedTab();
219 219
220 // Adds an always on top item to the window's system menu.
221 void AddAlwaysOnTopSystemMenuItem();
222
223 // Restores saved always on top state from a previous session. 220 // Restores saved always on top state from a previous session.
224 bool GetSavedAlwaysOnTopState(bool* always_on_top) const; 221 bool GetSavedAlwaysOnTopState(bool* always_on_top) const;
225 222
226 views::LabelButton* purge_memory_button_; 223 views::LabelButton* purge_memory_button_;
227 views::LabelButton* kill_button_; 224 views::LabelButton* kill_button_;
228 views::Link* about_memory_link_; 225 views::Link* about_memory_link_;
229 views::TableView* tab_table_; 226 views::TableView* tab_table_;
230 views::View* tab_table_parent_; 227 views::View* tab_table_parent_;
231 228
232 TaskManager* task_manager_; 229 TaskManager* task_manager_;
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 // DialogDelegate implementation. 546 // DialogDelegate implementation.
550 bool TaskManagerView::CanResize() const { 547 bool TaskManagerView::CanResize() const {
551 return true; 548 return true;
552 } 549 }
553 550
554 bool TaskManagerView::CanMaximize() const { 551 bool TaskManagerView::CanMaximize() const {
555 return true; 552 return true;
556 } 553 }
557 554
558 bool TaskManagerView::ExecuteWindowsCommand(int command_id) { 555 bool TaskManagerView::ExecuteWindowsCommand(int command_id) {
559 #if defined(OS_WIN) && !defined(USE_AURA)
560 if (command_id == IDC_ALWAYS_ON_TOP) {
561 is_always_on_top_ = !is_always_on_top_;
562
563 // Change the menu check state.
564 HMENU system_menu = GetSystemMenu(GetWidget()->GetNativeWindow(), FALSE);
565 MENUITEMINFO menu_info;
566 memset(&menu_info, 0, sizeof(MENUITEMINFO));
567 menu_info.cbSize = sizeof(MENUITEMINFO);
568 BOOL r = GetMenuItemInfo(system_menu, IDC_ALWAYS_ON_TOP,
569 FALSE, &menu_info);
570 DCHECK(r);
571 menu_info.fMask = MIIM_STATE;
572 if (is_always_on_top_)
573 menu_info.fState = MFS_CHECKED;
574 r = SetMenuItemInfo(system_menu, IDC_ALWAYS_ON_TOP, FALSE, &menu_info);
575
576 // Now change the actual window's behavior.
577 GetWidget()->SetAlwaysOnTop(is_always_on_top_);
578
579 // Save the state.
580 if (g_browser_process->local_state()) {
581 DictionaryPrefUpdate update(g_browser_process->local_state(),
582 GetWindowName().c_str());
583 base::DictionaryValue* window_preferences = update.Get();
584 window_preferences->SetBoolean("always_on_top", is_always_on_top_);
585 }
586 return true;
587 }
588 #endif
589 return false; 556 return false;
590 } 557 }
591 558
592 base::string16 TaskManagerView::GetWindowTitle() const { 559 base::string16 TaskManagerView::GetWindowTitle() const {
593 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_TITLE); 560 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_TITLE);
594 } 561 }
595 562
596 std::string TaskManagerView::GetWindowName() const { 563 std::string TaskManagerView::GetWindowName() const {
597 return prefs::kTaskManagerWindowPlacement; 564 return prefs::kTaskManagerWindowPlacement;
598 } 565 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 } 642 }
676 643
677 void TaskManagerView::ExecuteCommand(int id, int event_flags) { 644 void TaskManagerView::ExecuteCommand(int id, int event_flags) {
678 tab_table_->SetColumnVisibility(id, !tab_table_->IsColumnVisible(id)); 645 tab_table_->SetColumnVisibility(id, !tab_table_->IsColumnVisible(id));
679 } 646 }
680 647
681 void TaskManagerView::InitAlwaysOnTopState() { 648 void TaskManagerView::InitAlwaysOnTopState() {
682 is_always_on_top_ = false; 649 is_always_on_top_ = false;
683 if (GetSavedAlwaysOnTopState(&is_always_on_top_)) 650 if (GetSavedAlwaysOnTopState(&is_always_on_top_))
684 GetWidget()->SetAlwaysOnTop(is_always_on_top_); 651 GetWidget()->SetAlwaysOnTop(is_always_on_top_);
685 AddAlwaysOnTopSystemMenuItem();
686 } 652 }
687 653
688 void TaskManagerView::ActivateFocusedTab() { 654 void TaskManagerView::ActivateFocusedTab() {
689 const int active_row = tab_table_->selection_model().active(); 655 const int active_row = tab_table_->selection_model().active();
690 if (active_row != -1) 656 if (active_row != -1)
691 task_manager_->ActivateProcess(active_row); 657 task_manager_->ActivateProcess(active_row);
692 } 658 }
693 659
694 void TaskManagerView::AddAlwaysOnTopSystemMenuItem() {
695 #if defined(OS_WIN) && !defined(USE_AURA)
696 // The Win32 API requires that we own the text.
697 always_on_top_menu_text_ = l10n_util::GetStringUTF16(IDS_ALWAYS_ON_TOP);
698
699 // Let's insert a menu to the window.
700 HMENU system_menu = ::GetSystemMenu(GetWidget()->GetNativeWindow(), FALSE);
701 int index = ::GetMenuItemCount(system_menu) - 1;
702 if (index < 0) {
703 // Paranoia check.
704 NOTREACHED();
705 index = 0;
706 }
707 // First we add the separator.
708 MENUITEMINFO menu_info;
709 memset(&menu_info, 0, sizeof(MENUITEMINFO));
710 menu_info.cbSize = sizeof(MENUITEMINFO);
711 menu_info.fMask = MIIM_FTYPE;
712 menu_info.fType = MFT_SEPARATOR;
713 ::InsertMenuItem(system_menu, index, TRUE, &menu_info);
714
715 // Then the actual menu.
716 menu_info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING | MIIM_STATE;
717 menu_info.fType = MFT_STRING;
718 menu_info.fState = MFS_ENABLED;
719 if (is_always_on_top_)
720 menu_info.fState |= MFS_CHECKED;
721 menu_info.wID = IDC_ALWAYS_ON_TOP;
722 menu_info.dwTypeData = const_cast<wchar_t*>(always_on_top_menu_text_.c_str());
723 ::InsertMenuItem(system_menu, index, TRUE, &menu_info);
724 #endif
725 }
726
727 bool TaskManagerView::GetSavedAlwaysOnTopState(bool* always_on_top) const { 660 bool TaskManagerView::GetSavedAlwaysOnTopState(bool* always_on_top) const {
728 if (!g_browser_process->local_state()) 661 if (!g_browser_process->local_state())
729 return false; 662 return false;
730 663
731 const base::DictionaryValue* dictionary = 664 const base::DictionaryValue* dictionary =
732 g_browser_process->local_state()->GetDictionary(GetWindowName().c_str()); 665 g_browser_process->local_state()->GetDictionary(GetWindowName().c_str());
733 return dictionary && 666 return dictionary &&
734 dictionary->GetBoolean("always_on_top", always_on_top) && always_on_top; 667 dictionary->GetBoolean("always_on_top", always_on_top) && always_on_top;
735 } 668 }
736 669
737 } // namespace 670 } // namespace
738 671
739 namespace chrome { 672 namespace chrome {
740 673
741 // Declared in browser_dialogs.h so others don't need to depend on our header. 674 // Declared in browser_dialogs.h so others don't need to depend on our header.
742 void ShowTaskManager(Browser* browser) { 675 void ShowTaskManager(Browser* browser) {
743 TaskManagerView::Show(browser); 676 TaskManagerView::Show(browser);
744 } 677 }
745 678
746 } // namespace chrome 679 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698