| OLD | NEW |
| 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 "chrome/browser/ui/webui/task_manager_handler.h" | 5 #include "chrome/browser/ui/webui/task_manager_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/task_manager/task_manager.h" | 14 #include "chrome/browser/task_manager/task_manager.h" |
| 15 #include "chrome/browser/ui/webui/web_ui_util.h" | 15 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "content/browser/renderer_host/render_view_host.h" | 17 #include "content/browser/renderer_host/render_view_host.h" |
| 18 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
| 19 #include "content/common/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 20 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 21 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
| 22 #include "webkit/glue/webpreferences.h" | 22 #include "webkit/glue/webpreferences.h" |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 static Value* CreateColumnValue(const TaskManagerModel* tm, | 26 static Value* CreateColumnValue(const TaskManagerModel* tm, |
| 27 const std::string column_name, | 27 const std::string column_name, |
| 28 const int i) { | 28 const int i) { |
| 29 if (column_name == "processId") | 29 if (column_name == "processId") |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 347 } |
| 348 | 348 |
| 349 void TaskManagerHandler::EnableTaskManager(const ListValue* indexes) { | 349 void TaskManagerHandler::EnableTaskManager(const ListValue* indexes) { |
| 350 if (is_enabled_) | 350 if (is_enabled_) |
| 351 return; | 351 return; |
| 352 | 352 |
| 353 is_enabled_ = true; | 353 is_enabled_ = true; |
| 354 model_->AddObserver(this); | 354 model_->AddObserver(this); |
| 355 model_->StartUpdating(); | 355 model_->StartUpdating(); |
| 356 | 356 |
| 357 NotificationService::current()->Notify( | 357 content::NotificationService::current()->Notify( |
| 358 chrome::NOTIFICATION_TASK_MANAGER_WINDOW_READY, | 358 chrome::NOTIFICATION_TASK_MANAGER_WINDOW_READY, |
| 359 content::Source<TaskManagerModel>(model_), | 359 content::Source<TaskManagerModel>(model_), |
| 360 NotificationService::NoDetails()); | 360 content::NotificationService::NoDetails()); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void TaskManagerHandler::OpenAboutMemory(const ListValue* indexes) { | 363 void TaskManagerHandler::OpenAboutMemory(const ListValue* indexes) { |
| 364 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); | 364 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); |
| 365 if (rvh && rvh->delegate()) { | 365 if (rvh && rvh->delegate()) { |
| 366 WebPreferences webkit_prefs = rvh->delegate()->GetWebkitPrefs(); | 366 WebPreferences webkit_prefs = rvh->delegate()->GetWebkitPrefs(); |
| 367 webkit_prefs.allow_scripts_to_close_windows = true; | 367 webkit_prefs.allow_scripts_to_close_windows = true; |
| 368 rvh->UpdateWebkitPreferences(webkit_prefs); | 368 rvh->UpdateWebkitPreferences(webkit_prefs); |
| 369 } else { | 369 } else { |
| 370 DCHECK(false); | 370 DCHECK(false); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 | 422 |
| 423 void TaskManagerHandler::OnGroupRemoved(const int group_start, | 423 void TaskManagerHandler::OnGroupRemoved(const int group_start, |
| 424 const int group_length) { | 424 const int group_length) { |
| 425 base::FundamentalValue start_value(group_start); | 425 base::FundamentalValue start_value(group_start); |
| 426 base::FundamentalValue length_value(group_length); | 426 base::FundamentalValue length_value(group_length); |
| 427 if (is_enabled_) | 427 if (is_enabled_) |
| 428 web_ui_->CallJavascriptFunction("taskRemoved", start_value, length_value); | 428 web_ui_->CallJavascriptFunction("taskRemoved", start_value, length_value); |
| 429 } | 429 } |
| OLD | NEW |