diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-09 07:35:32 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-09 07:35:32 +0000 |
commit | 213dac2f0bff9162502fe325b6ebb85a255efcb2 (patch) | |
tree | 3640cb1f19976e38677b8632537d2d41f8444d0f /chrome/browser/ui/views/clear_data_view.cc | |
parent | 6de53d401aa8dc6c7e0a9874c71a95ce88ade50d (diff) | |
download | chromium_src-213dac2f0bff9162502fe325b6ebb85a255efcb2.zip chromium_src-213dac2f0bff9162502fe325b6ebb85a255efcb2.tar.gz chromium_src-213dac2f0bff9162502fe325b6ebb85a255efcb2.tar.bz2 |
Move browser/views to browser/ui/views
TBR=brettw
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/4694005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65508 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/views/clear_data_view.cc')
-rw-r--r-- | chrome/browser/ui/views/clear_data_view.cc | 174 |
1 files changed, 174 insertions, 0 deletions
diff --git a/chrome/browser/ui/views/clear_data_view.cc b/chrome/browser/ui/views/clear_data_view.cc new file mode 100644 index 0000000..8f349bd --- /dev/null +++ b/chrome/browser/ui/views/clear_data_view.cc @@ -0,0 +1,174 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/views/clear_data_view.h" + +#include "app/l10n_util.h" +#include "base/string16.h" +#include "base/utf_string_conversions.h" +#include "chrome/browser/browser.h" +#include "chrome/browser/browser_window.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/profile.h" +#include "chrome/browser/search_engines/template_url_model.h" +#include "chrome/browser/views/clear_browsing_data.h" +#include "chrome/browser/views/clear_server_data.h" +#include "chrome/common/pref_names.h" +#include "gfx/insets.h" +#include "grit/generated_resources.h" +#include "grit/locale_settings.h" +#include "net/url_request/url_request_context.h" +#include "views/background.h" +#include "views/controls/button/checkbox.h" +#include "views/controls/label.h" +#include "views/controls/separator.h" +#include "views/controls/throbber.h" +#include "views/grid_layout.h" +#include "views/standard_layout.h" +#include "views/widget/widget.h" +#include "views/window/dialog_client_view.h" +#include "views/window/window.h" + +using views::GridLayout; + +// The combo box is vertically aligned to the 'time-period' label, which makes +// the combo box look a little too close to the check box above it when we use +// standard layout to separate them. We therefore add a little extra margin to +// the label, giving it a little breathing space. +static const int kExtraMarginForTimePeriodLabel = 3; + +//////////////////////////////////////////////////////////////////////////////// +// ClearDataView, public: + +ClearDataView::ClearDataView(Profile* profile) + : profile_(profile), + clear_server_data_tab_(NULL), + clear_browsing_data_tab_(NULL), + clearing_data_(false) { + DCHECK(profile); + Init(); +} + +void ClearDataView::Init() { + tabs_ = new views::TabbedPane; + + tabs_->SetAccessibleName(l10n_util::GetStringF(IDS_OPTIONS_DIALOG_TITLE, + l10n_util::GetString(IDS_OPTIONS_DIALOG_TITLE))); + AddChildView(tabs_); + + int tab_index = 0; + clear_browsing_data_tab_ = new ClearBrowsingDataView2(profile_, this); + tabs_->AddTabAtIndex(tab_index++, + l10n_util::GetString(IDS_CLEAR_CHROME_DATA_TAB_LABEL), + clear_browsing_data_tab_, false); + clear_server_data_tab_ = new ClearServerDataView(profile_, this); + tabs_->AddTabAtIndex(tab_index++, + l10n_util::GetString(IDS_CLEAR_OTHER_DATA_TAB_LABEL), + clear_server_data_tab_, false); + + tabs_->SelectTabAt(static_cast<int>(0)); +} + +void ClearDataView::StartClearingBrowsingData() { + // Only one clear can happen at a time + clear_server_data_tab_->SetAllowClear(false); + clearing_data_ = true; + window()->EnableClose(false); + GetDialogClientView()->UpdateDialogButtons(); +} + +void ClearDataView::StopClearingBrowsingData() { + window()->Close(); +} + +void ClearDataView::StartClearingServerData() { + // Only one clear can happen at a time + clear_browsing_data_tab_->SetAllowClear(false); + clearing_data_ = true; + window()->EnableClose(false); + GetDialogClientView()->UpdateDialogButtons(); +} + +void ClearDataView::SucceededClearingServerData() { + window()->Close(); +} + +void ClearDataView::FailedClearingServerData() { + clear_browsing_data_tab_->SetAllowClear(true); + clearing_data_ = false; + window()->EnableClose(false); + GetDialogClientView()->UpdateDialogButtons(); +} + +//////////////////////////////////////////////////////////////////////////////// +// ClearDataView, views::View implementation: + +gfx::Size ClearDataView::GetPreferredSize() { + gfx::Size size(tabs_->GetPreferredSize()); + size.Enlarge(2 * kDialogPadding, 2 * kDialogPadding); + return size; +} + +void ClearDataView::Layout() { + tabs_->SetBounds(kDialogPadding, kDialogPadding, + width() - (2 * kDialogPadding), + height() - (2 * kDialogPadding)); +} + +//////////////////////////////////////////////////////////////////////////////// +// ClearDataView, views::DialogDelegate implementation: + +int ClearDataView::GetDefaultDialogButton() const { + return MessageBoxFlags::DIALOGBUTTON_NONE; +} + +std::wstring ClearDataView::GetDialogButtonLabel( + MessageBoxFlags::DialogButton button) const { + DCHECK(button == MessageBoxFlags::DIALOGBUTTON_CANCEL); + return l10n_util::GetString(IDS_CANCEL); +} + +int ClearDataView::GetDialogButtons() const { + return MessageBoxFlags::DIALOGBUTTON_CANCEL; +} + + +bool ClearDataView::IsDialogButtonEnabled( + MessageBoxFlags::DialogButton button) const { + + return !clearing_data_; +} + +bool ClearDataView::CanResize() const { + return false; +} + +bool ClearDataView::CanMaximize() const { + return false; +} + +bool ClearDataView::IsAlwaysOnTop() const { + return false; +} + +bool ClearDataView::HasAlwaysOnTopMenu() const { + return false; +} + +bool ClearDataView::IsModal() const { + return true; +} + +std::wstring ClearDataView::GetWindowTitle() const { + return l10n_util::GetString(IDS_CLEAR_BROWSING_DATA_TITLE); +} + +views::View* ClearDataView::GetContentsView() { + return this; +} + +views::View* ClearDataView::GetInitiallyFocusedView() { + return GetDialogClientView()->cancel_button(); +} + |