Commit ef1c7df1 authored by qghc36@motorola.com's avatar qghc36@motorola.com

TaskManager: Added functionality to remember the size of the task manager...

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
parent 31471e84
...@@ -119,8 +119,14 @@ void HtmlDialogGtk::OnDialogClosed(const std::string& json_retval) { ...@@ -119,8 +119,14 @@ void HtmlDialogGtk::OnDialogClosed(const std::string& json_retval) {
if (delegate_) { if (delegate_) {
HtmlDialogUIDelegate* dialog_delegate = delegate_; HtmlDialogUIDelegate* dialog_delegate = delegate_;
delegate_ = NULL; // We will not communicate further with the 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); dialog_delegate->OnDialogClosed(json_retval);
} }
gtk_widget_destroy(dialog_); gtk_widget_destroy(dialog_);
delete this; delete this;
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/string16.h" #include "base/string16.h"
#include "chrome/browser/ui/webui/chrome_web_ui.h" #include "chrome/browser/ui/webui/chrome_web_ui.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "ui/gfx/rect.h"
struct ContextMenuParams; struct ContextMenuParams;
...@@ -69,6 +70,9 @@ class HtmlDialogUIDelegate { ...@@ -69,6 +70,9 @@ class HtmlDialogUIDelegate {
// customized menu. // customized menu.
virtual bool HandleContextMenu(const ContextMenuParams& params); virtual bool HandleContextMenu(const ContextMenuParams& params);
// Stores the dialog bounds.
virtual void StoreDialogSize(const gfx::Rect dialog_bounds) {}
protected: protected:
virtual ~HtmlDialogUIDelegate() {} virtual ~HtmlDialogUIDelegate() {}
}; };
......
...@@ -7,12 +7,16 @@ ...@@ -7,12 +7,16 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/platform_util.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.h"
#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/dialog_style.h" #include "chrome/browser/ui/dialog_style.h"
#include "chrome/browser/ui/webui/html_dialog_ui.h" #include "chrome/browser/ui/webui/html_dialog_ui.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "grit/google_chrome_strings.h" #include "grit/google_chrome_strings.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -57,6 +61,21 @@ class TaskManagerDialogImpl : public HtmlDialogUIDelegate { ...@@ -57,6 +61,21 @@ class TaskManagerDialogImpl : public HtmlDialogUIDelegate {
std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE { std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE {
} }
virtual void GetDialogSize(gfx::Size* size) 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); size->SetSize(640, 480);
} }
virtual std::string GetDialogArgs() const OVERRIDE { virtual std::string GetDialogArgs() const OVERRIDE {
...@@ -75,6 +94,17 @@ class TaskManagerDialogImpl : public HtmlDialogUIDelegate { ...@@ -75,6 +94,17 @@ class TaskManagerDialogImpl : public HtmlDialogUIDelegate {
virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE { virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE {
return true; 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: private:
void ShowDialog(bool is_background_page_mode); void ShowDialog(bool is_background_page_mode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment