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

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: Created 9 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 side-by-side diff with in-line comments
Download patch
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..a855836ab0b1d05545fd94168dabe4e17dbde245 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,23 @@ 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.
+ if (g_browser_process->local_state()) {
+ const DictionaryValue* placement_pref =
+ g_browser_process->local_state()->GetDictionary(
+ prefs::kTaskManagerWindowPlacement);
+ int top = 0, left = 0, bottom = 1, right = 1;
James Hawkins 2011/11/30 16:20:32 Why do you set top,left to 0 and bottom,right to 1
NaveenBobbili (Motorola) 2011/12/01 07:31:21 I changed it to only store width and height now.
+ if (placement_pref &&
+ placement_pref->GetInteger("top", &top) &&
+ placement_pref->GetInteger("left", &left) &&
+ placement_pref->GetInteger("bottom", &bottom) &&
+ placement_pref->GetInteger("right", &right)) {
+ size->SetSize(std::max(1, right - left), std::max(1,bottom - top));
James Hawkins 2011/11/30 16:20:32 Space after comma.
NaveenBobbili (Motorola) 2011/12/01 07:31:21 Done.
+ return;
+ }
+ }
+
+ // Otherwise set default size.
size->SetSize(640, 480);
}
virtual std::string GetDialogArgs() const OVERRIDE {
@@ -71,10 +92,27 @@ class TaskManagerDialogImpl : public HtmlDialogUIDelegate {
virtual bool ShouldShowDialogTitle() const OVERRIDE {
return false;
}
+
James Hawkins 2011/11/30 16:20:32 You added a blank line here, but there are not bla
NaveenBobbili (Motorola) 2011/12/01 07:31:21 Sure . Done.
virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE {
return true;
}
+ virtual void StoreDialogSize(gfx::Rect dialog_bounds) OVERRIDE {
+ // Store the dialog's size so we can restore it the next time it's opened.
+ 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.
James Hawkins 2011/11/30 16:20:32 If this is the case, then why not just set "width"
NaveenBobbili (Motorola) 2011/12/01 07:31:21 I changed it to only store width and height now.
+ placement_pref->SetInteger("left", dialog_bounds.x());
+ placement_pref->SetInteger("top", dialog_bounds.y());
+ placement_pref->SetInteger("right", dialog_bounds.right());
+ placement_pref->SetInteger("bottom", dialog_bounds.bottom());
+ placement_pref->SetBoolean("maximized", false);
+ }
+ }
+
private:
void ShowDialog(bool is_background_page_mode);
void OpenHtmlDialog();
« chrome/browser/ui/webui/html_dialog_ui.h ('K') | « 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