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

Side by Side Diff: chrome/browser/ui/webui/task_manager_dialog.cc

Issue 9569001: WebUI TaskManager: Add method to set minimum window size on HTMLDialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 void OnCloseDialog(); 47 void OnCloseDialog();
48 48
49 // Overridden from HtmlDialogUIDelegate: 49 // Overridden from HtmlDialogUIDelegate:
50 virtual ui::ModalType GetDialogModalType() const OVERRIDE { 50 virtual ui::ModalType GetDialogModalType() const OVERRIDE {
51 return ui::MODAL_TYPE_NONE; 51 return ui::MODAL_TYPE_NONE;
52 } 52 }
53 virtual string16 GetDialogTitle() const OVERRIDE { 53 virtual string16 GetDialogTitle() const OVERRIDE {
54 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_TITLE); 54 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_TITLE);
55 } 55 }
56 virtual std::string GetDialogName() const OVERRIDE {
57 return prefs::kTaskManagerWindowPlacement;
58 }
56 virtual GURL GetDialogContentURL() const OVERRIDE { 59 virtual GURL GetDialogContentURL() const OVERRIDE {
57 std::string url_string(chrome::kChromeUITaskManagerURL); 60 std::string url_string(chrome::kChromeUITaskManagerURL);
58 url_string += "?"; 61 url_string += "?";
59 if (browser_defaults::kShowCancelButtonInTaskManager) 62 if (browser_defaults::kShowCancelButtonInTaskManager)
60 url_string += "showclose=1&"; 63 url_string += "showclose=1&";
61 if (browser_defaults::kShowHtmlTitleBarInTaskManager) 64 if (browser_defaults::kShowHtmlTitleBarInTaskManager)
62 url_string += "showtitle=1&"; 65 url_string += "showtitle=1&";
63 if (is_background_page_mode_) 66 if (is_background_page_mode_)
64 url_string += "background=1"; 67 url_string += "background=1";
65 return GURL(url_string); 68 return GURL(url_string);
66 } 69 }
67 virtual void GetWebUIMessageHandlers( 70 virtual void GetWebUIMessageHandlers(
68 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE { 71 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE {
69 } 72 }
70 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE { 73 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE {
74 #if !defined(TOOLKIT_VIEWS)
71 // If dialog's bounds are previously saved, use them. 75 // If dialog's bounds are previously saved, use them.
72 if (g_browser_process->local_state()) { 76 if (g_browser_process->local_state()) {
73 const DictionaryValue* placement_pref = 77 const DictionaryValue* placement_pref =
74 g_browser_process->local_state()->GetDictionary( 78 g_browser_process->local_state()->GetDictionary(
75 prefs::kTaskManagerWindowPlacement); 79 prefs::kTaskManagerWindowPlacement);
76 int width, height; 80 int width, height;
77 if (placement_pref && 81 if (placement_pref &&
78 placement_pref->GetInteger("width", &width) && 82 placement_pref->GetInteger("width", &width) &&
79 placement_pref->GetInteger("height", &height)) { 83 placement_pref->GetInteger("height", &height)) {
80 size->SetSize(std::max(1, width), std::max(1, height)); 84 size->SetSize(std::max(1, width), std::max(1, height));
81 return; 85 return;
82 } 86 }
83 } 87 }
84 88
85 // Otherwise set default size. 89 // Otherwise set default size.
86 size->SetSize(640, 480); 90 size->SetSize(640, 480);
91 #endif
92 }
93 virtual void GetMinimumDialogSize(gfx::Size* size) const OVERRIDE {
94 size->SetSize(640, 480);
87 } 95 }
88 virtual std::string GetDialogArgs() const OVERRIDE { 96 virtual std::string GetDialogArgs() const OVERRIDE {
89 return std::string(); 97 return std::string();
90 } 98 }
91 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { 99 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE {
92 OnCloseDialog(); 100 OnCloseDialog();
93 } 101 }
94 virtual void OnCloseContents(WebContents* source, bool* out_close_dialog) 102 virtual void OnCloseContents(WebContents* source, bool* out_close_dialog)
95 OVERRIDE { 103 OVERRIDE {
96 *out_close_dialog = true; 104 *out_close_dialog = true;
97 } 105 }
98 virtual bool ShouldShowDialogTitle() const OVERRIDE { 106 virtual bool ShouldShowDialogTitle() const OVERRIDE {
99 return false; 107 return false;
100 } 108 }
101 virtual bool HandleContextMenu( 109 virtual bool HandleContextMenu(
102 const content::ContextMenuParams& params) OVERRIDE { 110 const content::ContextMenuParams& params) OVERRIDE {
103 return true; 111 return true;
104 } 112 }
113 #if !defined(TOOLKIT_VIEWS)
105 virtual void StoreDialogSize(const gfx::Size& dialog_size) OVERRIDE { 114 virtual void StoreDialogSize(const gfx::Size& dialog_size) OVERRIDE {
106 // Store the dialog's bounds so that it can be restored with the same bounds 115 // Store the dialog's bounds so that it can be restored with the same bounds
107 // the next time it's opened. 116 // the next time it's opened.
108 if (g_browser_process->local_state()) { 117 if (g_browser_process->local_state()) {
109 DictionaryPrefUpdate update(g_browser_process->local_state(), 118 DictionaryPrefUpdate update(g_browser_process->local_state(),
110 prefs::kTaskManagerWindowPlacement); 119 prefs::kTaskManagerWindowPlacement);
111 DictionaryValue* placement_pref = update.Get(); 120 DictionaryValue* placement_pref = update.Get();
112 placement_pref->SetInteger("width", dialog_size.width()); 121 placement_pref->SetInteger("width", dialog_size.width());
113 placement_pref->SetInteger("height", dialog_size.height()); 122 placement_pref->SetInteger("height", dialog_size.height());
114 } 123 }
115 } 124 }
125 #endif
116 126
117 private: 127 private:
118 void ShowDialog(bool is_background_page_mode); 128 void ShowDialog(bool is_background_page_mode);
119 void OpenHtmlDialog(); 129 void OpenHtmlDialog();
120 130
121 int show_count_; 131 int show_count_;
122 132
123 gfx::NativeWindow window_; 133 gfx::NativeWindow window_;
124 bool is_background_page_mode_; 134 bool is_background_page_mode_;
125 135
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 BrowserThread::PostTask( 206 BrowserThread::PostTask(
197 BrowserThread::UI, FROM_HERE, 207 BrowserThread::UI, FROM_HERE,
198 base::Bind(&TaskManagerDialogImpl::Show, true)); 208 base::Bind(&TaskManagerDialogImpl::Show, true));
199 } 209 }
200 210
201 // static 211 // static
202 bool TaskManagerDialog::UseWebUITaskManager() { 212 bool TaskManagerDialog::UseWebUITaskManager() {
203 return CommandLine::ForCurrentProcess()->HasSwitch( 213 return CommandLine::ForCurrentProcess()->HasSwitch(
204 switches::kWebUITaskManager); 214 switches::kWebUITaskManager);
205 } 215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698