| 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 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
| 11 #include "chrome/browser/app_modal_dialog_queue.h" | 11 #include "chrome/browser/app_modal_dialog_queue.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_utils.h" | 12 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 13 #include "chrome/browser/browser.h" | 13 #include "chrome/browser/browser.h" |
| 14 #include "chrome/browser/browser_list.h" | 14 #include "chrome/browser/browser_list.h" |
| 15 #include "chrome/browser/download/download_manager.h" |
| 15 #include "chrome/browser/encoding_menu_controller_delegate.h" | 16 #include "chrome/browser/encoding_menu_controller_delegate.h" |
| 16 #include "chrome/browser/find_bar_controller.h" | 17 #include "chrome/browser/find_bar_controller.h" |
| 17 #include "chrome/browser/view_ids.h" | 18 #include "chrome/browser/view_ids.h" |
| 18 #include "chrome/browser/views/about_chrome_view.h" | 19 #include "chrome/browser/views/about_chrome_view.h" |
| 19 #include "chrome/browser/views/bookmark_bar_view.h" | 20 #include "chrome/browser/views/bookmark_bar_view.h" |
| 20 #include "chrome/browser/views/bookmark_bubble_view.h" | 21 #include "chrome/browser/views/bookmark_bubble_view.h" |
| 21 #include "chrome/browser/views/bookmark_manager_view.h" | 22 #include "chrome/browser/views/bookmark_manager_view.h" |
| 22 #include "chrome/browser/views/bug_report_view.h" | 23 #include "chrome/browser/views/bug_report_view.h" |
| 23 #include "chrome/browser/views/clear_browsing_data.h" | 24 #include "chrome/browser/views/clear_browsing_data.h" |
| 24 #include "chrome/browser/views/download_shelf_view.h" | 25 #include "chrome/browser/views/download_shelf_view.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 45 #include "chrome/common/drag_drop_types.h" | 46 #include "chrome/common/drag_drop_types.h" |
| 46 #include "chrome/common/gfx/chrome_canvas.h" | 47 #include "chrome/common/gfx/chrome_canvas.h" |
| 47 #include "chrome/common/l10n_util.h" | 48 #include "chrome/common/l10n_util.h" |
| 48 #include "chrome/common/notification_service.h" | 49 #include "chrome/common/notification_service.h" |
| 49 #include "chrome/common/os_exchange_data.h" | 50 #include "chrome/common/os_exchange_data.h" |
| 50 #include "chrome/common/pref_names.h" | 51 #include "chrome/common/pref_names.h" |
| 51 #include "chrome/common/pref_service.h" | 52 #include "chrome/common/pref_service.h" |
| 52 #include "chrome/common/resource_bundle.h" | 53 #include "chrome/common/resource_bundle.h" |
| 53 #include "chrome/common/win_util.h" | 54 #include "chrome/common/win_util.h" |
| 54 #include "chrome/views/controls/scrollbar/native_scroll_bar.h" | 55 #include "chrome/views/controls/scrollbar/native_scroll_bar.h" |
| 56 #include "chrome/views/fill_layout.h" |
| 55 #include "chrome/views/view.h" | 57 #include "chrome/views/view.h" |
| 56 #include "chrome/views/widget/hwnd_notification_source.h" | 58 #include "chrome/views/widget/hwnd_notification_source.h" |
| 57 #include "chrome/views/widget/root_view.h" | 59 #include "chrome/views/widget/root_view.h" |
| 58 #include "chrome/views/window/non_client_view.h" | 60 #include "chrome/views/window/non_client_view.h" |
| 59 #include "chrome/views/window/window.h" | 61 #include "chrome/views/window/window.h" |
| 60 #include "grit/chromium_strings.h" | 62 #include "grit/chromium_strings.h" |
| 61 #include "grit/generated_resources.h" | 63 #include "grit/generated_resources.h" |
| 62 #include "grit/theme_resources.h" | 64 #include "grit/theme_resources.h" |
| 63 #include "grit/webkit_resources.h" | 65 #include "grit/webkit_resources.h" |
| 64 | 66 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // Returns the BrowserView we're displayed in. Returns NULL if we're not | 184 // Returns the BrowserView we're displayed in. Returns NULL if we're not |
| 183 // currently in a browser view. | 185 // currently in a browser view. |
| 184 BrowserView* GetBrowserView() { | 186 BrowserView* GetBrowserView() { |
| 185 View* browser = GetAncestorWithClassName(kBrowserViewClassName); | 187 View* browser = GetAncestorWithClassName(kBrowserViewClassName); |
| 186 return browser ? static_cast<BrowserView*>(browser) : NULL; | 188 return browser ? static_cast<BrowserView*>(browser) : NULL; |
| 187 } | 189 } |
| 188 | 190 |
| 189 DISALLOW_COPY_AND_ASSIGN(ResizeCorner); | 191 DISALLOW_COPY_AND_ASSIGN(ResizeCorner); |
| 190 }; | 192 }; |
| 191 | 193 |
| 194 //////////////////////////////////////////////////////////////////////////////// |
| 195 // DownloadInProgressConfirmDialogDelegate |
| 196 |
| 197 class DownloadInProgressConfirmDialogDelegate : public views::DialogDelegate, |
| 198 public views::View { |
| 199 public: |
| 200 explicit DownloadInProgressConfirmDialogDelegate(Browser* browser) |
| 201 : browser_(browser) { |
| 202 int download_count = browser->profile()->GetDownloadManager()-> |
| 203 in_progress_count(); |
| 204 label_ = new views::Label(l10n_util::GetStringF( |
| 205 IDS_DOWNLOAD_REMOVE_CONFIRM_TITLE, download_count)); |
| 206 label_->SetMultiLine(true); |
| 207 label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 208 label_->set_border(views::Border::CreateEmptyBorder(10, 10, 10, 10)); |
| 209 AddChildView(label_); |
| 210 SetParentOwned(false); |
| 211 SetLayoutManager(new views::FillLayout()); |
| 212 } |
| 213 |
| 214 // View implementation: |
| 215 virtual gfx::Size GetPreferredSize() { |
| 216 const int kContentWidth = 400; |
| 217 return gfx::Size(kContentWidth, label_->GetHeightForWidth(kContentWidth)); |
| 218 } |
| 219 |
| 220 // DialogDelegate implementation: |
| 221 virtual int GetDefaultDialogButton() const { |
| 222 return DIALOGBUTTON_CANCEL; |
| 223 } |
| 224 |
| 225 virtual std::wstring GetDialogButtonLabel(DialogButton button) const { |
| 226 if (button == DIALOGBUTTON_OK) |
| 227 return l10n_util::GetString(IDS_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL); |
| 228 |
| 229 DCHECK_EQ(DIALOGBUTTON_CANCEL, button); |
| 230 return l10n_util::GetString( |
| 231 IDS_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL); |
| 232 } |
| 233 |
| 234 virtual bool Accept() { |
| 235 browser_->InProgressDownloadResponse(true); |
| 236 return true; |
| 237 } |
| 238 |
| 239 virtual bool Cancel() { |
| 240 browser_->InProgressDownloadResponse(false); |
| 241 return true; |
| 242 } |
| 243 |
| 244 virtual void DeleteDelegate() { |
| 245 delete this; |
| 246 } |
| 247 |
| 248 // WindowDelegate implementation: |
| 249 virtual bool IsModal() const { return true; } |
| 250 |
| 251 virtual views::View* GetContentsView() { |
| 252 return this; |
| 253 } |
| 254 |
| 255 private: |
| 256 Browser* browser_; |
| 257 views::Label* label_; |
| 258 |
| 259 DISALLOW_COPY_AND_ASSIGN(DownloadInProgressConfirmDialogDelegate); |
| 260 }; |
| 192 | 261 |
| 193 /////////////////////////////////////////////////////////////////////////////// | 262 /////////////////////////////////////////////////////////////////////////////// |
| 194 // BrowserView, public: | 263 // BrowserView, public: |
| 195 | 264 |
| 196 // static | 265 // static |
| 197 void BrowserView::SetShowState(int state) { | 266 void BrowserView::SetShowState(int state) { |
| 198 explicit_show_state = state; | 267 explicit_show_state = state; |
| 199 } | 268 } |
| 200 | 269 |
| 201 BrowserView::BrowserView(Browser* browser) | 270 BrowserView::BrowserView(Browser* browser) |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 } | 880 } |
| 812 | 881 |
| 813 void BrowserView::ShowSelectProfileDialog() { | 882 void BrowserView::ShowSelectProfileDialog() { |
| 814 SelectProfileDialog::RunDialog(); | 883 SelectProfileDialog::RunDialog(); |
| 815 } | 884 } |
| 816 | 885 |
| 817 void BrowserView::ShowNewProfileDialog() { | 886 void BrowserView::ShowNewProfileDialog() { |
| 818 NewProfileDialog::RunDialog(); | 887 NewProfileDialog::RunDialog(); |
| 819 } | 888 } |
| 820 | 889 |
| 890 void BrowserView::ConfirmBrowserCloseWithPendingDownloads() { |
| 891 DownloadInProgressConfirmDialogDelegate* delegate = |
| 892 new DownloadInProgressConfirmDialogDelegate(browser_.get()); |
| 893 views::Window::CreateChromeWindow(GetWidget()->GetNativeView(), gfx::Rect(), |
| 894 delegate)->Show(); |
| 895 } |
| 896 |
| 821 void BrowserView::ShowHTMLDialog(HtmlDialogUIDelegate* delegate, | 897 void BrowserView::ShowHTMLDialog(HtmlDialogUIDelegate* delegate, |
| 822 void* parent_window) { | 898 void* parent_window) { |
| 823 HWND parent_hwnd = reinterpret_cast<HWND>(parent_window); | 899 HWND parent_hwnd = reinterpret_cast<HWND>(parent_window); |
| 824 parent_hwnd = parent_hwnd ? parent_hwnd : GetWidget()->GetNativeView(); | 900 parent_hwnd = parent_hwnd ? parent_hwnd : GetWidget()->GetNativeView(); |
| 825 HtmlDialogView* html_view = new HtmlDialogView(browser_.get(), | 901 HtmlDialogView* html_view = new HtmlDialogView(browser_.get(), |
| 826 browser_->profile(), | 902 browser_->profile(), |
| 827 delegate); | 903 delegate); |
| 828 views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), html_view); | 904 views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), html_view); |
| 829 html_view->InitDialog(); | 905 html_view->InitDialog(); |
| 830 html_view->window()->Show(); | 906 html_view->window()->Show(); |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 1674 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 1599 BrowserView* browser_view = new BrowserView(browser); | 1675 BrowserView* browser_view = new BrowserView(browser); |
| 1600 (new BrowserFrame(browser_view))->Init(); | 1676 (new BrowserFrame(browser_view))->Init(); |
| 1601 return browser_view; | 1677 return browser_view; |
| 1602 } | 1678 } |
| 1603 | 1679 |
| 1604 // static | 1680 // static |
| 1605 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 1681 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 1606 return new FindBarWin(static_cast<BrowserView*>(browser->window())); | 1682 return new FindBarWin(static_cast<BrowserView*>(browser->window())); |
| 1607 } | 1683 } |
| OLD | NEW |