OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/views/frame/browser_view.h" | 5 #include "chrome/browser/views/frame/browser_view.h" |
6 | 6 |
7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 //////////////////////////////////////////////////////////////////////////////// | 199 //////////////////////////////////////////////////////////////////////////////// |
200 // DownloadInProgressConfirmDialogDelegate | 200 // DownloadInProgressConfirmDialogDelegate |
201 | 201 |
202 class DownloadInProgressConfirmDialogDelegate : public views::DialogDelegate, | 202 class DownloadInProgressConfirmDialogDelegate : public views::DialogDelegate, |
203 public views::View { | 203 public views::View { |
204 public: | 204 public: |
205 explicit DownloadInProgressConfirmDialogDelegate(Browser* browser) | 205 explicit DownloadInProgressConfirmDialogDelegate(Browser* browser) |
206 : browser_(browser) { | 206 : browser_(browser) { |
207 int download_count = browser->profile()->GetDownloadManager()-> | 207 int download_count = browser->profile()->GetDownloadManager()-> |
208 in_progress_count(); | 208 in_progress_count(); |
209 label_ = new views::Label(l10n_util::GetStringF( | 209 |
210 IDS_DOWNLOAD_REMOVE_CONFIRM_TITLE, download_count)); | 210 std::wstring label_text; |
| 211 if (download_count == 1) { |
| 212 label_text = |
| 213 l10n_util::GetString(IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_TITLE); |
| 214 ok_button_text_ = l10n_util::GetString( |
| 215 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL); |
| 216 cancel_button_text_ = l10n_util::GetString( |
| 217 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL); |
| 218 } else { |
| 219 label_text = |
| 220 l10n_util::GetStringF(IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_TITLE, |
| 221 download_count); |
| 222 ok_button_text_ = l10n_util::GetString( |
| 223 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_OK_BUTTON_LABEL); |
| 224 cancel_button_text_ = l10n_util::GetString( |
| 225 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL); |
| 226 } |
| 227 label_ = new views::Label(label_text); |
211 label_->SetMultiLine(true); | 228 label_->SetMultiLine(true); |
212 label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 229 label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
213 label_->set_border(views::Border::CreateEmptyBorder(10, 10, 10, 10)); | 230 label_->set_border(views::Border::CreateEmptyBorder(10, 10, 10, 10)); |
214 AddChildView(label_); | 231 AddChildView(label_); |
215 SetLayoutManager(new views::FillLayout()); | 232 SetLayoutManager(new views::FillLayout()); |
216 } | 233 } |
217 | 234 |
218 ~DownloadInProgressConfirmDialogDelegate() { | 235 ~DownloadInProgressConfirmDialogDelegate() { |
219 } | 236 } |
220 | 237 |
221 // View implementation: | 238 // View implementation: |
222 virtual gfx::Size GetPreferredSize() { | 239 virtual gfx::Size GetPreferredSize() { |
223 const int kContentWidth = 400; | 240 const int kContentWidth = 400; |
224 return gfx::Size(kContentWidth, label_->GetHeightForWidth(kContentWidth)); | 241 return gfx::Size(kContentWidth, label_->GetHeightForWidth(kContentWidth)); |
225 } | 242 } |
226 | 243 |
227 // DialogDelegate implementation: | 244 // DialogDelegate implementation: |
228 virtual int GetDefaultDialogButton() const { | 245 virtual int GetDefaultDialogButton() const { |
229 return MessageBoxFlags::DIALOGBUTTON_CANCEL; | 246 return MessageBoxFlags::DIALOGBUTTON_CANCEL; |
230 } | 247 } |
231 | 248 |
232 virtual std::wstring GetDialogButtonLabel( | 249 virtual std::wstring GetDialogButtonLabel( |
233 MessageBoxFlags::DialogButton button) const { | 250 MessageBoxFlags::DialogButton button) const { |
234 if (button == MessageBoxFlags::DIALOGBUTTON_OK) | 251 if (button == MessageBoxFlags::DIALOGBUTTON_OK) |
235 return l10n_util::GetString(IDS_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL); | 252 return ok_button_text_; |
236 | 253 |
237 DCHECK_EQ(MessageBoxFlags::DIALOGBUTTON_CANCEL, button); | 254 DCHECK_EQ(MessageBoxFlags::DIALOGBUTTON_CANCEL, button); |
238 return l10n_util::GetString( | 255 return cancel_button_text_; |
239 IDS_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL); | |
240 } | 256 } |
241 | 257 |
242 virtual bool Accept() { | 258 virtual bool Accept() { |
243 browser_->InProgressDownloadResponse(true); | 259 browser_->InProgressDownloadResponse(true); |
244 return true; | 260 return true; |
245 } | 261 } |
246 | 262 |
247 virtual bool Cancel() { | 263 virtual bool Cancel() { |
248 browser_->InProgressDownloadResponse(false); | 264 browser_->InProgressDownloadResponse(false); |
249 return true; | 265 return true; |
250 } | 266 } |
251 | 267 |
252 // WindowDelegate implementation: | 268 // WindowDelegate implementation: |
253 virtual bool IsModal() const { return true; } | 269 virtual bool IsModal() const { return true; } |
254 | 270 |
255 virtual views::View* GetContentsView() { | 271 virtual views::View* GetContentsView() { |
256 return this; | 272 return this; |
257 } | 273 } |
258 | 274 |
259 virtual std::wstring GetWindowTitle() const { | 275 virtual std::wstring GetWindowTitle() const { |
260 return l10n_util::GetString(IDS_PRODUCT_NAME); | 276 return l10n_util::GetString(IDS_PRODUCT_NAME); |
261 } | 277 } |
262 | 278 |
263 private: | 279 private: |
264 Browser* browser_; | 280 Browser* browser_; |
265 views::Label* label_; | 281 views::Label* label_; |
266 | 282 |
| 283 std::wstring ok_button_text_; |
| 284 std::wstring cancel_button_text_; |
| 285 |
267 DISALLOW_COPY_AND_ASSIGN(DownloadInProgressConfirmDialogDelegate); | 286 DISALLOW_COPY_AND_ASSIGN(DownloadInProgressConfirmDialogDelegate); |
268 }; | 287 }; |
269 | 288 |
270 /////////////////////////////////////////////////////////////////////////////// | 289 /////////////////////////////////////////////////////////////////////////////// |
271 // BrowserView, public: | 290 // BrowserView, public: |
272 | 291 |
273 // static | 292 // static |
274 void BrowserView::SetShowState(int state) { | 293 void BrowserView::SetShowState(int state) { |
275 explicit_show_state = state; | 294 explicit_show_state = state; |
276 } | 295 } |
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 | 1754 |
1736 // static | 1755 // static |
1737 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 1756 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
1738 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 1757 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
1739 } | 1758 } |
1740 | 1759 |
1741 // static | 1760 // static |
1742 void BrowserList::AllBrowsersClosed() { | 1761 void BrowserList::AllBrowsersClosed() { |
1743 views::Window::CloseAllSecondaryWindows(); | 1762 views::Window::CloseAllSecondaryWindows(); |
1744 } | 1763 } |
OLD | NEW |