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

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

Issue 2514473003: Replace IDR window property use with gfx::ImageSkia icons. (Closed)
Patch Set: Add owership comments. Created 4 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
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 "chrome/browser/ui/views/task_manager_view.h" 5 #include "chrome/browser/ui/views/task_manager_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 23 matching lines...) Expand all
34 #include "ui/views/window/dialog_client_view.h" 34 #include "ui/views/window/dialog_client_view.h"
35 35
36 #if defined(USE_ASH) 36 #if defined(USE_ASH)
37 // Note: gn check complains here, despite the correct conditional //ash dep. 37 // Note: gn check complains here, despite the correct conditional //ash dep.
38 #include "ash/common/shelf/shelf_item_types.h" // nogncheck 38 #include "ash/common/shelf/shelf_item_types.h" // nogncheck
39 #include "ash/resources/grit/ash_resources.h" // nogncheck 39 #include "ash/resources/grit/ash_resources.h" // nogncheck
40 #include "ash/wm/window_properties.h" // nogncheck 40 #include "ash/wm/window_properties.h" // nogncheck
41 #include "ash/wm/window_util.h" // nogncheck 41 #include "ash/wm/window_util.h" // nogncheck
42 #include "chrome/browser/ui/ash/ash_util.h" // nogncheck 42 #include "chrome/browser/ui/ash/ash_util.h" // nogncheck
43 #include "chrome/browser/ui/ash/property_util.h" // nogncheck 43 #include "chrome/browser/ui/ash/property_util.h" // nogncheck
44 #include "ui/aura/client/aura_constants.h"
45 #include "ui/base/resource/resource_bundle.h"
46 #include "ui/gfx/image/image_skia.h"
44 #endif // defined(USE_ASH) 47 #endif // defined(USE_ASH)
45 48
46 #if defined(OS_WIN) 49 #if defined(OS_WIN)
47 #include "chrome/browser/shell_integration_win.h" 50 #include "chrome/browser/shell_integration_win.h"
48 #include "ui/base/win/shell.h" 51 #include "ui/base/win/shell.h"
49 #include "ui/views/win/hwnd_util.h" 52 #include "ui/views/win/hwnd_util.h"
50 #endif // defined(OS_WIN) 53 #endif // defined(OS_WIN)
51 54
52 namespace task_manager { 55 namespace task_manager {
53 56
(...skipping 12 matching lines...) Expand all
66 task_manager::TaskManagerTableModel* TaskManagerView::Show(Browser* browser) { 69 task_manager::TaskManagerTableModel* TaskManagerView::Show(Browser* browser) {
67 if (g_task_manager_view) { 70 if (g_task_manager_view) {
68 // If there's a Task manager window open already, just activate it. 71 // If there's a Task manager window open already, just activate it.
69 g_task_manager_view->SelectTaskOfActiveTab(browser); 72 g_task_manager_view->SelectTaskOfActiveTab(browser);
70 g_task_manager_view->GetWidget()->Activate(); 73 g_task_manager_view->GetWidget()->Activate();
71 return g_task_manager_view->table_model_.get(); 74 return g_task_manager_view->table_model_.get();
72 } 75 }
73 76
74 g_task_manager_view = new TaskManagerView(); 77 g_task_manager_view = new TaskManagerView();
75 78
76 gfx::NativeWindow window = 79 gfx::NativeWindow context =
77 browser ? browser->window()->GetNativeWindow() : nullptr; 80 browser ? browser->window()->GetNativeWindow() : nullptr;
78 #if defined(USE_ASH) 81 #if defined(USE_ASH)
79 if (!chrome::IsRunningInMash() && !window) 82 if (!chrome::IsRunningInMash() && !context)
80 window = ash::wm::GetActiveWindow(); 83 context = ash::wm::GetActiveWindow();
81 #endif 84 #endif
82 85
83 DialogDelegate::CreateDialogWidget(g_task_manager_view, window, nullptr); 86 DialogDelegate::CreateDialogWidget(g_task_manager_view, context, nullptr);
84 g_task_manager_view->InitAlwaysOnTopState(); 87 g_task_manager_view->InitAlwaysOnTopState();
85 88
86 #if defined(OS_WIN) 89 #if defined(OS_WIN)
87 // Set the app id for the task manager to the app id of its parent browser. If 90 // Set the app id for the task manager to the app id of its parent browser. If
88 // no parent is specified, the app id will default to that of the initial 91 // no parent is specified, the app id will default to that of the initial
89 // process. 92 // process.
90 if (browser) { 93 if (browser) {
91 ui::win::SetAppIdForWindow( 94 ui::win::SetAppIdForWindow(
92 shell_integration::win::GetChromiumModelIdForProfile( 95 shell_integration::win::GetChromiumModelIdForProfile(
93 browser->profile()->GetPath()), 96 browser->profile()->GetPath()),
94 views::HWNDForWidget(g_task_manager_view->GetWidget())); 97 views::HWNDForWidget(g_task_manager_view->GetWidget()));
95 } 98 }
96 #endif 99 #endif
97 100
98 g_task_manager_view->SelectTaskOfActiveTab(browser); 101 g_task_manager_view->SelectTaskOfActiveTab(browser);
99 g_task_manager_view->GetWidget()->Show(); 102 g_task_manager_view->GetWidget()->Show();
100 103
101 // Set the initial focus to the list of tasks. 104 // Set the initial focus to the list of tasks.
102 views::FocusManager* focus_manager = g_task_manager_view->GetFocusManager(); 105 views::FocusManager* focus_manager = g_task_manager_view->GetFocusManager();
103 if (focus_manager) 106 if (focus_manager)
104 focus_manager->SetFocusedView(g_task_manager_view->tab_table_); 107 focus_manager->SetFocusedView(g_task_manager_view->tab_table_);
105 108
106 #if defined(USE_ASH) 109 #if defined(USE_ASH)
107 aura::Window* aura_window = 110 aura::Window* window = g_task_manager_view->GetWidget()->GetNativeWindow();
108 g_task_manager_view->GetWidget()->GetNativeWindow(); 111 property_util::SetIntProperty(window, ash::kShelfItemTypeKey,
109 property_util::SetIntProperty(aura_window, ash::kShelfItemTypeKey,
110 ash::TYPE_DIALOG); 112 ash::TYPE_DIALOG);
111 property_util::SetIntProperty(aura_window, ash::kShelfIconResourceIdKey, 113 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
112 IDR_ASH_SHELF_ICON_TASK_MANAGER); 114 gfx::ImageSkia* icon = rb.GetImageSkiaNamed(IDR_ASH_SHELF_ICON_TASK_MANAGER);
115 // The new gfx::ImageSkia instance is owned by the window itself.
116 window->SetProperty(aura::client::kWindowIconKey, new gfx::ImageSkia(*icon));
113 #endif 117 #endif
114 return g_task_manager_view->table_model_.get(); 118 return g_task_manager_view->table_model_.get();
115 } 119 }
116 120
117 // static 121 // static
118 void TaskManagerView::Hide() { 122 void TaskManagerView::Hide() {
119 if (g_task_manager_view) 123 if (g_task_manager_view)
120 g_task_manager_view->GetWidget()->Close(); 124 g_task_manager_view->GetWidget()->Close();
121 } 125 }
122 126
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 if (!g_browser_process->local_state()) 367 if (!g_browser_process->local_state())
364 return; 368 return;
365 369
366 const base::DictionaryValue* dictionary = 370 const base::DictionaryValue* dictionary =
367 g_browser_process->local_state()->GetDictionary(GetWindowName()); 371 g_browser_process->local_state()->GetDictionary(GetWindowName());
368 if (dictionary) 372 if (dictionary)
369 dictionary->GetBoolean("always_on_top", &is_always_on_top_); 373 dictionary->GetBoolean("always_on_top", &is_always_on_top_);
370 } 374 }
371 375
372 } // namespace task_manager 376 } // namespace task_manager
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/property_util.cc ('k') | services/ui/public/interfaces/window_manager.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698