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

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: review fix 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 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 #define MINIMUM_TASKMANAGER_WIDTH 640
James Hawkins 2012/03/14 17:39:25 Use constants for values like this.
yoshiki 2012/03/15 08:35:07 Done.
33 #define MINIMUM_TASKMANAGER_HEIGHT 480
34
32 using content::BrowserThread; 35 using content::BrowserThread;
33 using content::WebContents; 36 using content::WebContents;
34 using content::WebUIMessageHandler; 37 using content::WebUIMessageHandler;
35 38
36 class TaskManagerDialogImpl : public HtmlDialogUIDelegate { 39 class TaskManagerDialogImpl : public HtmlDialogUIDelegate {
37 public: 40 public:
38 TaskManagerDialogImpl(); 41 TaskManagerDialogImpl();
39 42
40 static void Show(bool is_background_page_mode); 43 static void Show(bool is_background_page_mode);
41 static TaskManagerDialogImpl* GetInstance(); 44 static TaskManagerDialogImpl* GetInstance();
42 45
43 protected: 46 protected:
44 friend struct DefaultSingletonTraits<TaskManagerDialogImpl>; 47 friend struct DefaultSingletonTraits<TaskManagerDialogImpl>;
45 virtual ~TaskManagerDialogImpl(); 48 virtual ~TaskManagerDialogImpl();
46 49
47 void OnCloseDialog(); 50 void OnCloseDialog();
48 51
49 // Overridden from HtmlDialogUIDelegate: 52 // Overridden from HtmlDialogUIDelegate:
50 virtual ui::ModalType GetDialogModalType() const OVERRIDE { 53 virtual ui::ModalType GetDialogModalType() const OVERRIDE {
51 return ui::MODAL_TYPE_NONE; 54 return ui::MODAL_TYPE_NONE;
52 } 55 }
53 virtual string16 GetDialogTitle() const OVERRIDE { 56 virtual string16 GetDialogTitle() const OVERRIDE {
54 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_TITLE); 57 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_TITLE);
55 } 58 }
59 virtual std::string GetDialogName() const OVERRIDE {
60 return prefs::kTaskManagerWindowPlacement;
61 }
56 virtual GURL GetDialogContentURL() const OVERRIDE { 62 virtual GURL GetDialogContentURL() const OVERRIDE {
57 std::string url_string(chrome::kChromeUITaskManagerURL); 63 std::string url_string(chrome::kChromeUITaskManagerURL);
58 url_string += "?"; 64 url_string += "?";
59 if (browser_defaults::kShowCancelButtonInTaskManager) 65 if (browser_defaults::kShowCancelButtonInTaskManager)
60 url_string += "showclose=1&"; 66 url_string += "showclose=1&";
61 if (browser_defaults::kShowHtmlTitleBarInTaskManager) 67 if (browser_defaults::kShowHtmlTitleBarInTaskManager)
62 url_string += "showtitle=1&"; 68 url_string += "showtitle=1&";
63 if (is_background_page_mode_) 69 if (is_background_page_mode_)
64 url_string += "background=1"; 70 url_string += "background=1";
65 return GURL(url_string); 71 return GURL(url_string);
66 } 72 }
67 virtual void GetWebUIMessageHandlers( 73 virtual void GetWebUIMessageHandlers(
68 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE { 74 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE {
69 } 75 }
70 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE { 76 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE {
77 #if !defined(TOOLKIT_VIEWS)
71 // If dialog's bounds are previously saved, use them. 78 // If dialog's bounds are previously saved, use them.
72 if (g_browser_process->local_state()) { 79 if (g_browser_process->local_state()) {
73 const DictionaryValue* placement_pref = 80 const DictionaryValue* placement_pref =
74 g_browser_process->local_state()->GetDictionary( 81 g_browser_process->local_state()->GetDictionary(
75 prefs::kTaskManagerWindowPlacement); 82 prefs::kTaskManagerWindowPlacement);
76 int width, height; 83 int width, height;
77 if (placement_pref && 84 if (placement_pref &&
78 placement_pref->GetInteger("width", &width) && 85 placement_pref->GetInteger("width", &width) &&
79 placement_pref->GetInteger("height", &height)) { 86 placement_pref->GetInteger("height", &height)) {
80 size->SetSize(std::max(1, width), std::max(1, height)); 87 size->SetSize(std::max(1, width), std::max(1, height));
81 return; 88 return;
82 } 89 }
83 } 90 }
84 91
85 // Otherwise set default size. 92 // Otherwise set default size.
86 size->SetSize(640, 480); 93 size->SetSize(MINIMUM_TASKMANAGER_WIDTH, MINIMUM_TASKMANAGER_HEIGHT);
94 #endif
95 }
96 virtual void GetMinimumDialogSize(gfx::Size* size) const OVERRIDE {
97 size->SetSize(MINIMUM_TASKMANAGER_WIDTH, MINIMUM_TASKMANAGER_HEIGHT);
87 } 98 }
88 virtual std::string GetDialogArgs() const OVERRIDE { 99 virtual std::string GetDialogArgs() const OVERRIDE {
89 return std::string(); 100 return std::string();
90 } 101 }
91 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { 102 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE {
92 OnCloseDialog(); 103 OnCloseDialog();
93 } 104 }
94 virtual void OnCloseContents(WebContents* source, bool* out_close_dialog) 105 virtual void OnCloseContents(WebContents* source, bool* out_close_dialog)
95 OVERRIDE { 106 OVERRIDE {
96 *out_close_dialog = true; 107 *out_close_dialog = true;
97 } 108 }
98 virtual bool ShouldShowDialogTitle() const OVERRIDE { 109 virtual bool ShouldShowDialogTitle() const OVERRIDE {
99 return false; 110 return false;
100 } 111 }
101 virtual bool HandleContextMenu( 112 virtual bool HandleContextMenu(
102 const content::ContextMenuParams& params) OVERRIDE { 113 const content::ContextMenuParams& params) OVERRIDE {
103 return true; 114 return true;
104 } 115 }
116 #if !defined(TOOLKIT_VIEWS)
105 virtual void StoreDialogSize(const gfx::Size& dialog_size) OVERRIDE { 117 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 118 // Store the dialog's bounds so that it can be restored with the same bounds
107 // the next time it's opened. 119 // the next time it's opened.
108 if (g_browser_process->local_state()) { 120 if (g_browser_process->local_state()) {
109 DictionaryPrefUpdate update(g_browser_process->local_state(), 121 DictionaryPrefUpdate update(g_browser_process->local_state(),
110 prefs::kTaskManagerWindowPlacement); 122 prefs::kTaskManagerWindowPlacement);
111 DictionaryValue* placement_pref = update.Get(); 123 DictionaryValue* placement_pref = update.Get();
112 placement_pref->SetInteger("width", dialog_size.width()); 124 placement_pref->SetInteger("width", dialog_size.width());
113 placement_pref->SetInteger("height", dialog_size.height()); 125 placement_pref->SetInteger("height", dialog_size.height());
114 } 126 }
115 } 127 }
128 #endif
116 129
117 private: 130 private:
118 void ShowDialog(bool is_background_page_mode); 131 void ShowDialog(bool is_background_page_mode);
119 void OpenHtmlDialog(); 132 void OpenHtmlDialog();
120 133
121 int show_count_; 134 int show_count_;
122 135
123 gfx::NativeWindow window_; 136 gfx::NativeWindow window_;
124 bool is_background_page_mode_; 137 bool is_background_page_mode_;
125 138
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 BrowserThread::PostTask( 209 BrowserThread::PostTask(
197 BrowserThread::UI, FROM_HERE, 210 BrowserThread::UI, FROM_HERE,
198 base::Bind(&TaskManagerDialogImpl::Show, true)); 211 base::Bind(&TaskManagerDialogImpl::Show, true));
199 } 212 }
200 213
201 // static 214 // static
202 bool TaskManagerDialog::UseWebUITaskManager() { 215 bool TaskManagerDialog::UseWebUITaskManager() {
203 return CommandLine::ForCurrentProcess()->HasSwitch( 216 return CommandLine::ForCurrentProcess()->HasSwitch(
204 switches::kWebUITaskManager); 217 switches::kWebUITaskManager);
205 } 218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698