diff options
author | qghc36@motorola.com <qghc36@motorola.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 13:49:49 +0000 |
---|---|---|
committer | qghc36@motorola.com <qghc36@motorola.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 13:49:49 +0000 |
commit | ef1c7df1e0e4967b71681f49b1117537cbe21229 (patch) | |
tree | 0ba6e1084dcc88ab6de254c7b23940df3b0e03fb /chrome/browser/ui | |
parent | 31471e84c6ea53a1527fa0cc32388beb4f61ba5d (diff) | |
download | chromium_src-ef1c7df1e0e4967b71681f49b1117537cbe21229.zip chromium_src-ef1c7df1e0e4967b71681f49b1117537cbe21229.tar.gz chromium_src-ef1c7df1e0e4967b71681f49b1117537cbe21229.tar.bz2 |
TaskManager: Added functionality to remember the size of the task manager dialog so that it can be restored with the same size in further launches.
BUG=105117
TEST=None
Review URL: http://codereview.chromium.org/8741010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r-- | chrome/browser/ui/gtk/html_dialog_gtk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/webui/html_dialog_ui.h | 4 | ||||
-rw-r--r-- | chrome/browser/ui/webui/task_manager_dialog.cc | 30 |
3 files changed, 40 insertions, 0 deletions
diff --git a/chrome/browser/ui/gtk/html_dialog_gtk.cc b/chrome/browser/ui/gtk/html_dialog_gtk.cc index b7d9a68..43c73a1 100644 --- a/chrome/browser/ui/gtk/html_dialog_gtk.cc +++ b/chrome/browser/ui/gtk/html_dialog_gtk.cc @@ -119,8 +119,14 @@ void HtmlDialogGtk::OnDialogClosed(const std::string& json_retval) { if (delegate_) { HtmlDialogUIDelegate* dialog_delegate = delegate_; delegate_ = NULL; // We will not communicate further with the delegate. + + // Store the dialog bounds. + gfx::Rect dialog_bounds = gtk_util::GetDialogBounds(GTK_WIDGET(dialog_)); + dialog_delegate->StoreDialogSize(dialog_bounds); + dialog_delegate->OnDialogClosed(json_retval); } + gtk_widget_destroy(dialog_); delete this; } diff --git a/chrome/browser/ui/webui/html_dialog_ui.h b/chrome/browser/ui/webui/html_dialog_ui.h index da90b8f..e760aa0 100644 --- a/chrome/browser/ui/webui/html_dialog_ui.h +++ b/chrome/browser/ui/webui/html_dialog_ui.h @@ -12,6 +12,7 @@ #include "base/string16.h" #include "chrome/browser/ui/webui/chrome_web_ui.h" #include "googleurl/src/gurl.h" +#include "ui/gfx/rect.h" struct ContextMenuParams; @@ -69,6 +70,9 @@ class HtmlDialogUIDelegate { // customized menu. virtual bool HandleContextMenu(const ContextMenuParams& params); + // Stores the dialog bounds. + virtual void StoreDialogSize(const gfx::Rect dialog_bounds) {} + protected: virtual ~HtmlDialogUIDelegate() {} }; diff --git a/chrome/browser/ui/webui/task_manager_dialog.cc b/chrome/browser/ui/webui/task_manager_dialog.cc index 9fb52e8..6ac33d9 100644 --- a/chrome/browser/ui/webui/task_manager_dialog.cc +++ b/chrome/browser/ui/webui/task_manager_dialog.cc @@ -7,12 +7,16 @@ #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/dialog_style.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" @@ -57,6 +61,21 @@ class TaskManagerDialogImpl : public HtmlDialogUIDelegate { std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE { } virtual void GetDialogSize(gfx::Size* size) const OVERRIDE { + // If dialog's bounds are previously saved, use them. + 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 { @@ -75,6 +94,17 @@ 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 bounds so that it can be restored with the same bounds + // 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(); + placement_pref->SetInteger("width", dialog_bounds.width()); + placement_pref->SetInteger("height", dialog_bounds.height()); + } + } private: void ShowDialog(bool is_background_page_mode); |