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

Unified Diff: chrome/browser/ui/webui/task_manager_dialog.cc

Issue 8741010: TaskManager: Added functionality to remember the size of the task manager dialog. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed review comments. Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/html_dialog_ui.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/task_manager_dialog.cc
diff --git a/chrome/browser/ui/webui/task_manager_dialog.cc b/chrome/browser/ui/webui/task_manager_dialog.cc
index 4070c3edc71350dc9940e7f52f3f3856fef5a91d..ce2ddbf732d2ce1eedd1a1edacd924e23c51bc5a 100644
--- a/chrome/browser/ui/webui/task_manager_dialog.cc
+++ b/chrome/browser/ui/webui/task_manager_dialog.cc
@@ -7,11 +7,15 @@
#include "base/bind.h"
#include "base/memory/singleton.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/platform_util.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/webui/html_dialog_ui.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "grit/google_chrome_strings.h"
#include "ui/base/l10n/l10n_util.h"
@@ -56,6 +60,21 @@ class TaskManagerDialogImpl : public HtmlDialogUIDelegate {
std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE {
}
virtual void GetDialogSize(gfx::Size* size) const OVERRIDE {
+ // If we previously saved the dialog's bounds, use them.
James Hawkins 2011/12/02 16:31:31 Don't use 'we' in comments, it's ambiguous.
NaveenBobbili (Motorola) 2011/12/03 01:25:33 Done.
+ if (g_browser_process->local_state()) {
+ const DictionaryValue* placement_pref =
+ g_browser_process->local_state()->GetDictionary(
+ prefs::kTaskManagerWindowPlacement);
+ int width, height;
+ if (placement_pref &&
+ placement_pref->GetInteger("width", &width) &&
+ placement_pref->GetInteger("height", &height)) {
+ size->SetSize(std::max(1, width), std::max(1, height));
+ return;
+ }
+ }
+
+ // Otherwise set default size.
size->SetSize(640, 480);
}
virtual std::string GetDialogArgs() const OVERRIDE {
@@ -74,6 +93,18 @@ class TaskManagerDialogImpl : public HtmlDialogUIDelegate {
virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE {
return true;
}
+ virtual void StoreDialogSize(const gfx::Rect dialog_bounds) OVERRIDE {
+ // Store the dialog's size so we can restore it the next time it's opened.
James Hawkins 2011/12/02 16:31:31 Same here about 'we'.
NaveenBobbili (Motorola) 2011/12/03 01:25:33 Done.
+ if (g_browser_process->local_state()) {
+ DictionaryPrefUpdate update(g_browser_process->local_state(),
+ prefs::kTaskManagerWindowPlacement);
+ DictionaryValue* placement_pref = update.Get();
+ // Note that we store left/top for consistency with Windows, but that we
+ // *don't* restore them.
+ placement_pref->SetInteger("width", dialog_bounds.width());
+ placement_pref->SetInteger("height", dialog_bounds.height());
+ }
+ }
private:
void ShowDialog(bool is_background_page_mode);
« no previous file with comments | « chrome/browser/ui/webui/html_dialog_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698