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

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

Issue 9749003: Revert 127660 - 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
« no previous file with comments | « chrome/browser/ui/webui/html_dialog_ui.cc ('k') | ui/views/widget/widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/task_manager_dialog.h" 5 #include "chrome/browser/ui/webui/task_manager/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 11 matching lines...) Expand all
22 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
24 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
25 #include "grit/google_chrome_strings.h" 25 #include "grit/google_chrome_strings.h"
26 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
27 27
28 #if defined(OS_CHROMEOS) 28 #if defined(OS_CHROMEOS)
29 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
30 #endif 30 #endif
31 31
32 namespace {
33
34 // The minimum size of task manager window in px.
35 const int kMinimumTaskManagerWidth = 640;
36 const int kMinimumTaskManagerHeight = 480;
37
38 } // namespace
39
40 using content::BrowserThread; 32 using content::BrowserThread;
41 using content::WebContents; 33 using content::WebContents;
42 using content::WebUIMessageHandler; 34 using content::WebUIMessageHandler;
43 35
44 class TaskManagerDialogImpl : public HtmlDialogUIDelegate { 36 class TaskManagerDialogImpl : public HtmlDialogUIDelegate {
45 public: 37 public:
46 TaskManagerDialogImpl(); 38 TaskManagerDialogImpl();
47 39
48 static void Show(bool is_background_page_mode); 40 static void Show(bool is_background_page_mode);
49 static TaskManagerDialogImpl* GetInstance(); 41 static TaskManagerDialogImpl* GetInstance();
50 42
51 protected: 43 protected:
52 friend struct DefaultSingletonTraits<TaskManagerDialogImpl>; 44 friend struct DefaultSingletonTraits<TaskManagerDialogImpl>;
53 virtual ~TaskManagerDialogImpl(); 45 virtual ~TaskManagerDialogImpl();
54 46
55 void OnCloseDialog(); 47 void OnCloseDialog();
56 48
57 // Overridden from HtmlDialogUIDelegate: 49 // Overridden from HtmlDialogUIDelegate:
58 virtual ui::ModalType GetDialogModalType() const OVERRIDE { 50 virtual ui::ModalType GetDialogModalType() const OVERRIDE {
59 return ui::MODAL_TYPE_NONE; 51 return ui::MODAL_TYPE_NONE;
60 } 52 }
61 virtual string16 GetDialogTitle() const OVERRIDE { 53 virtual string16 GetDialogTitle() const OVERRIDE {
62 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_TITLE); 54 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_TITLE);
63 } 55 }
64 virtual std::string GetDialogName() const OVERRIDE {
65 return prefs::kTaskManagerWindowPlacement;
66 }
67 virtual GURL GetDialogContentURL() const OVERRIDE { 56 virtual GURL GetDialogContentURL() const OVERRIDE {
68 std::string url_string(chrome::kChromeUITaskManagerURL); 57 std::string url_string(chrome::kChromeUITaskManagerURL);
69 url_string += "?"; 58 url_string += "?";
70 if (browser_defaults::kShowCancelButtonInTaskManager) 59 if (browser_defaults::kShowCancelButtonInTaskManager)
71 url_string += "showclose=1&"; 60 url_string += "showclose=1&";
72 if (browser_defaults::kShowHtmlTitleBarInTaskManager) 61 if (browser_defaults::kShowHtmlTitleBarInTaskManager)
73 url_string += "showtitle=1&"; 62 url_string += "showtitle=1&";
74 if (is_background_page_mode_) 63 if (is_background_page_mode_)
75 url_string += "background=1"; 64 url_string += "background=1";
76 return GURL(url_string); 65 return GURL(url_string);
77 } 66 }
78 virtual void GetWebUIMessageHandlers( 67 virtual void GetWebUIMessageHandlers(
79 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE { 68 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE {
80 } 69 }
81 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE { 70 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE {
82 #if !defined(TOOLKIT_VIEWS)
83 // If dialog's bounds are previously saved, use them. 71 // If dialog's bounds are previously saved, use them.
84 if (g_browser_process->local_state()) { 72 if (g_browser_process->local_state()) {
85 const DictionaryValue* placement_pref = 73 const DictionaryValue* placement_pref =
86 g_browser_process->local_state()->GetDictionary( 74 g_browser_process->local_state()->GetDictionary(
87 prefs::kTaskManagerWindowPlacement); 75 prefs::kTaskManagerWindowPlacement);
88 int width, height; 76 int width, height;
89 if (placement_pref && 77 if (placement_pref &&
90 placement_pref->GetInteger("width", &width) && 78 placement_pref->GetInteger("width", &width) &&
91 placement_pref->GetInteger("height", &height)) { 79 placement_pref->GetInteger("height", &height)) {
92 size->SetSize(std::max(1, width), std::max(1, height)); 80 size->SetSize(std::max(1, width), std::max(1, height));
93 return; 81 return;
94 } 82 }
95 } 83 }
96 84
97 // Otherwise set default size. 85 // Otherwise set default size.
98 size->SetSize(kMinimumTaskManagerWidth, kMinimumTaskManagerHeight); 86 size->SetSize(640, 480);
99 #endif
100 }
101 virtual void GetMinimumDialogSize(gfx::Size* size) const OVERRIDE {
102 size->SetSize(kMinimumTaskManagerWidth, kMinimumTaskManagerHeight);
103 } 87 }
104 virtual std::string GetDialogArgs() const OVERRIDE { 88 virtual std::string GetDialogArgs() const OVERRIDE {
105 return std::string(); 89 return std::string();
106 } 90 }
107 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { 91 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE {
108 OnCloseDialog(); 92 OnCloseDialog();
109 } 93 }
110 virtual void OnCloseContents(WebContents* source, bool* out_close_dialog) 94 virtual void OnCloseContents(WebContents* source, bool* out_close_dialog)
111 OVERRIDE { 95 OVERRIDE {
112 *out_close_dialog = true; 96 *out_close_dialog = true;
113 } 97 }
114 virtual bool ShouldShowDialogTitle() const OVERRIDE { 98 virtual bool ShouldShowDialogTitle() const OVERRIDE {
115 return true; 99 return true;
116 } 100 }
117 virtual bool HandleContextMenu( 101 virtual bool HandleContextMenu(
118 const content::ContextMenuParams& params) OVERRIDE { 102 const content::ContextMenuParams& params) OVERRIDE {
119 return true; 103 return true;
120 } 104 }
121 #if !defined(TOOLKIT_VIEWS)
122 virtual void StoreDialogSize(const gfx::Size& dialog_size) OVERRIDE { 105 virtual void StoreDialogSize(const gfx::Size& dialog_size) OVERRIDE {
123 // Store the dialog's bounds so that it can be restored with the same bounds 106 // Store the dialog's bounds so that it can be restored with the same bounds
124 // the next time it's opened. 107 // the next time it's opened.
125 if (g_browser_process->local_state()) { 108 if (g_browser_process->local_state()) {
126 DictionaryPrefUpdate update(g_browser_process->local_state(), 109 DictionaryPrefUpdate update(g_browser_process->local_state(),
127 prefs::kTaskManagerWindowPlacement); 110 prefs::kTaskManagerWindowPlacement);
128 DictionaryValue* placement_pref = update.Get(); 111 DictionaryValue* placement_pref = update.Get();
129 placement_pref->SetInteger("width", dialog_size.width()); 112 placement_pref->SetInteger("width", dialog_size.width());
130 placement_pref->SetInteger("height", dialog_size.height()); 113 placement_pref->SetInteger("height", dialog_size.height());
131 } 114 }
132 } 115 }
133 #endif
134 116
135 private: 117 private:
136 void ShowDialog(bool is_background_page_mode); 118 void ShowDialog(bool is_background_page_mode);
137 void OpenHtmlDialog(); 119 void OpenHtmlDialog();
138 120
139 int show_count_; 121 int show_count_;
140 122
141 gfx::NativeWindow window_; 123 gfx::NativeWindow window_;
142 bool is_background_page_mode_; 124 bool is_background_page_mode_;
143 125
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 BrowserThread::PostTask( 196 BrowserThread::PostTask(
215 BrowserThread::UI, FROM_HERE, 197 BrowserThread::UI, FROM_HERE,
216 base::Bind(&TaskManagerDialogImpl::Show, true)); 198 base::Bind(&TaskManagerDialogImpl::Show, true));
217 } 199 }
218 200
219 // static 201 // static
220 bool TaskManagerDialog::UseWebUITaskManager() { 202 bool TaskManagerDialog::UseWebUITaskManager() {
221 return CommandLine::ForCurrentProcess()->HasSwitch( 203 return CommandLine::ForCurrentProcess()->HasSwitch(
222 switches::kWebUITaskManager); 204 switches::kWebUITaskManager);
223 } 205 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/html_dialog_ui.cc ('k') | ui/views/widget/widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698