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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_dialog.h" 5 #include "chrome/browser/ui/webui/task_manager_dialog.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/platform_util.h" 11 #include "chrome/browser/platform_util.h"
12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/prefs/scoped_user_pref_update.h"
11 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_dialogs.h" 15 #include "chrome/browser/ui/browser_dialogs.h"
13 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
14 #include "chrome/browser/ui/webui/html_dialog_ui.h" 17 #include "chrome/browser/ui/webui/html_dialog_ui.h"
18 #include "chrome/common/pref_names.h"
15 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
16 #include "grit/google_chrome_strings.h" 20 #include "grit/google_chrome_strings.h"
17 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
18 22
19 #if defined(OS_CHROMEOS) 23 #if defined(OS_CHROMEOS)
20 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
21 #endif 25 #endif
22 26
23 using content::BrowserThread; 27 using content::BrowserThread;
24 28
(...skipping 24 matching lines...) Expand all
49 url_string += "showclose=1&showtitle=1&"; 53 url_string += "showclose=1&showtitle=1&";
50 #endif // defined(OS_CHROMEOS) 54 #endif // defined(OS_CHROMEOS)
51 if (is_background_page_mode_) 55 if (is_background_page_mode_)
52 url_string += "background=1"; 56 url_string += "background=1";
53 return GURL(url_string); 57 return GURL(url_string);
54 } 58 }
55 virtual void GetWebUIMessageHandlers( 59 virtual void GetWebUIMessageHandlers(
56 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE { 60 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE {
57 } 61 }
58 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE { 62 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE {
63 // If we previously saved the dialog's bounds, use them.
64 if (g_browser_process->local_state()) {
65 const DictionaryValue* placement_pref =
66 g_browser_process->local_state()->GetDictionary(
67 prefs::kTaskManagerWindowPlacement);
68 int width, height;
69 if (placement_pref &&
70 placement_pref->GetInteger("width", &width) &&
71 placement_pref->GetInteger("height", &height)) {
72 size->SetSize(std::max(1, width), std::max(1, height));
73 return;
74 }
75 }
76
77 // Otherwise set default size.
59 size->SetSize(640, 480); 78 size->SetSize(640, 480);
60 } 79 }
61 virtual std::string GetDialogArgs() const OVERRIDE { 80 virtual std::string GetDialogArgs() const OVERRIDE {
62 return std::string(); 81 return std::string();
63 } 82 }
64 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { 83 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE {
65 OnCloseDialog(); 84 OnCloseDialog();
66 } 85 }
67 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) 86 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog)
68 OVERRIDE { 87 OVERRIDE {
69 *out_close_dialog = true; 88 *out_close_dialog = true;
70 } 89 }
71 virtual bool ShouldShowDialogTitle() const OVERRIDE { 90 virtual bool ShouldShowDialogTitle() const OVERRIDE {
72 return false; 91 return false;
73 } 92 }
74 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE { 93 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE {
75 return true; 94 return true;
76 } 95 }
96 virtual void StoreDialogSize(gfx::Rect dialog_bounds) OVERRIDE {
97 // Store the dialog's size so we can restore it the next time it's opened.
98 if (g_browser_process->local_state()) {
99 DictionaryPrefUpdate update(g_browser_process->local_state(),
100 prefs::kTaskManagerWindowPlacement);
101 DictionaryValue* placement_pref = update.Get();
102 // Note that we store left/top for consistency with Windows, but that we
103 // *don't* restore them.
104 placement_pref->SetInteger("width", dialog_bounds.width());
105 placement_pref->SetInteger("height", dialog_bounds.height());
106 }
107 }
77 108
78 private: 109 private:
79 void ShowDialog(bool is_background_page_mode); 110 void ShowDialog(bool is_background_page_mode);
80 void OpenHtmlDialog(); 111 void OpenHtmlDialog();
81 112
82 int show_count_; 113 int show_count_;
83 114
84 gfx::NativeWindow window_; 115 gfx::NativeWindow window_;
85 bool is_background_page_mode_; 116 bool is_background_page_mode_;
86 117
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 BrowserThread::UI, FROM_HERE, 177 BrowserThread::UI, FROM_HERE,
147 base::Bind(&TaskManagerDialogImpl::Show, false)); 178 base::Bind(&TaskManagerDialogImpl::Show, false));
148 } 179 }
149 180
150 // static 181 // static
151 void TaskManagerDialog::ShowBackgroundPages() { 182 void TaskManagerDialog::ShowBackgroundPages() {
152 BrowserThread::PostTask( 183 BrowserThread::PostTask(
153 BrowserThread::UI, FROM_HERE, 184 BrowserThread::UI, FROM_HERE,
154 base::Bind(&TaskManagerDialogImpl::Show, true)); 185 base::Bind(&TaskManagerDialogImpl::Show, true));
155 } 186 }
OLDNEW
« 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