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

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: 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 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.
69 if (placement_pref &&
70 placement_pref->GetInteger("top", &top) &&
71 placement_pref->GetInteger("left", &left) &&
72 placement_pref->GetInteger("bottom", &bottom) &&
73 placement_pref->GetInteger("right", &right)) {
74 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.
75 return;
76 }
77 }
78
79 // Otherwise set default size.
59 size->SetSize(640, 480); 80 size->SetSize(640, 480);
60 } 81 }
61 virtual std::string GetDialogArgs() const OVERRIDE { 82 virtual std::string GetDialogArgs() const OVERRIDE {
62 return std::string(); 83 return std::string();
63 } 84 }
64 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { 85 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE {
65 OnCloseDialog(); 86 OnCloseDialog();
66 } 87 }
67 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) 88 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog)
68 OVERRIDE { 89 OVERRIDE {
69 *out_close_dialog = true; 90 *out_close_dialog = true;
70 } 91 }
71 virtual bool ShouldShowDialogTitle() const OVERRIDE { 92 virtual bool ShouldShowDialogTitle() const OVERRIDE {
72 return false; 93 return false;
73 } 94 }
95
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.
74 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE { 96 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE {
75 return true; 97 return true;
76 } 98 }
77 99
100 virtual void StoreDialogSize(gfx::Rect dialog_bounds) OVERRIDE {
101 // Store the dialog's size so we can restore it the next time it's opened.
102 if (g_browser_process->local_state()) {
103 DictionaryPrefUpdate update(g_browser_process->local_state(),
104 prefs::kTaskManagerWindowPlacement);
105 DictionaryValue* placement_pref = update.Get();
106 // Note that we store left/top for consistency with Windows, but that we
107 // *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.
108 placement_pref->SetInteger("left", dialog_bounds.x());
109 placement_pref->SetInteger("top", dialog_bounds.y());
110 placement_pref->SetInteger("right", dialog_bounds.right());
111 placement_pref->SetInteger("bottom", dialog_bounds.bottom());
112 placement_pref->SetBoolean("maximized", false);
113 }
114 }
115
78 private: 116 private:
79 void ShowDialog(bool is_background_page_mode); 117 void ShowDialog(bool is_background_page_mode);
80 void OpenHtmlDialog(); 118 void OpenHtmlDialog();
81 119
82 int show_count_; 120 int show_count_;
83 121
84 gfx::NativeWindow window_; 122 gfx::NativeWindow window_;
85 bool is_background_page_mode_; 123 bool is_background_page_mode_;
86 124
87 DISALLOW_COPY_AND_ASSIGN(TaskManagerDialogImpl); 125 DISALLOW_COPY_AND_ASSIGN(TaskManagerDialogImpl);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 BrowserThread::UI, FROM_HERE, 184 BrowserThread::UI, FROM_HERE,
147 base::Bind(&TaskManagerDialogImpl::Show, false)); 185 base::Bind(&TaskManagerDialogImpl::Show, false));
148 } 186 }
149 187
150 // static 188 // static
151 void TaskManagerDialog::ShowBackgroundPages() { 189 void TaskManagerDialog::ShowBackgroundPages() {
152 BrowserThread::PostTask( 190 BrowserThread::PostTask(
153 BrowserThread::UI, FROM_HERE, 191 BrowserThread::UI, FROM_HERE,
154 base::Bind(&TaskManagerDialogImpl::Show, true)); 192 base::Bind(&TaskManagerDialogImpl::Show, true));
155 } 193 }
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