summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/options
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/views/options')
-rw-r--r--chrome/browser/views/options/advanced_contents_view.cc1725
-rw-r--r--chrome/browser/views/options/advanced_contents_view.h36
-rw-r--r--chrome/browser/views/options/advanced_page_view.cc145
-rw-r--r--chrome/browser/views/options/advanced_page_view.h39
-rw-r--r--chrome/browser/views/options/content_exceptions_table_view.cc33
-rw-r--r--chrome/browser/views/options/content_exceptions_table_view.h24
-rw-r--r--chrome/browser/views/options/content_filter_page_view.cc227
-rw-r--r--chrome/browser/views/options/content_filter_page_view.h42
-rw-r--r--chrome/browser/views/options/content_page_view.cc496
-rw-r--r--chrome/browser/views/options/content_page_view.h110
-rw-r--r--chrome/browser/views/options/content_settings_window_view.cc210
-rw-r--r--chrome/browser/views/options/content_settings_window_view.h83
-rw-r--r--chrome/browser/views/options/cookie_filter_page_view.cc116
-rw-r--r--chrome/browser/views/options/cookie_filter_page_view.h43
-rw-r--r--chrome/browser/views/options/cookies_view.cc397
-rw-r--r--chrome/browser/views/options/cookies_view.h152
-rw-r--r--chrome/browser/views/options/exception_editor_view.cc175
-rw-r--r--chrome/browser/views/options/exception_editor_view.h107
-rw-r--r--chrome/browser/views/options/exceptions_page_view.cc193
-rw-r--r--chrome/browser/views/options/exceptions_page_view.h70
-rw-r--r--chrome/browser/views/options/exceptions_view.cc275
-rw-r--r--chrome/browser/views/options/exceptions_view.h108
-rw-r--r--chrome/browser/views/options/fonts_languages_window_view.cc134
-rw-r--r--chrome/browser/views/options/fonts_languages_window_view.h69
-rw-r--r--chrome/browser/views/options/fonts_page_view.cc435
-rw-r--r--chrome/browser/views/options/fonts_page_view.h125
-rw-r--r--chrome/browser/views/options/general_page_view.cc883
-rw-r--r--chrome/browser/views/options/general_page_view.h165
-rw-r--r--chrome/browser/views/options/languages_page_view.cc579
-rw-r--r--chrome/browser/views/options/languages_page_view.h116
-rw-r--r--chrome/browser/views/options/managed_prefs_banner_view.cc71
-rw-r--r--chrome/browser/views/options/managed_prefs_banner_view.h45
-rw-r--r--chrome/browser/views/options/options_group_view.cc141
-rw-r--r--chrome/browser/views/options/options_group_view.h60
-rw-r--r--chrome/browser/views/options/options_page_view.cc42
-rw-r--r--chrome/browser/views/options/options_page_view.h49
-rw-r--r--chrome/browser/views/options/options_window_view.cc244
-rw-r--r--chrome/browser/views/options/passwords_exceptions_window_view.cc111
-rw-r--r--chrome/browser/views/options/passwords_exceptions_window_view.h62
-rw-r--r--chrome/browser/views/options/passwords_page_view.cc367
-rw-r--r--chrome/browser/views/options/passwords_page_view.h195
-rw-r--r--chrome/browser/views/options/plugin_filter_page_view.cc49
-rw-r--r--chrome/browser/views/options/plugin_filter_page_view.h23
-rw-r--r--chrome/browser/views/options/simple_content_exceptions_view.cc185
-rw-r--r--chrome/browser/views/options/simple_content_exceptions_view.h86
45 files changed, 74 insertions, 8968 deletions
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc
deleted file mode 100644
index b8513b6..0000000
--- a/chrome/browser/views/options/advanced_contents_view.cc
+++ /dev/null
@@ -1,1725 +0,0 @@
-// 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/options/advanced_contents_view.h"
-
-#include <windows.h>
-
-#include <cryptuiapi.h>
-#pragma comment(lib, "cryptui.lib")
-#include <shellapi.h>
-#include <vsstyle.h>
-#include <vssym32.h>
-
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "base/command_line.h"
-#include "base/file_util.h"
-#include "base/i18n/rtl.h"
-#include "base/message_loop.h"
-#include "base/path_service.h"
-#include "base/scoped_callback_factory.h"
-#include "base/thread.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/download/download_manager.h"
-#include "chrome/browser/download/download_prefs.h"
-#include "chrome/browser/gears_integration.h"
-#include "chrome/browser/options_util.h"
-#include "chrome/browser/prefs/pref_member.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/prefs/pref_set_observer.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
-#include "chrome/browser/safe_browsing/safe_browsing_service.h"
-#include "chrome/browser/shell_dialogs.h"
-#include "chrome/browser/show_options_url.h"
-#include "chrome/browser/views/browser_dialogs.h"
-#include "chrome/browser/views/clear_browsing_data.h"
-#include "chrome/browser/views/list_background.h"
-#include "chrome/browser/views/options/content_settings_window_view.h"
-#include "chrome/browser/views/options/fonts_languages_window_view.h"
-#include "chrome/browser/views/restart_message_box.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
-#include "gfx/canvas_skia.h"
-#include "gfx/native_theme_win.h"
-#include "grit/app_resources.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "net/base/ssl_config_service_win.h"
-#include "skia/ext/skia_utils_win.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "views/background.h"
-#include "views/controls/button/checkbox.h"
-#include "views/controls/combobox/combobox.h"
-#include "views/controls/scroll_view.h"
-#include "views/controls/textfield/textfield.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-#include "views/widget/widget.h"
-#include "views/window/window.h"
-
-using views::GridLayout;
-using views::ColumnSet;
-
-namespace {
-
-const int kFileIconSize = 16;
-const int kFileIconVerticalSpacing = 3;
-const int kFileIconHorizontalSpacing = 3;
-const int kFileIconTextFieldSpacing = 3;
-
-////////////////////////////////////////////////////////////////////////////////
-// FileDisplayArea
-
-class FileDisplayArea : public views::View {
- public:
- FileDisplayArea();
- virtual ~FileDisplayArea();
-
- void SetFile(const FilePath& file_path);
-
- // views::View overrides:
- virtual void Paint(gfx::Canvas* canvas);
- virtual void Layout();
- virtual gfx::Size GetPreferredSize();
-
- protected:
- // views::View overrides:
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
-
- private:
- void Init();
-
- views::Textfield* text_field_;
- SkColor text_field_background_color_;
-
- gfx::Rect icon_bounds_;
-
- bool initialized_;
-
- static void InitClass();
- static SkBitmap default_folder_icon_;
-
- DISALLOW_COPY_AND_ASSIGN(FileDisplayArea);
-};
-
-// static
-SkBitmap FileDisplayArea::default_folder_icon_;
-
-FileDisplayArea::FileDisplayArea()
- : text_field_(new views::Textfield),
- text_field_background_color_(0),
- initialized_(false) {
- InitClass();
-}
-
-FileDisplayArea::~FileDisplayArea() {
-}
-
-void FileDisplayArea::SetFile(const FilePath& file_path) {
- // Force file path to have LTR directionality.
- if (base::i18n::IsRTL()) {
- string16 localized_file_path;
- base::i18n::WrapPathWithLTRFormatting(file_path, &localized_file_path);
- text_field_->SetText(UTF16ToWide(localized_file_path));
- } else {
- text_field_->SetText(file_path.ToWStringHack());
- }
-}
-
-void FileDisplayArea::Paint(gfx::Canvas* canvas) {
- HDC dc = canvas->BeginPlatformPaint();
- RECT rect = { 0, 0, width(), height() };
- gfx::NativeTheme::instance()->PaintTextField(
- dc, EP_EDITTEXT, ETS_READONLY, 0, &rect,
- skia::SkColorToCOLORREF(text_field_background_color_), true, true);
- canvas->EndPlatformPaint();
- // Mirror left point for icon_bounds_ to draw icon in RTL locales correctly.
- canvas->DrawBitmapInt(default_folder_icon_,
- MirroredLeftPointForRect(icon_bounds_),
- icon_bounds_.y());
-}
-
-void FileDisplayArea::Layout() {
- icon_bounds_.SetRect(kFileIconHorizontalSpacing, kFileIconVerticalSpacing,
- kFileIconSize, kFileIconSize);
- gfx::Size ps = text_field_->GetPreferredSize();
- text_field_->SetBounds(icon_bounds_.right() + kFileIconTextFieldSpacing,
- (height() - ps.height()) / 2,
- width() - icon_bounds_.right() -
- kFileIconHorizontalSpacing -
- kFileIconTextFieldSpacing, ps.height());
-}
-
-gfx::Size FileDisplayArea::GetPreferredSize() {
- return gfx::Size(kFileIconSize + 2 * kFileIconVerticalSpacing,
- kFileIconSize + 2 * kFileIconHorizontalSpacing);
-}
-
-void FileDisplayArea::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- if (!initialized_ && is_add && GetWidget())
- Init();
-}
-
-void FileDisplayArea::Init() {
- initialized_ = true;
- AddChildView(text_field_);
- text_field_background_color_ =
- gfx::NativeTheme::instance()->GetThemeColorWithDefault(
- gfx::NativeTheme::TEXTFIELD, EP_EDITTEXT, ETS_READONLY,
- TMT_FILLCOLOR, COLOR_3DFACE);
- text_field_->SetReadOnly(true);
- text_field_->RemoveBorder();
- text_field_->SetBackgroundColor(text_field_background_color_);
-}
-
-// static
-void FileDisplayArea::InitClass() {
- static bool initialized = false;
- if (!initialized) {
- // We'd prefer to use base::i18n::IsRTL() to perform the RTL
- // environment check, but it's nonstatic, so, instead, we check whether the
- // locale is RTL.
- bool ui_is_rtl = base::i18n::IsRTL();
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- default_folder_icon_ = *rb.GetBitmapNamed(ui_is_rtl ?
- IDR_FOLDER_CLOSED_RTL :
- IDR_FOLDER_CLOSED);
- initialized = true;
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// AdvancedSection
-// A convenience view for grouping advanced options together into related
-// sections.
-//
-class AdvancedSection : public OptionsPageView {
- public:
- AdvancedSection(Profile* profile, const std::wstring& title);
- virtual ~AdvancedSection() {}
-
- virtual void DidChangeBounds(const gfx::Rect& previous,
- const gfx::Rect& current);
-
- protected:
- // Convenience helpers to add different kinds of ColumnSets for specific
- // types of layout.
- void AddWrappingColumnSet(views::GridLayout* layout, int id);
- void AddDependentTwoColumnSet(views::GridLayout* layout, int id);
- void AddTwoColumnSet(views::GridLayout* layout, int id);
- void AddIndentedColumnSet(views::GridLayout* layout, int id);
-
- // Convenience helpers for adding controls to specific layouts in an
- // aesthetically pleasing way.
- void AddWrappingCheckboxRow(views::GridLayout* layout,
- views::Checkbox* checkbox,
- int id,
- bool related_follows);
- void AddWrappingLabelRow(views::GridLayout* layout,
- views::Label* label,
- int id,
- bool related_follows);
- void AddLabeledTwoColumnRow(views::GridLayout* layout,
- views::Label* label,
- views::View* control,
- bool control_stretches,
- int id,
- bool related_follows);
- void AddTwoColumnRow(views::GridLayout* layout,
- views::View* first,
- views::View* second,
- bool control_stretches, // Whether or not the control
- // expands to fill the width.
- int id,
- int trailing_space);
- void AddLeadingControl(views::GridLayout* layout,
- views::View* control,
- int id,
- bool related_follows);
- void AddIndentedControl(views::GridLayout* layout,
- views::View* control,
- int id,
- bool related_follows);
- void AddSpacing(views::GridLayout* layout, bool related_follows);
-
- // OptionsPageView overrides:
- virtual void InitControlLayout();
-
- // The View that contains the contents of the section.
- views::View* contents_;
-
- private:
- // The section title.
- views::Label* title_label_;
-
- DISALLOW_COPY_AND_ASSIGN(AdvancedSection);
-};
-
-////////////////////////////////////////////////////////////////////////////////
-// AdvancedSection, public:
-
-AdvancedSection::AdvancedSection(Profile* profile,
- const std::wstring& title)
- : contents_(NULL),
- title_label_(new views::Label(title)),
- OptionsPageView(profile) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- gfx::Font title_font =
- rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD);
- title_label_->SetFont(title_font);
-
- SkColor title_color = gfx::NativeTheme::instance()->GetThemeColorWithDefault(
- gfx::NativeTheme::BUTTON, BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR,
- COLOR_WINDOWTEXT);
- title_label_->SetColor(title_color);
-}
-
-void AdvancedSection::DidChangeBounds(const gfx::Rect& previous,
- const gfx::Rect& current) {
- Layout();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// AdvancedSection, protected:
-
-void AdvancedSection::AddWrappingColumnSet(views::GridLayout* layout, int id) {
- ColumnSet* column_set = layout->AddColumnSet(id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
-}
-
-void AdvancedSection::AddDependentTwoColumnSet(views::GridLayout* layout,
- int id) {
- ColumnSet* column_set = layout->AddColumnSet(id);
- column_set->AddPaddingColumn(0, views::Checkbox::GetTextIndent());
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kUnrelatedControlHorizontalSpacing);
-}
-
-void AdvancedSection::AddTwoColumnSet(views::GridLayout* layout, int id) {
- ColumnSet* column_set = layout->AddColumnSet(id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
-}
-
-void AdvancedSection::AddIndentedColumnSet(views::GridLayout* layout, int id) {
- ColumnSet* column_set = layout->AddColumnSet(id);
- column_set->AddPaddingColumn(0, views::Checkbox::GetTextIndent());
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
-}
-
-void AdvancedSection::AddWrappingCheckboxRow(views::GridLayout* layout,
- views::Checkbox* checkbox,
- int id,
- bool related_follows) {
- checkbox->SetMultiLine(true);
- layout->StartRow(0, id);
- layout->AddView(checkbox);
- AddSpacing(layout, related_follows);
-}
-
-void AdvancedSection::AddWrappingLabelRow(views::GridLayout* layout,
- views::Label* label,
- int id,
- bool related_follows) {
- label->SetMultiLine(true);
- label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- layout->StartRow(0, id);
- layout->AddView(label);
- AddSpacing(layout, related_follows);
-}
-
-void AdvancedSection::AddLabeledTwoColumnRow(views::GridLayout* layout,
- views::Label* label,
- views::View* control,
- bool control_stretches,
- int id,
- bool related_follows) {
- label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- AddTwoColumnRow(layout, label, control, control_stretches, id,
- related_follows ?
- kRelatedControlVerticalSpacing : kUnrelatedControlVerticalSpacing);
-}
-
-void AdvancedSection::AddTwoColumnRow(views::GridLayout* layout,
- views::View* first,
- views::View* second,
- bool control_stretches,
- int id,
- int trailing_space) {
- layout->StartRow(0, id);
- layout->AddView(first);
- if (control_stretches) {
- layout->AddView(second);
- } else {
- layout->AddView(second, 1, 1, views::GridLayout::LEADING,
- views::GridLayout::CENTER);
- }
- layout->AddPaddingRow(0, trailing_space);
-}
-
-void AdvancedSection::AddLeadingControl(views::GridLayout* layout,
- views::View* control,
- int id,
- bool related_follows) {
- layout->StartRow(0, id);
- layout->AddView(control, 1, 1, GridLayout::LEADING, GridLayout::CENTER);
- AddSpacing(layout, related_follows);
-}
-
-void AdvancedSection::AddSpacing(views::GridLayout* layout,
- bool related_follows) {
- layout->AddPaddingRow(0, related_follows ? kRelatedControlVerticalSpacing
- : kUnrelatedControlVerticalSpacing);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// AdvancedSection, OptionsPageView overrides:
-
-void AdvancedSection::InitControlLayout() {
- contents_ = new views::View;
-
- GridLayout* layout = new GridLayout(this);
- SetLayoutManager(layout);
-
- const int single_column_layout_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
- const int inset_column_layout_id = 1;
- column_set = layout->AddColumnSet(inset_column_layout_id);
- column_set->AddPaddingColumn(0, kUnrelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, single_column_layout_id);
- layout->AddView(title_label_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, inset_column_layout_id);
- layout->AddView(contents_);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// PrivacySection
-
-class PrivacySection : public AdvancedSection,
- public views::ButtonListener,
- public views::LinkController {
- public:
- explicit PrivacySection(Profile* profile);
- virtual ~PrivacySection() {}
-
- // Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // Overridden from views::LinkController:
- virtual void LinkActivated(views::Link* source, int event_flags);
-
- protected:
- // OptionsPageView overrides:
- virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::string* pref_name);
-
- private:
- // Controls for this section:
- views::NativeButton* content_settings_button_;
- views::NativeButton* clear_data_button_;
- views::Label* section_description_label_;
- views::Checkbox* enable_link_doctor_checkbox_;
- views::Checkbox* enable_suggest_checkbox_;
- views::Checkbox* enable_dns_prefetching_checkbox_;
- views::Checkbox* enable_safe_browsing_checkbox_;
- views::Checkbox* reporting_enabled_checkbox_;
- views::Link* learn_more_link_;
-
- // Preferences for this section:
- BooleanPrefMember alternate_error_pages_;
- BooleanPrefMember use_suggest_;
- BooleanPrefMember dns_prefetch_enabled_;
- BooleanPrefMember safe_browsing_;
- BooleanPrefMember enable_metrics_recording_;
-
- void ResolveMetricsReportingEnabled();
-
- DISALLOW_COPY_AND_ASSIGN(PrivacySection);
-};
-
-PrivacySection::PrivacySection(Profile* profile)
- : content_settings_button_(NULL),
- clear_data_button_(NULL),
- section_description_label_(NULL),
- enable_link_doctor_checkbox_(NULL),
- enable_suggest_checkbox_(NULL),
- enable_dns_prefetching_checkbox_(NULL),
- enable_safe_browsing_checkbox_(NULL),
- reporting_enabled_checkbox_(NULL),
- learn_more_link_(NULL),
- AdvancedSection(profile,
- l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY)) {
-}
-
-void PrivacySection::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (sender == enable_link_doctor_checkbox_) {
- bool enabled = enable_link_doctor_checkbox_->checked();
- UserMetricsRecordAction(UserMetricsAction(enabled ?
- "Options_LinkDoctorCheckbox_Enable" :
- "Options_LinkDoctorCheckbox_Disable"),
- profile()->GetPrefs());
- alternate_error_pages_.SetValue(enabled);
- } else if (sender == enable_suggest_checkbox_) {
- bool enabled = enable_suggest_checkbox_->checked();
- UserMetricsRecordAction(UserMetricsAction(enabled ?
- "Options_UseSuggestCheckbox_Enable" :
- "Options_UseSuggestCheckbox_Disable"),
- profile()->GetPrefs());
- use_suggest_.SetValue(enabled);
- } else if (sender == enable_dns_prefetching_checkbox_) {
- bool enabled = enable_dns_prefetching_checkbox_->checked();
- UserMetricsRecordAction(UserMetricsAction(enabled ?
- "Options_DnsPrefetchCheckbox_Enable" :
- "Options_DnsPrefetchCheckbox_Disable"),
- profile()->GetPrefs());
- dns_prefetch_enabled_.SetValue(enabled);
- } else if (sender == enable_safe_browsing_checkbox_) {
- bool enabled = enable_safe_browsing_checkbox_->checked();
- UserMetricsRecordAction(UserMetricsAction(enabled ?
- "Options_SafeBrowsingCheckbox_Enable" :
- "Options_SafeBrowsingCheckbox_Disable"),
- profile()->GetPrefs());
- safe_browsing_.SetValue(enabled);
- SafeBrowsingService* safe_browsing_service =
- g_browser_process->resource_dispatcher_host()->safe_browsing_service();
- MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
- safe_browsing_service, &SafeBrowsingService::OnEnable, enabled));
- } else if (reporting_enabled_checkbox_ &&
- (sender == reporting_enabled_checkbox_)) {
- bool enabled = reporting_enabled_checkbox_->checked();
- UserMetricsRecordAction(UserMetricsAction(enabled ?
- "Options_MetricsReportingCheckbox_Enable" :
- "Options_MetricsReportingCheckbox_Disable"),
- profile()->GetPrefs());
- ResolveMetricsReportingEnabled();
- if (enabled == reporting_enabled_checkbox_->checked())
- RestartMessageBox::ShowMessageBox(GetWindow()->GetNativeWindow());
- enable_metrics_recording_.SetValue(enabled);
- } else if (sender == content_settings_button_) {
- UserMetricsRecordAction(UserMetricsAction("Options_ContentSettings"), NULL);
- browser::ShowContentSettingsWindow(GetWindow()->GetNativeWindow(),
- CONTENT_SETTINGS_TYPE_DEFAULT, profile());
- } else if (sender == clear_data_button_) {
- UserMetricsRecordAction(UserMetricsAction("Options_ClearData"), NULL);
- views::Window::CreateChromeWindow(
- GetWindow()->GetNativeWindow(),
- gfx::Rect(),
- new ClearBrowsingDataView(profile()))->Show();
- }
-}
-
-void PrivacySection::LinkActivated(views::Link* source, int event_flags) {
- DCHECK(source == learn_more_link_);
- browser::ShowOptionsURL(
- profile(),
- GURL(l10n_util::GetString(IDS_LEARN_MORE_PRIVACY_URL)));
-}
-
-void PrivacySection::InitControlLayout() {
- AdvancedSection::InitControlLayout();
-
- content_settings_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_OPTIONS_PRIVACY_CONTENT_SETTINGS_BUTTON));
- clear_data_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_OPTIONS_PRIVACY_CLEAR_DATA_BUTTON));
- section_description_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_DISABLE_SERVICES));
- enable_link_doctor_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_LINKDOCTOR_PREF));
- enable_link_doctor_checkbox_->set_listener(this);
- enable_suggest_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_SUGGEST_PREF));
- enable_suggest_checkbox_->set_listener(this);
- enable_dns_prefetching_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_NETWORK_DNS_PREFETCH_ENABLED_DESCRIPTION));
- enable_dns_prefetching_checkbox_->set_listener(this);
- enable_safe_browsing_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_SAFEBROWSING_ENABLEPROTECTION));
- enable_safe_browsing_checkbox_->set_listener(this);
-#if defined(GOOGLE_CHROME_BUILD)
- reporting_enabled_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_ENABLE_LOGGING));
- reporting_enabled_checkbox_->SetMultiLine(true);
- reporting_enabled_checkbox_->set_listener(this);
- reporting_enabled_checkbox_->SetVisible(true);
-#endif
- learn_more_link_ = new views::Link(l10n_util::GetString(IDS_LEARN_MORE));
- learn_more_link_->SetController(this);
-
- GridLayout* layout = new GridLayout(contents_);
- contents_->SetLayoutManager(layout);
-
- const int leading_column_set_id = 0;
- AddTwoColumnSet(layout, leading_column_set_id);
- const int single_column_view_set_id = 1;
- AddWrappingColumnSet(layout, single_column_view_set_id);
- const int dependent_labeled_field_set_id = 2;
- AddDependentTwoColumnSet(layout, dependent_labeled_field_set_id);
- const int indented_view_set_id = 3;
- AddIndentedColumnSet(layout, indented_view_set_id);
- const int indented_column_set_id = 4;
- AddIndentedColumnSet(layout, indented_column_set_id);
-
- AddTwoColumnRow(layout, content_settings_button_, clear_data_button_, false,
- leading_column_set_id, kUnrelatedControlLargeVerticalSpacing);
-
- // The description label at the top and label.
- section_description_label_->SetMultiLine(true);
- AddWrappingLabelRow(layout, section_description_label_,
- single_column_view_set_id, true);
- // Learn more link.
- AddLeadingControl(layout, learn_more_link_,
- single_column_view_set_id, true);
-
- // Link doctor.
- AddWrappingCheckboxRow(layout, enable_link_doctor_checkbox_,
- indented_view_set_id, true);
- // Use Suggest service.
- AddWrappingCheckboxRow(layout, enable_suggest_checkbox_,
- indented_view_set_id, true);
- // DNS pre-fetching.
- AddWrappingCheckboxRow(layout, enable_dns_prefetching_checkbox_,
- indented_view_set_id, true);
- // Safe browsing controls.
- AddWrappingCheckboxRow(layout, enable_safe_browsing_checkbox_,
- indented_view_set_id,
- reporting_enabled_checkbox_ != NULL);
- // The "Help make Google Chrome better" checkbox.
- if (reporting_enabled_checkbox_) {
- AddWrappingCheckboxRow(layout, reporting_enabled_checkbox_,
- indented_view_set_id, false);
- }
-
- // Init member prefs so we can update the controls if prefs change.
- alternate_error_pages_.Init(prefs::kAlternateErrorPagesEnabled,
- profile()->GetPrefs(), this);
- use_suggest_.Init(prefs::kSearchSuggestEnabled,
- profile()->GetPrefs(), this);
- dns_prefetch_enabled_.Init(prefs::kDnsPrefetchingEnabled,
- profile()->GetPrefs(), this);
- safe_browsing_.Init(prefs::kSafeBrowsingEnabled, profile()->GetPrefs(), this);
- enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled,
- g_browser_process->local_state(), this);
-}
-
-void PrivacySection::NotifyPrefChanged(const std::string* pref_name) {
- if (!pref_name || *pref_name == prefs::kAlternateErrorPagesEnabled) {
- enable_link_doctor_checkbox_->SetEnabled(
- !alternate_error_pages_.IsManaged());
- enable_link_doctor_checkbox_->SetChecked(
- alternate_error_pages_.GetValue());
- }
- if (!pref_name || *pref_name == prefs::kSearchSuggestEnabled) {
- enable_suggest_checkbox_->SetEnabled(!use_suggest_.IsManaged());
- enable_suggest_checkbox_->SetChecked(use_suggest_.GetValue());
- }
- if (!pref_name || *pref_name == prefs::kDnsPrefetchingEnabled) {
- enable_dns_prefetching_checkbox_->SetEnabled(
- !dns_prefetch_enabled_.IsManaged());
- bool enabled = dns_prefetch_enabled_.GetValue();
- enable_dns_prefetching_checkbox_->SetChecked(enabled);
- }
- if (!pref_name || *pref_name == prefs::kSafeBrowsingEnabled) {
- enable_safe_browsing_checkbox_->SetEnabled(!safe_browsing_.IsManaged());
- enable_safe_browsing_checkbox_->SetChecked(safe_browsing_.GetValue());
- }
- if (reporting_enabled_checkbox_ &&
- (!pref_name || *pref_name == prefs::kMetricsReportingEnabled)) {
- reporting_enabled_checkbox_->SetEnabled(
- !enable_metrics_recording_.IsManaged());
- reporting_enabled_checkbox_->SetChecked(
- enable_metrics_recording_.GetValue());
- ResolveMetricsReportingEnabled();
- }
-}
-
-void PrivacySection::ResolveMetricsReportingEnabled() {
- DCHECK(reporting_enabled_checkbox_);
- bool enabled = reporting_enabled_checkbox_->checked();
-
- enabled = OptionsUtil::ResolveMetricsReportingEnabled(enabled);
-
- reporting_enabled_checkbox_->SetChecked(enabled);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// WebContentSection
-
-class WebContentSection : public AdvancedSection,
- public views::ButtonListener {
- public:
- explicit WebContentSection(Profile* profile);
- virtual ~WebContentSection() {}
-
- // Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- protected:
- // OptionsPageView overrides:
- virtual void InitControlLayout();
-
- private:
- // Controls for this section:
- views::Label* fonts_and_languages_label_;
- views::NativeButton* change_content_fonts_button_;
- views::Label* gears_label_;
- views::NativeButton* gears_settings_button_;
-
- DISALLOW_COPY_AND_ASSIGN(WebContentSection);
-};
-
-WebContentSection::WebContentSection(Profile* profile)
- : fonts_and_languages_label_(NULL),
- change_content_fonts_button_(NULL),
- gears_label_(NULL),
- gears_settings_button_(NULL),
- AdvancedSection(profile,
- l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT)) {
-}
-
-void WebContentSection::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (sender == gears_settings_button_) {
- UserMetricsRecordAction(UserMetricsAction("Options_GearsSettings"), NULL);
- GearsSettingsPressed(GetAncestor(GetWidget()->GetNativeView(), GA_ROOT));
- } else if (sender == change_content_fonts_button_) {
- views::Window::CreateChromeWindow(
- GetWindow()->GetNativeWindow(),
- gfx::Rect(),
- new FontsLanguagesWindowView(profile()))->Show();
- }
-}
-
-void WebContentSection::InitControlLayout() {
- AdvancedSection::InitControlLayout();
-
- if (!base::i18n::IsRTL()) {
- gears_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_GEARSSETTINGS_GROUP_NAME));
- } else {
- // Add an RTL mark so that
- // ":" in "Google Gears:" in Hebrew Chrome is displayed left-most.
- std::wstring gearssetting_group_name =
- l10n_util::GetString(IDS_OPTIONS_GEARSSETTINGS_GROUP_NAME);
- gearssetting_group_name.push_back(
- static_cast<wchar_t>(base::i18n::kRightToLeftMark));
- gears_label_ = new views::Label(gearssetting_group_name);
- }
- gears_settings_button_ = new views::NativeButton(
- this,
- l10n_util::GetString(IDS_OPTIONS_GEARSSETTINGS_CONFIGUREGEARS_BUTTON));
- fonts_and_languages_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_FONTSETTINGS_INFO));
-
- change_content_fonts_button_ = new views::NativeButton(
- this,
- l10n_util::GetString(IDS_OPTIONS_FONTSETTINGS_CONFIGUREFONTS_BUTTON));
-
- GridLayout* layout = new GridLayout(contents_);
- contents_->SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- AddWrappingColumnSet(layout, single_column_view_set_id);
- const int indented_column_set_id = 1;
- AddIndentedColumnSet(layout, indented_column_set_id);
- const int single_double_column_set = 2;
- AddTwoColumnSet(layout, single_double_column_set);
-
- // Fonts and Languages.
- AddWrappingLabelRow(layout, fonts_and_languages_label_,
- single_column_view_set_id,
- true);
- AddLeadingControl(layout, change_content_fonts_button_,
- indented_column_set_id,
- false);
-
- // Gears.
- AddLabeledTwoColumnRow(layout, gears_label_, gears_settings_button_, false,
- single_double_column_set, false);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// SecuritySection
-
-class SecuritySection : public AdvancedSection,
- public views::ButtonListener {
- public:
- explicit SecuritySection(Profile* profile);
- virtual ~SecuritySection() {}
-
- // Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- protected:
- // OptionsPageView overrides:
- virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::string* pref_name);
-
- private:
- // Controls for this section:
- views::Label* ssl_info_label_;
- views::Checkbox* enable_ssl2_checkbox_;
- views::Checkbox* enable_ssl3_checkbox_;
- views::Checkbox* enable_tls1_checkbox_;
- views::Checkbox* check_for_cert_revocation_checkbox_;
- views::Label* manage_certificates_label_;
- views::NativeButton* manage_certificates_button_;
-
- DISALLOW_COPY_AND_ASSIGN(SecuritySection);
-};
-
-SecuritySection::SecuritySection(Profile* profile)
- : ssl_info_label_(NULL),
- enable_ssl2_checkbox_(NULL),
- enable_ssl3_checkbox_(NULL),
- enable_tls1_checkbox_(NULL),
- check_for_cert_revocation_checkbox_(NULL),
- manage_certificates_label_(NULL),
- manage_certificates_button_(NULL),
- AdvancedSection(profile,
- l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY)) {
-}
-
-void SecuritySection::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (sender == enable_ssl2_checkbox_) {
- bool enabled = enable_ssl2_checkbox_->checked();
- if (enabled) {
- UserMetricsRecordAction(UserMetricsAction("Options_SSL2_Enable"), NULL);
- } else {
- UserMetricsRecordAction(UserMetricsAction("Options_SSL2_Disable"), NULL);
- }
- net::SSLConfigServiceWin::SetSSL2Enabled(enabled);
- } else if (sender == enable_ssl3_checkbox_) {
- bool enabled = enable_ssl3_checkbox_->checked();
- if (enabled) {
- UserMetricsRecordAction(UserMetricsAction("Options_SSL3_Enable"), NULL);
- } else {
- UserMetricsRecordAction(UserMetricsAction("Options_SSL3_Disable"), NULL);
- }
- net::SSLConfigServiceWin::SetSSL3Enabled(enabled);
- } else if (sender == enable_tls1_checkbox_) {
- bool enabled = enable_tls1_checkbox_->checked();
- if (enabled) {
- UserMetricsRecordAction(UserMetricsAction("Options_TLS1_Enable"), NULL);
- } else {
- UserMetricsRecordAction(UserMetricsAction("Options_TLS1_Disable"), NULL);
- }
- net::SSLConfigServiceWin::SetTLS1Enabled(enabled);
- } else if (sender == check_for_cert_revocation_checkbox_) {
- bool enabled = check_for_cert_revocation_checkbox_->checked();
- if (enabled) {
- UserMetricsRecordAction(
- UserMetricsAction("Options_CheckCertRevocation_Enable"), NULL);
- } else {
- UserMetricsRecordAction(
- UserMetricsAction("Options_CheckCertRevocation_Disable"), NULL);
- }
- net::SSLConfigServiceWin::SetRevCheckingEnabled(enabled);
- } else if (sender == manage_certificates_button_) {
- UserMetricsRecordAction(UserMetricsAction("Options_ManagerCerts"), NULL);
- CRYPTUI_CERT_MGR_STRUCT cert_mgr = { 0 };
- cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT);
- cert_mgr.hwndParent = GetWindow()->GetNativeWindow();
- ::CryptUIDlgCertMgr(&cert_mgr);
- }
-}
-
-void SecuritySection::InitControlLayout() {
- AdvancedSection::InitControlLayout();
-
- ssl_info_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_SSL_GROUP_DESCRIPTION));
- enable_ssl2_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_SSL_USESSL2));
- enable_ssl2_checkbox_->set_listener(this);
- enable_ssl3_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_SSL_USESSL3));
- enable_ssl3_checkbox_->set_listener(this);
- enable_tls1_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_SSL_USETLS1));
- enable_tls1_checkbox_->set_listener(this);
- check_for_cert_revocation_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_SSL_CHECKREVOCATION));
- check_for_cert_revocation_checkbox_->set_listener(this);
- manage_certificates_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_CERTIFICATES_LABEL));
- manage_certificates_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_OPTIONS_CERTIFICATES_MANAGE_BUTTON));
-
- GridLayout* layout = new GridLayout(contents_);
- contents_->SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- AddWrappingColumnSet(layout, single_column_view_set_id);
- const int dependent_labeled_field_set_id = 1;
- AddDependentTwoColumnSet(layout, dependent_labeled_field_set_id);
- const int double_column_view_set_id = 2;
- AddTwoColumnSet(layout, double_column_view_set_id);
- const int indented_column_set_id = 3;
- AddIndentedColumnSet(layout, indented_column_set_id);
- const int indented_view_set_id = 4;
- AddIndentedColumnSet(layout, indented_view_set_id);
-
- // SSL connection controls and Certificates.
- AddWrappingLabelRow(layout, manage_certificates_label_,
- single_column_view_set_id, true);
- AddLeadingControl(layout, manage_certificates_button_,
- indented_column_set_id, false);
- AddWrappingLabelRow(layout, ssl_info_label_, single_column_view_set_id,
- true);
- AddWrappingCheckboxRow(layout, enable_ssl2_checkbox_,
- indented_column_set_id, true);
- AddWrappingCheckboxRow(layout, enable_ssl3_checkbox_,
- indented_column_set_id, true);
- AddWrappingCheckboxRow(layout, enable_tls1_checkbox_,
- indented_column_set_id, true);
- AddWrappingCheckboxRow(layout, check_for_cert_revocation_checkbox_,
- indented_column_set_id, false);
-}
-
-// This method is called with a null pref_name when the dialog is initialized.
-void SecuritySection::NotifyPrefChanged(const std::string* pref_name) {
- // These SSL options are system settings and stored in the OS.
- if (!pref_name) {
- net::SSLConfig config;
- if (net::SSLConfigServiceWin::GetSSLConfigNow(&config)) {
- enable_ssl2_checkbox_->SetChecked(config.ssl2_enabled);
- enable_ssl3_checkbox_->SetChecked(config.ssl3_enabled);
- enable_tls1_checkbox_->SetChecked(config.tls1_enabled);
- check_for_cert_revocation_checkbox_->SetChecked(
- config.rev_checking_enabled);
- } else {
- enable_ssl2_checkbox_->SetEnabled(false);
- enable_ssl3_checkbox_->SetEnabled(false);
- enable_tls1_checkbox_->SetEnabled(false);
- check_for_cert_revocation_checkbox_->SetEnabled(false);
- }
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NetworkSection
-
-// A helper method that opens the Internet Options control panel dialog with
-// the Connections tab selected.
-class OpenConnectionDialogTask : public Task {
- public:
- OpenConnectionDialogTask() {}
-
- virtual void Run() {
- // Using rundll32 seems better than LaunchConnectionDialog which causes a
- // new dialog to be made for each call. rundll32 uses the same global
- // dialog and it seems to share with the shortcut in control panel.
- FilePath rundll32;
- PathService::Get(base::DIR_SYSTEM, &rundll32);
- rundll32 = rundll32.AppendASCII("rundll32.exe");
-
- FilePath shell32dll;
- PathService::Get(base::DIR_SYSTEM, &shell32dll);
- shell32dll = shell32dll.AppendASCII("shell32.dll");
-
- FilePath inetcpl;
- PathService::Get(base::DIR_SYSTEM, &inetcpl);
- inetcpl = inetcpl.AppendASCII("inetcpl.cpl,,4");
-
- std::wstring args(shell32dll.value());
- args.append(L",Control_RunDLL ");
- args.append(inetcpl.value());
-
- ShellExecute(NULL, L"open", rundll32.value().c_str(), args.c_str(), NULL,
- SW_SHOWNORMAL);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(OpenConnectionDialogTask);
-};
-
-class NetworkSection : public AdvancedSection,
- public views::ButtonListener {
- public:
- explicit NetworkSection(Profile* profile);
- virtual ~NetworkSection() {}
-
- // Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- protected:
- // OptionsPageView overrides:
- virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::string* pref_name);
-
- private:
- // Controls for this section:
- views::Label* change_proxies_label_;
- views::NativeButton* change_proxies_button_;
-
- // Tracks the proxy preferences.
- scoped_ptr<PrefSetObserver> proxy_prefs_;
-
- DISALLOW_COPY_AND_ASSIGN(NetworkSection);
-};
-
-NetworkSection::NetworkSection(Profile* profile)
- : change_proxies_label_(NULL),
- change_proxies_button_(NULL),
- AdvancedSection(profile,
- l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_NETWORK)) {
-}
-
-void NetworkSection::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (sender == change_proxies_button_) {
- UserMetricsRecordAction(UserMetricsAction("Options_ChangeProxies"), NULL);
- base::Thread* thread = g_browser_process->file_thread();
- DCHECK(thread);
- thread->message_loop()->PostTask(FROM_HERE, new OpenConnectionDialogTask);
- }
-}
-
-void NetworkSection::InitControlLayout() {
- AdvancedSection::InitControlLayout();
-
- change_proxies_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_PROXIES_LABEL));
- change_proxies_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON));
-
- GridLayout* layout = new GridLayout(contents_);
- contents_->SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- AddWrappingColumnSet(layout, single_column_view_set_id);
- const int indented_view_set_id = 1;
- AddIndentedColumnSet(layout, indented_view_set_id);
- const int dependent_labeled_field_set_id = 2;
- AddDependentTwoColumnSet(layout, dependent_labeled_field_set_id);
- const int dns_set_id = 3;
- AddDependentTwoColumnSet(layout, dns_set_id);
-
- // Proxy settings.
- AddWrappingLabelRow(layout, change_proxies_label_, single_column_view_set_id,
- true);
- AddLeadingControl(layout, change_proxies_button_, indented_view_set_id,
- false);
-
- proxy_prefs_.reset(PrefSetObserver::CreateProxyPrefSetObserver(
- profile()->GetPrefs(), this));
- NotifyPrefChanged(NULL);
-}
-
-void NetworkSection::NotifyPrefChanged(const std::string* pref_name) {
- if (!pref_name || proxy_prefs_->IsObserved(*pref_name)) {
- change_proxies_button_->SetEnabled(!proxy_prefs_->IsManaged());
- }
-}
-
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-// DownloadSection
-
-class DownloadSection : public AdvancedSection,
- public views::ButtonListener,
- public SelectFileDialog::Listener {
- public:
- explicit DownloadSection(Profile* profile);
- virtual ~DownloadSection() {
- select_file_dialog_->ListenerDestroyed();
- }
-
- // Overridden from views::ButtonListener.
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // SelectFileDialog::Listener implementation.
- virtual void FileSelected(const FilePath& path, int index, void* params);
-
- // OptionsPageView implementation.
- virtual bool CanClose() const;
-
- protected:
- // OptionsPageView overrides.
- virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::string* pref_name);
-
- private:
- // Controls for this section.
- views::Label* download_file_location_label_;
- FileDisplayArea* download_default_download_location_display_;
- views::NativeButton* download_browse_button_;
- views::Checkbox* download_ask_for_save_location_checkbox_;
- scoped_refptr<SelectFileDialog> select_file_dialog_;
- views::Label* reset_file_handlers_label_;
- views::NativeButton* reset_file_handlers_button_;
-
- // Pref members.
- FilePathPrefMember default_download_location_;
- BooleanPrefMember ask_for_save_location_;
-
- // Updates the directory displayed in the default download location view with
- // the current value of the pref.
- void UpdateDownloadDirectoryDisplay();
-
- StringPrefMember auto_open_files_;
-
- DISALLOW_COPY_AND_ASSIGN(DownloadSection);
-};
-
-DownloadSection::DownloadSection(Profile* profile)
- : download_file_location_label_(NULL),
- download_default_download_location_display_(NULL),
- download_browse_button_(NULL),
- download_ask_for_save_location_checkbox_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- select_file_dialog_(SelectFileDialog::Create(this))),
- reset_file_handlers_label_(NULL),
- reset_file_handlers_button_(NULL),
- AdvancedSection(profile,
- l10n_util::GetString(IDS_OPTIONS_DOWNLOADLOCATION_GROUP_NAME)) {
-}
-
-void DownloadSection::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (sender == download_browse_button_) {
- const std::wstring dialog_title =
- l10n_util::GetString(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE);
- select_file_dialog_->SelectFile(SelectFileDialog::SELECT_FOLDER,
- dialog_title,
- profile()->GetPrefs()->GetFilePath(
- prefs::kDownloadDefaultDirectory),
- NULL, 0, std::wstring(),
- GetWindow()->GetNativeWindow(),
- NULL);
- } else if (sender == download_ask_for_save_location_checkbox_) {
- bool enabled = download_ask_for_save_location_checkbox_->checked();
- if (enabled) {
- UserMetricsRecordAction(
- UserMetricsAction("Options_AskForSaveLocation_Enable"),
- profile()->GetPrefs());
- } else {
- UserMetricsRecordAction(
- UserMetricsAction("Options_AskForSaveLocation_Disable"),
- profile()->GetPrefs());
- }
- ask_for_save_location_.SetValue(enabled);
- } else if (sender == reset_file_handlers_button_) {
- profile()->GetDownloadManager()->download_prefs()->ResetAutoOpen();
- UserMetricsRecordAction(UserMetricsAction("Options_ResetAutoOpenFiles"),
- profile()->GetPrefs());
- }
-}
-
-void DownloadSection::FileSelected(const FilePath& path,
- int index, void* params) {
- UserMetricsRecordAction(UserMetricsAction("Options_SetDownloadDirectory"),
- profile()->GetPrefs());
- default_download_location_.SetValue(path);
- // We need to call this manually here since because we're setting the value
- // through the pref member which avoids notifying the listener that set the
- // value.
- UpdateDownloadDirectoryDisplay();
-}
-
-bool DownloadSection::CanClose() const {
- return !select_file_dialog_->IsRunning(GetWindow()->GetNativeWindow());
-}
-
-void DownloadSection::InitControlLayout() {
- AdvancedSection::InitControlLayout();
-
- // Layout the download components.
- download_file_location_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE));
- download_default_download_location_display_ = new FileDisplayArea;
- download_browse_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_BUTTON));
-
- download_ask_for_save_location_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_DOWNLOADLOCATION_ASKFORSAVELOCATION));
- download_ask_for_save_location_checkbox_->set_listener(this);
- download_ask_for_save_location_checkbox_->SetMultiLine(true);
- reset_file_handlers_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_AUTOOPENFILETYPES_INFO));
- reset_file_handlers_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_OPTIONS_AUTOOPENFILETYPES_RESETTODEFAULT));
-
- GridLayout* layout = new GridLayout(contents_);
- contents_->SetLayoutManager(layout);
-
- // Download location label.
- const int single_column_view_set_id = 0;
- AddWrappingColumnSet(layout, single_column_view_set_id);
- AddWrappingLabelRow(layout, download_file_location_label_,
- single_column_view_set_id, true);
-
- // Download location control.
- const int double_column_view_set_id = 1;
- ColumnSet* column_set = layout->AddColumnSet(double_column_view_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kUnrelatedControlHorizontalSpacing);
- layout->StartRow(0, double_column_view_set_id);
- layout->AddView(download_default_download_location_display_, 1, 1,
- GridLayout::FILL, GridLayout::CENTER);
- layout->AddView(download_browse_button_);
- AddSpacing(layout, true);
-
- // Save location checkbox layout.
- const int indented_view_set_id = 2;
- AddIndentedColumnSet(layout, indented_view_set_id);
- AddWrappingCheckboxRow(layout, download_ask_for_save_location_checkbox_,
- indented_view_set_id, false);
-
- // Reset file handlers layout.
- AddWrappingLabelRow(layout, reset_file_handlers_label_,
- single_column_view_set_id, true);
- AddLeadingControl(layout, reset_file_handlers_button_,
- indented_view_set_id,
- false);
-
- // Init member prefs so we can update the controls if prefs change.
- default_download_location_.Init(prefs::kDownloadDefaultDirectory,
- profile()->GetPrefs(), this);
- ask_for_save_location_.Init(prefs::kPromptForDownload,
- profile()->GetPrefs(), this);
- auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, profile()->GetPrefs(),
- this);
-}
-
-void DownloadSection::NotifyPrefChanged(const std::string* pref_name) {
- if (!pref_name || *pref_name == prefs::kDownloadDefaultDirectory)
- UpdateDownloadDirectoryDisplay();
-
- if (!pref_name || *pref_name == prefs::kPromptForDownload) {
- download_ask_for_save_location_checkbox_->SetChecked(
- ask_for_save_location_.GetValue());
- }
-
- if (!pref_name || *pref_name == prefs::kDownloadExtensionsToOpen) {
- bool enabled =
- profile()->GetDownloadManager()->download_prefs()->IsAutoOpenUsed();
- reset_file_handlers_label_->SetEnabled(enabled);
- reset_file_handlers_button_->SetEnabled(enabled);
- }
-}
-
-void DownloadSection::UpdateDownloadDirectoryDisplay() {
- download_default_download_location_display_->SetFile(
- default_download_location_.GetValue());
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// TranslateSection
-
-class TranslateSection : public AdvancedSection,
- public views::ButtonListener {
- public:
- explicit TranslateSection(Profile* profile);
- virtual ~TranslateSection() {}
-
- // Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- protected:
- // OptionsPageView overrides:
- virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::string* pref_name);
-
- private:
- // Control for this section:
- views::Checkbox* enable_translate_checkbox_;
-
- // Preferences for this section:
- BooleanPrefMember enable_translate_;
-
- DISALLOW_COPY_AND_ASSIGN(TranslateSection);
-};
-
-TranslateSection::TranslateSection(Profile* profile)
- : enable_translate_checkbox_(NULL),
- AdvancedSection(profile,
- l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_TRANSLATE)) {
-}
-
-void TranslateSection::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- DCHECK(sender == enable_translate_checkbox_);
- bool enabled = enable_translate_checkbox_->checked();
- UserMetricsRecordAction(enabled ?
- UserMetricsAction("Options_Translate_Enable") :
- UserMetricsAction("Options_Translate_Disable"),
- profile()->GetPrefs());
- enable_translate_.SetValue(enabled);
-}
-
-void TranslateSection::InitControlLayout() {
- AdvancedSection::InitControlLayout();
-
- GridLayout* layout = new GridLayout(contents_);
- contents_->SetLayoutManager(layout);
-
- AddIndentedColumnSet(layout, 0);
-
- enable_translate_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_TRANSLATE_ENABLE_TRANSLATE));
- enable_translate_checkbox_->set_listener(this);
- AddWrappingCheckboxRow(layout, enable_translate_checkbox_, 0, false);
-
- // Init member pref so we can update the controls if prefs change.
- enable_translate_.Init(prefs::kEnableTranslate, profile()->GetPrefs(), this);
-}
-
-void TranslateSection::NotifyPrefChanged(const std::string* pref_name) {
- if (!pref_name || *pref_name == prefs::kEnableTranslate)
- enable_translate_checkbox_->SetChecked(enable_translate_.GetValue());
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ChromeAppsSection
-
-class ChromeAppsSection : public AdvancedSection,
- public views::ButtonListener,
- public views::LinkController {
- public:
- explicit ChromeAppsSection(Profile* profile);
- virtual ~ChromeAppsSection() {}
-
- // Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
- // Overridden from views::LinkController:
- virtual void LinkActivated(views::Link* source, int event_flags);
-
- protected:
- // OptionsPageView overrides:
- virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::string* pref_name);
-
- private:
- // Controls for this section:
- views::Checkbox* enable_background_mode_checkbox_;
- views::Link* learn_more_link_;
-
- // Preferences for this section:
- BooleanPrefMember enable_background_mode_;
-
- DISALLOW_COPY_AND_ASSIGN(ChromeAppsSection);
-};
-
-ChromeAppsSection::ChromeAppsSection(Profile* profile)
- : enable_background_mode_checkbox_(NULL),
- learn_more_link_(NULL),
- AdvancedSection(profile, l10n_util::GetString(
- IDS_OPTIONS_ADVANCED_SECTION_TITLE_CHROME_APPS)) {
-}
-
-void ChromeAppsSection::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- DCHECK(sender == enable_background_mode_checkbox_);
- bool enabled = enable_background_mode_checkbox_->checked();
- UserMetricsRecordAction(enabled ?
- UserMetricsAction("Options_BackgroundMode_Enable") :
- UserMetricsAction("Options_BackgroundMode_Disable"),
- profile()->GetPrefs());
- enable_background_mode_.SetValue(enabled);
-}
-
-void ChromeAppsSection::LinkActivated(views::Link* source, int event_flags) {
- DCHECK(source == learn_more_link_);
- browser::ShowOptionsURL(
- profile(),
- GURL(l10n_util::GetString(IDS_LEARN_MORE_BACKGROUND_MODE_URL)));
-}
-
-void ChromeAppsSection::InitControlLayout() {
- AdvancedSection::InitControlLayout();
-
- GridLayout* layout = new GridLayout(contents_);
- contents_->SetLayoutManager(layout);
-
- AddIndentedColumnSet(layout, 0);
-
- enable_background_mode_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_CHROME_APPS_ENABLE_BACKGROUND_MODE));
- enable_background_mode_checkbox_->set_listener(this);
- AddWrappingCheckboxRow(layout, enable_background_mode_checkbox_, 0, true);
-
- // Init member pref so we can update the controls if prefs change.
- enable_background_mode_.Init(prefs::kBackgroundModeEnabled,
- profile()->GetPrefs(), this);
-
- // Add our link to the help center page for this feature.
- learn_more_link_ = new views::Link(l10n_util::GetString(IDS_LEARN_MORE));
- learn_more_link_->SetController(this);
- AddLeadingControl(layout, learn_more_link_, 0, false);
-}
-
-void ChromeAppsSection::NotifyPrefChanged(const std::string* pref_name) {
- if (!pref_name || *pref_name == prefs::kBackgroundModeEnabled) {
- enable_background_mode_checkbox_->SetChecked(
- enable_background_mode_.GetValue());
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// CloudPrintProxySection
-
-class CloudPrintProxySection : public AdvancedSection,
- public views::ButtonListener,
- public CloudPrintSetupFlow::Delegate {
- public:
- explicit CloudPrintProxySection(Profile* profile);
- virtual ~CloudPrintProxySection() {}
-
- // Overridden from views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // CloudPrintSetupFlow::Delegate implementation.
- virtual void OnDialogClosed();
-
- protected:
- // OptionsPageView overrides:
- virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::string* pref_name);
-
- private:
- bool Enabled() const;
-
- // Controls for this section:
- views::Label* section_description_label_;
- views::NativeButton* enable_disable_button_;
- views::NativeButton* manage_printer_button_;
-
- // Preferences we tie things to.
- StringPrefMember cloud_print_proxy_email_;
-
- base::ScopedCallbackFactory<CloudPrintProxySection> factory_;
-
- DISALLOW_COPY_AND_ASSIGN(CloudPrintProxySection);
-};
-
-CloudPrintProxySection::CloudPrintProxySection(Profile* profile)
- : section_description_label_(NULL),
- enable_disable_button_(NULL),
- manage_printer_button_(NULL),
- factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
- AdvancedSection(profile,
- l10n_util::GetString(
- IDS_OPTIONS_ADVANCED_SECTION_TITLE_CLOUD_PRINT)) {
-}
-
-void CloudPrintProxySection::ButtonPressed(views::Button* sender,
- const views::Event& event) {
- if (sender == enable_disable_button_) {
- if (Enabled()) {
- // Enabled, we must be the disable button.
- UserMetricsRecordAction(
- UserMetricsAction("Options_DisableCloudPrintProxy"), NULL);
- profile()->GetCloudPrintProxyService()->DisableForUser();
- } else {
- UserMetricsRecordAction(
- UserMetricsAction("Options_EnableCloudPrintProxy"), NULL);
- // We open a new browser window so the Options dialog doesn't
- // get lost behind other windows.
- enable_disable_button_->SetEnabled(false);
- enable_disable_button_->SetLabel(
- l10n_util::GetString(IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLING_BUTTON));
- enable_disable_button_->InvalidateLayout();
- Layout();
- CloudPrintSetupFlow::OpenDialog(profile(), this,
- GetWindow()->GetNativeWindow());
- }
- } else if (sender == manage_printer_button_) {
- UserMetricsRecordAction(
- UserMetricsAction("Options_ManageCloudPrinters"), NULL);
- browser::ShowOptionsURL(
- profile(),
- CloudPrintURL(profile()).GetCloudPrintServiceManageURL());
- }
-}
-
-void CloudPrintProxySection::OnDialogClosed() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- enable_disable_button_->SetEnabled(true);
- // If the dialog is canceled, the preference won't change, and so we
- // have to revert the button text back to the disabled state.
- if (!Enabled()) {
- enable_disable_button_->SetLabel(
- l10n_util::GetString(IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_BUTTON));
- enable_disable_button_->InvalidateLayout();
- Layout();
- }
-}
-
-void CloudPrintProxySection::InitControlLayout() {
- AdvancedSection::InitControlLayout();
-
- section_description_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_LABEL));
- enable_disable_button_ = new views::NativeButton(this,
- l10n_util::GetString(IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_BUTTON));
- manage_printer_button_ = new views::NativeButton(this,
- l10n_util::GetString(
- IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_MANAGE_BUTTON));
-
- GridLayout* layout = new GridLayout(contents_);
- contents_->SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- AddWrappingColumnSet(layout, single_column_view_set_id);
- const int control_view_set_id = 1;
- AddDependentTwoColumnSet(layout, control_view_set_id);
-
- // The description label at the top and label.
- section_description_label_->SetMultiLine(true);
- AddWrappingLabelRow(layout, section_description_label_,
- single_column_view_set_id, true);
-
- // The enable / disable button and manage button.
- AddTwoColumnRow(layout, enable_disable_button_, manage_printer_button_, false,
- control_view_set_id, kRelatedControlVerticalSpacing);
-
- // Attach the preferences so we can flip things appropriately.
- cloud_print_proxy_email_.Init(prefs::kCloudPrintEmail,
- profile()->GetPrefs(), this);
-
- // Start the UI off in the state we think it should be in.
- std::string pref_string(prefs::kCloudPrintEmail);
- NotifyPrefChanged(&pref_string);
-
- // Kick off a task to ask the background service what the real
- // answer is.
- profile()->GetCloudPrintProxyService()->RefreshStatusFromService();
-}
-
-void CloudPrintProxySection::NotifyPrefChanged(const std::string* pref_name) {
- if (pref_name == NULL)
- return;
-
- if (*pref_name == prefs::kCloudPrintEmail) {
- if (Enabled()) {
- std::string email;
- if (profile()->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail))
- email = profile()->GetPrefs()->GetString(prefs::kCloudPrintEmail);
-
- section_description_label_->SetText(
- l10n_util::GetStringF(IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_LABEL,
- UTF8ToWide(email)));
- enable_disable_button_->SetLabel(
- l10n_util::GetString(IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_BUTTON));
- enable_disable_button_->InvalidateLayout();
- manage_printer_button_->SetVisible(true);
- manage_printer_button_->InvalidateLayout();
- } else {
- section_description_label_->SetText(
- l10n_util::GetString(IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_LABEL));
- enable_disable_button_->SetLabel(
- l10n_util::GetString(IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_BUTTON));
- enable_disable_button_->InvalidateLayout();
- manage_printer_button_->SetVisible(false);
- }
-
- // Find the parent ScrollView, and ask it to re-layout since it's
- // possible that the section_description_label_ has changed
- // heights. And scroll us back to being visible in that case, to
- // be nice to the user.
- views::View* view = section_description_label_->GetParent();
- while (view && view->GetClassName() != views::ScrollView::kViewClassName)
- view = view->GetParent();
- if (view) {
- gfx::Rect visible_bounds = GetVisibleBounds();
- bool was_all_visible = (visible_bounds.size() == bounds().size());
- // Our bounds can change across this call, so we have to use the
- // new bounds if we want to stay completely visible.
- view->Layout();
- ScrollRectToVisible(was_all_visible ? bounds() : visible_bounds);
- } else {
- Layout();
- }
- }
-}
-
-bool CloudPrintProxySection::Enabled() const {
- return profile()->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) &&
- !profile()->GetPrefs()->GetString(prefs::kCloudPrintEmail).empty();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// AdvancedContentsView
-
-class AdvancedContentsView : public OptionsPageView {
- public:
- explicit AdvancedContentsView(Profile* profile);
- virtual ~AdvancedContentsView();
-
- // views::View overrides:
- virtual int GetLineScrollIncrement(views::ScrollView* scroll_view,
- bool is_horizontal, bool is_positive);
- virtual void Layout();
- virtual void DidChangeBounds(const gfx::Rect& previous,
- const gfx::Rect& current);
-
- protected:
- // OptionsPageView implementation:
- virtual void InitControlLayout();
-
- private:
- static void InitClass();
-
- static int line_height_;
-
- DISALLOW_COPY_AND_ASSIGN(AdvancedContentsView);
-};
-
-// static
-int AdvancedContentsView::line_height_ = 0;
-
-////////////////////////////////////////////////////////////////////////////////
-// AdvancedContentsView, public:
-
-AdvancedContentsView::AdvancedContentsView(Profile* profile)
- : OptionsPageView(profile) {
- InitClass();
-}
-
-AdvancedContentsView::~AdvancedContentsView() {
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// AdvancedContentsView, views::View overrides:
-
-int AdvancedContentsView::GetLineScrollIncrement(
- views::ScrollView* scroll_view,
- bool is_horizontal,
- bool is_positive) {
-
- if (!is_horizontal)
- return line_height_;
- return View::GetPageScrollIncrement(scroll_view, is_horizontal, is_positive);
-}
-
-void AdvancedContentsView::Layout() {
- views::View* parent = GetParent();
- if (parent && parent->width()) {
- const int width = parent->width();
- const int height = GetHeightForWidth(width);
- SetBounds(0, 0, width, height);
- } else {
- gfx::Size prefsize = GetPreferredSize();
- SetBounds(0, 0, prefsize.width(), prefsize.height());
- }
- View::Layout();
-}
-
-void AdvancedContentsView::DidChangeBounds(const gfx::Rect& previous,
- const gfx::Rect& current) {
- // Override to do nothing. Calling Layout() interferes with our scrolling.
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// AdvancedContentsView, OptionsPageView implementation:
-
-void AdvancedContentsView::InitControlLayout() {
- GridLayout* layout = CreatePanelGridLayout(this);
- SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(new PrivacySection(profile()));
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(new NetworkSection(profile()));
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(new TranslateSection(profile()));
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(new DownloadSection(profile()));
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(new WebContentSection(profile()));
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(new SecuritySection(profile()));
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableCloudPrintProxy) &&
- profile()->GetCloudPrintProxyService()) {
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(new CloudPrintProxySection(profile()));
- }
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableBackgroundMode)) {
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(new ChromeAppsSection(profile()));
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// AdvancedContentsView, private:
-
-void AdvancedContentsView::InitClass() {
- static bool initialized = false;
- if (!initialized) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- line_height_ = rb.GetFont(ResourceBundle::BaseFont).GetHeight();
- initialized = true;
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// AdvancedScrollViewContainer, public:
-
-AdvancedScrollViewContainer::AdvancedScrollViewContainer(Profile* profile)
- : contents_view_(new AdvancedContentsView(profile)),
- scroll_view_(new views::ScrollView) {
- AddChildView(scroll_view_);
- scroll_view_->SetContents(contents_view_);
- set_background(new ListBackground());
-}
-
-AdvancedScrollViewContainer::~AdvancedScrollViewContainer() {
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// AdvancedScrollViewContainer, views::View overrides:
-
-void AdvancedScrollViewContainer::Layout() {
- gfx::Rect lb = GetLocalBounds(false);
-
- gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize(
- gfx::NativeTheme::LIST);
- lb.Inset(border.width(), border.height());
- scroll_view_->SetBounds(lb);
-}
diff --git a/chrome/browser/views/options/advanced_contents_view.h b/chrome/browser/views/options/advanced_contents_view.h
index 5adf493..9026e82 100644
--- a/chrome/browser/views/options/advanced_contents_view.h
+++ b/chrome/browser/views/options/advanced_contents_view.h
@@ -2,38 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_OPTIONS_ADVANCED_CONTENTS_VIEW_H__
-#define CHROME_BROWSER_VIEWS_OPTIONS_ADVANCED_CONTENTS_VIEW_H__
+#ifndef CHROME_BROWSER_VIEWS_OPTIONS_ADVANCED_CONTENTS_VIEW_H_
+#define CHROME_BROWSER_VIEWS_OPTIONS_ADVANCED_CONTENTS_VIEW_H_
#pragma once
-#include "chrome/browser/views/options/options_page_view.h"
+#include "chrome/browser/ui/views/options/advanced_contents_view.h"
+// TODO(beng): remove this file once all includes have been updated.
-class AdvancedContentsView;
-namespace views {
-class ScrollView;
-}
+#endif // CHROME_BROWSER_VIEWS_OPTIONS_ADVANCED_CONTENTS_VIEW_H_
-///////////////////////////////////////////////////////////////////////////////
-// AdvancedScrollViewContainer
-//
-// A View that contains a scroll view containing the Advanced options.
-
-class AdvancedScrollViewContainer : public views::View {
- public:
- explicit AdvancedScrollViewContainer(Profile* profile);
- virtual ~AdvancedScrollViewContainer();
-
- // views::View overrides:
- virtual void Layout();
-
- private:
- // The contents of the advanced scroll view.
- AdvancedContentsView* contents_view_;
-
- // The scroll view that contains the advanced options.
- views::ScrollView* scroll_view_;
-
- DISALLOW_COPY_AND_ASSIGN(AdvancedScrollViewContainer);
-};
-
-#endif // CHROME_BROWSER_VIEWS_OPTIONS_ADVANCED_CONTENTS_VIEW_H__
diff --git a/chrome/browser/views/options/advanced_page_view.cc b/chrome/browser/views/options/advanced_page_view.cc
deleted file mode 100644
index 712955c..0000000
--- a/chrome/browser/views/options/advanced_page_view.cc
+++ /dev/null
@@ -1,145 +0,0 @@
-// 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/options/advanced_page_view.h"
-
-#include "app/l10n_util.h"
-#include "app/message_box_flags.h"
-#include "base/string_util.h"
-#include "chrome/browser/options_util.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/views/options/advanced_contents_view.h"
-#include "chrome/browser/views/options/managed_prefs_banner_view.h"
-#include "chrome/common/chrome_constants.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "views/controls/message_box_view.h"
-#include "views/controls/button/native_button.h"
-#include "views/controls/scroll_view.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-#include "views/window/dialog_delegate.h"
-#include "views/window/window.h"
-
-namespace {
-
-// A dialog box that asks the user to confirm resetting settings.
-class ResetDefaultsConfirmBox : public views::DialogDelegate {
- public:
- // This box is modal to |parent_hwnd|.
- static void ShowConfirmBox(HWND parent_hwnd, AdvancedPageView* page_view) {
- // When the window closes, it will delete itself.
- new ResetDefaultsConfirmBox(parent_hwnd, page_view);
- }
-
- protected:
- // views::DialogDelegate
- virtual std::wstring GetDialogButtonLabel(
- MessageBoxFlags::DialogButton button) const {
- switch (button) {
- case MessageBoxFlags::DIALOGBUTTON_OK:
- return l10n_util::GetString(IDS_OPTIONS_RESET_OKLABEL);
- case MessageBoxFlags::DIALOGBUTTON_CANCEL:
- return l10n_util::GetString(IDS_OPTIONS_RESET_CANCELLABEL);
- default:
- break;
- }
- NOTREACHED();
- return std::wstring();
- }
- virtual std::wstring GetWindowTitle() const {
- return l10n_util::GetString(IDS_PRODUCT_NAME);
- }
- virtual bool Accept() {
- advanced_page_view_->ResetToDefaults();
- return true;
- }
- // views::WindowDelegate
- virtual void DeleteDelegate() { delete this; }
- virtual bool IsModal() const { return true; }
- virtual views::View* GetContentsView() { return message_box_view_; }
-
- private:
- ResetDefaultsConfirmBox(HWND parent_hwnd, AdvancedPageView* page_view)
- : advanced_page_view_(page_view) {
- int dialog_width = views::Window::GetLocalizedContentsWidth(
- IDS_OPTIONS_RESET_CONFIRM_BOX_WIDTH_CHARS);
- // Also deleted when the window closes.
- message_box_view_ = new MessageBoxView(
- MessageBoxFlags::kFlagHasMessage | MessageBoxFlags::kFlagHasOKButton,
- l10n_util::GetString(IDS_OPTIONS_RESET_MESSAGE).c_str(),
- std::wstring(),
- dialog_width);
- views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), this)->Show();
- }
- virtual ~ResetDefaultsConfirmBox() { }
-
- MessageBoxView* message_box_view_;
- AdvancedPageView* advanced_page_view_;
-
- DISALLOW_COPY_AND_ASSIGN(ResetDefaultsConfirmBox);
-};
-
-} // namespace
-
-///////////////////////////////////////////////////////////////////////////////
-// AdvancedPageView, public:
-
-AdvancedPageView::AdvancedPageView(Profile* profile)
- : advanced_scroll_view_(NULL),
- reset_to_default_button_(NULL),
- OptionsPageView(profile) {
-}
-
-AdvancedPageView::~AdvancedPageView() {
-}
-
-void AdvancedPageView::ResetToDefaults() {
- OptionsUtil::ResetToDefaults(profile());
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// AdvancedPageView, views::ButtonListener implementation:
-
-void AdvancedPageView::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (sender == reset_to_default_button_) {
- UserMetricsRecordAction(UserMetricsAction("Options_ResetToDefaults"),
- NULL);
- ResetDefaultsConfirmBox::ShowConfirmBox(
- GetWindow()->GetNativeWindow(), this);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// AdvancedPageView, OptionsPageView implementation:
-
-void AdvancedPageView::InitControlLayout() {
- reset_to_default_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_OPTIONS_RESET));
- advanced_scroll_view_ = new AdvancedScrollViewContainer(profile());
-
- using views::GridLayout;
- using views::ColumnSet;
-
- GridLayout* layout = CreatePanelGridLayout(this);
- SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(
- new ManagedPrefsBannerView(profile()->GetPrefs(), OPTIONS_PAGE_ADVANCED));
-
- layout->StartRow(1, single_column_view_set_id);
- layout->AddView(advanced_scroll_view_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(reset_to_default_button_, 1, 1,
- GridLayout::TRAILING, GridLayout::CENTER);
-}
diff --git a/chrome/browser/views/options/advanced_page_view.h b/chrome/browser/views/options/advanced_page_view.h
index 8075021..dccd66e 100644
--- a/chrome/browser/views/options/advanced_page_view.h
+++ b/chrome/browser/views/options/advanced_page_view.h
@@ -6,41 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_ADVANCED_PAGE_VIEW_H_
#pragma once
-#include "chrome/browser/views/options/options_page_view.h"
-#include "views/controls/button/button.h"
-
-class AdvancedOptionsListModel;
-class AdvancedScrollViewContainer;
-class PrefService;
-namespace views {
-class NativeButton;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// AdvancedPageView
-
-class AdvancedPageView : public OptionsPageView,
- public views::ButtonListener {
- public:
- explicit AdvancedPageView(Profile* profile);
- virtual ~AdvancedPageView();
-
- // Resets all prefs to their default values.
- void ResetToDefaults();
-
- // views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- protected:
- // OptionsPageView implementation:
- virtual void InitControlLayout();
-
- private:
- // Controls for the Advanced page
- AdvancedScrollViewContainer* advanced_scroll_view_;
- views::NativeButton* reset_to_default_button_;
-
- DISALLOW_COPY_AND_ASSIGN(AdvancedPageView);
-};
+#include "chrome/browser/ui/views/options/advanced_page_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_ADVANCED_PAGE_VIEW_H_
+
diff --git a/chrome/browser/views/options/content_exceptions_table_view.cc b/chrome/browser/views/options/content_exceptions_table_view.cc
deleted file mode 100644
index 1b81aa1..0000000
--- a/chrome/browser/views/options/content_exceptions_table_view.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// 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/options/content_exceptions_table_view.h"
-
-#include "gfx/font.h"
-
-ContentExceptionsTableView::ContentExceptionsTableView(
- ContentExceptionsTableModel* model,
- const std::vector<TableColumn>& columns)
- : views::TableView(model, columns, views::TEXT_ONLY, false, true, false),
- exceptions_(model) {
- SetCustomColorsEnabled(true);
-}
-
-bool ContentExceptionsTableView::GetCellColors(int model_row,
- int column,
- ItemColor* foreground,
- ItemColor* background,
- LOGFONT* logfont) {
- if (!exceptions_->entry_is_off_the_record(model_row))
- return false;
-
- foreground->color_is_set = false;
- background->color_is_set = false;
-
- gfx::Font font;
- font = font.DeriveFont(0, gfx::Font::ITALIC);
- HFONT hf = font.GetNativeFont();
- GetObject(hf, sizeof(LOGFONT), logfont);
- return true;
-}
diff --git a/chrome/browser/views/options/content_exceptions_table_view.h b/chrome/browser/views/options/content_exceptions_table_view.h
index ac5511f..6cc48fb 100644
--- a/chrome/browser/views/options/content_exceptions_table_view.h
+++ b/chrome/browser/views/options/content_exceptions_table_view.h
@@ -6,26 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_EXCEPTIONS_TABLE_VIEW_H_
#pragma once
-#include "chrome/browser/content_exceptions_table_model.h"
-#include "views/controls/table/table_view.h"
-
-// A thin wrapper around TableView that displays off-the-record entries in
-// italics.
-class ContentExceptionsTableView : public views::TableView {
- public:
- ContentExceptionsTableView(ContentExceptionsTableModel* model,
- const std::vector<TableColumn>& columns);
-
- virtual ~ContentExceptionsTableView() {}
-
- private:
- virtual bool GetCellColors(int model_row,
- int column,
- ItemColor* foreground,
- ItemColor* background,
- LOGFONT* logfont);
-
- ContentExceptionsTableModel* exceptions_;
-};
+#include "chrome/browser/ui/views/options/content_exceptions_table_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_EXCEPTIONS_TABLE_VIEW_H_
+
diff --git a/chrome/browser/views/options/content_filter_page_view.cc b/chrome/browser/views/options/content_filter_page_view.cc
deleted file mode 100644
index 756045f..0000000
--- a/chrome/browser/views/options/content_filter_page_view.cc
+++ /dev/null
@@ -1,227 +0,0 @@
-// 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/options/content_filter_page_view.h"
-
-#include "app/l10n_util.h"
-#include "base/command_line.h"
-#include "chrome/browser/geolocation/geolocation_content_settings_map.h"
-#include "chrome/browser/geolocation/geolocation_exceptions_table_model.h"
-#include "chrome/browser/notifications/desktop_notification_service.h"
-#include "chrome/browser/notifications/notification_exceptions_table_model.h"
-#include "chrome/browser/plugin_exceptions_table_model.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/views/options/exceptions_view.h"
-#include "chrome/browser/views/options/simple_content_exceptions_view.h"
-#include "chrome/common/chrome_switches.h"
-#include "grit/generated_resources.h"
-#include "views/controls/button/radio_button.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-#include "views/window/window.h"
-
-ContentFilterPageView::ContentFilterPageView(Profile* profile,
- ContentSettingsType content_type)
- : OptionsPageView(profile),
- content_type_(content_type),
- allow_radio_(NULL),
- ask_radio_(NULL),
- block_radio_(NULL),
- exceptions_button_(NULL) {
-}
-
-ContentFilterPageView::~ContentFilterPageView() {
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ContentFilterPageView, OptionsPageView implementation:
-
-void ContentFilterPageView::InitControlLayout() {
- using views::GridLayout;
-
- GridLayout* layout = new GridLayout(this);
- SetLayoutManager(layout);
-
- const int single_column_set_id = 0;
- views::ColumnSet* column_set = layout->AddColumnSet(single_column_set_id);
- column_set->AddPaddingColumn(0, kRelatedControlVerticalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- static const int kTitleIDs[] = {
- IDS_MODIFY_COOKIE_STORING_LABEL,
- IDS_IMAGES_SETTING_LABEL,
- IDS_JS_SETTING_LABEL,
- IDS_PLUGIN_SETTING_LABEL,
- IDS_POPUP_SETTING_LABEL,
- IDS_GEOLOCATION_SETTING_LABEL,
- IDS_NOTIFICATIONS_SETTING_LABEL,
- };
- COMPILE_ASSERT(arraysize(kTitleIDs) == CONTENT_SETTINGS_NUM_TYPES,
- Need_a_setting_for_every_content_settings_type);
- views::Label* title_label = new views::Label(
- l10n_util::GetString(kTitleIDs[content_type_]));
- title_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- title_label->SetMultiLine(true);
-
- layout->StartRow(0, single_column_set_id);
- layout->AddView(title_label);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- static const int kAllowIDs[] = {
- IDS_COOKIES_ALLOW_RADIO,
- IDS_IMAGES_LOAD_RADIO,
- IDS_JS_ALLOW_RADIO,
- IDS_PLUGIN_LOAD_RADIO,
- IDS_POPUP_ALLOW_RADIO,
- IDS_GEOLOCATION_ALLOW_RADIO,
- IDS_NOTIFICATIONS_ALLOW_RADIO,
- };
- COMPILE_ASSERT(arraysize(kAllowIDs) == CONTENT_SETTINGS_NUM_TYPES,
- Need_a_setting_for_every_content_settings_type);
- const int radio_button_group = 0;
- allow_radio_ = new views::RadioButton(
- l10n_util::GetString(kAllowIDs[content_type_]), radio_button_group);
- allow_radio_->set_listener(this);
- allow_radio_->SetMultiLine(true);
- layout->StartRow(0, single_column_set_id);
- layout->AddView(allow_radio_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- static const int kAskIDs[] = {
- IDS_COOKIES_ASK_EVERY_TIME_RADIO,
- 0,
- 0,
- IDS_PLUGIN_ASK_RADIO,
- 0,
- IDS_GEOLOCATION_ASK_RADIO,
- IDS_NOTIFICATIONS_ASK_RADIO,
- };
- COMPILE_ASSERT(arraysize(kAskIDs) == CONTENT_SETTINGS_NUM_TYPES,
- Need_a_setting_for_every_content_settings_type);
- DCHECK_EQ(arraysize(kAskIDs),
- static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES));
- if (content_type_ != CONTENT_SETTINGS_TYPE_COOKIES) {
- if (kAskIDs[content_type_] != 0) {
- ask_radio_ = new views::RadioButton(
- l10n_util::GetString(kAskIDs[content_type_]), radio_button_group);
- ask_radio_->set_listener(this);
- ask_radio_->SetMultiLine(true);
- layout->StartRow(0, single_column_set_id);
- layout->AddView(ask_radio_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- }
- }
-
- static const int kBlockIDs[] = {
- IDS_COOKIES_BLOCK_RADIO,
- IDS_IMAGES_NOLOAD_RADIO,
- IDS_JS_DONOTALLOW_RADIO,
- IDS_PLUGIN_NOLOAD_RADIO,
- IDS_POPUP_BLOCK_RADIO,
- IDS_GEOLOCATION_BLOCK_RADIO,
- IDS_NOTIFICATIONS_BLOCK_RADIO,
- };
- COMPILE_ASSERT(arraysize(kBlockIDs) == CONTENT_SETTINGS_NUM_TYPES,
- Need_a_setting_for_every_content_settings_type);
- block_radio_ = new views::RadioButton(
- l10n_util::GetString(kBlockIDs[content_type_]), radio_button_group);
- block_radio_->set_listener(this);
- block_radio_->SetMultiLine(true);
- layout->StartRow(0, single_column_set_id);
- layout->AddView(block_radio_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- ContentSetting default_setting;
- if (content_type_ == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
- default_setting = profile()->GetGeolocationContentSettingsMap()->
- GetDefaultContentSetting();
- } else if (content_type_ == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
- default_setting = profile()->GetDesktopNotificationService()->
- GetDefaultContentSetting();
- } else {
- default_setting = profile()->GetHostContentSettingsMap()->
- GetDefaultContentSetting(content_type_);
- }
- // Now that these have been added to the view hierarchy, it's safe to call
- // SetChecked() on them.
- if (default_setting == CONTENT_SETTING_ALLOW) {
- allow_radio_->SetChecked(true);
- } else if (default_setting == CONTENT_SETTING_ASK) {
- DCHECK(ask_radio_ != NULL);
- ask_radio_->SetChecked(true);
- } else {
- DCHECK(default_setting == CONTENT_SETTING_BLOCK);
- block_radio_->SetChecked(true);
- }
-
- exceptions_button_ = new views::NativeButton(this,
- l10n_util::GetString(IDS_COOKIES_EXCEPTIONS_BUTTON));
-
- layout->StartRow(0, single_column_set_id);
- layout->AddView(exceptions_button_, 1, 1, GridLayout::LEADING,
- GridLayout::FILL);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ContentFilterPageView, views::ButtonListener implementation:
-
-void ContentFilterPageView::ButtonPressed(views::Button* sender,
- const views::Event& event) {
- if (sender == exceptions_button_) {
- if (content_type_ == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
- SimpleContentExceptionsView::ShowExceptionsWindow(
- GetWindow()->GetNativeWindow(),
- new GeolocationExceptionsTableModel(
- profile()->GetGeolocationContentSettingsMap()),
- IDS_GEOLOCATION_EXCEPTION_TITLE);
- } else if (content_type_ == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
- SimpleContentExceptionsView::ShowExceptionsWindow(
- GetWindow()->GetNativeWindow(),
- new NotificationExceptionsTableModel(
- profile()->GetDesktopNotificationService()),
- IDS_NOTIFICATIONS_EXCEPTION_TITLE);
- } else {
- HostContentSettingsMap* settings = profile()->GetHostContentSettingsMap();
- HostContentSettingsMap* otr_settings =
- profile()->HasOffTheRecordProfile() ?
- profile()->GetOffTheRecordProfile()->GetHostContentSettingsMap() :
- NULL;
- if (content_type_ == CONTENT_SETTINGS_TYPE_PLUGINS &&
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableResourceContentSettings)) {
- PluginExceptionsTableModel* model =
- new PluginExceptionsTableModel(settings, otr_settings);
- model->LoadSettings();
- SimpleContentExceptionsView::ShowExceptionsWindow(
- GetWindow()->GetNativeWindow(),
- model,
- IDS_PLUGINS_EXCEPTION_TITLE);
- } else {
- ExceptionsView::ShowExceptionsWindow(GetWindow()->GetNativeWindow(),
- settings,
- otr_settings,
- content_type_);
- }
- }
- return;
- }
-
- DCHECK((sender == allow_radio_) || (sender == ask_radio_) ||
- (sender == block_radio_));
- ContentSetting default_setting = allow_radio_->checked() ?
- CONTENT_SETTING_ALLOW :
- (block_radio_->checked() ? CONTENT_SETTING_BLOCK : CONTENT_SETTING_ASK);
- if (content_type_ == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
- profile()->GetGeolocationContentSettingsMap()->SetDefaultContentSetting(
- default_setting);
- } else if (content_type_ == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
- profile()->GetDesktopNotificationService()->SetDefaultContentSetting(
- default_setting);
- } else {
- profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
- content_type_, default_setting);
- }
-}
diff --git a/chrome/browser/views/options/content_filter_page_view.h b/chrome/browser/views/options/content_filter_page_view.h
index 8c9bd99..0a1115e 100644
--- a/chrome/browser/views/options/content_filter_page_view.h
+++ b/chrome/browser/views/options/content_filter_page_view.h
@@ -6,44 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_FILTER_PAGE_VIEW_H_
#pragma once
-#include "chrome/browser/views/options/options_page_view.h"
-#include "chrome/common/content_settings_types.h"
-#include "views/controls/button/button.h"
-
-namespace views {
-class Label;
-class NativeButton;
-class RadioButton;
-}
-class PrefService;
-
-////////////////////////////////////////////////////////////////////////////////
-// The ContentFilterPageView class is used to render the Images, JavaScript,
-// Pop-ups and Location pages in the Content Settings window.
-
-class ContentFilterPageView : public OptionsPageView,
- public views::ButtonListener {
- public:
- ContentFilterPageView(Profile* profile, ContentSettingsType content_type);
- virtual ~ContentFilterPageView();
-
- protected:
- // OptionsPageView implementation:
- virtual void InitControlLayout();
-
- // views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- private:
- ContentSettingsType content_type_;
-
- // Controls for the content filter tab page.
- views::RadioButton* allow_radio_;
- views::RadioButton* ask_radio_;
- views::RadioButton* block_radio_;
- views::NativeButton* exceptions_button_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(ContentFilterPageView);
-};
+#include "chrome/browser/ui/views/options/content_filter_page_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_FILTER_PAGE_VIEW_H_
+
diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc
deleted file mode 100644
index 7f50426..0000000
--- a/chrome/browser/views/options/content_page_view.cc
+++ /dev/null
@@ -1,496 +0,0 @@
-// 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/options/content_page_view.h"
-
-#include <windows.h>
-#include <shlobj.h>
-#include <vsstyle.h>
-#include <vssym32.h>
-
-#include "app/l10n_util.h"
-#include "base/command_line.h"
-#include "base/string_util.h"
-#include "chrome/browser/autofill/autofill_dialog.h"
-#include "chrome/browser/autofill/personal_data_manager.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/browser_window.h"
-#include "chrome/browser/importer/importer_data_types.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/sync/sync_ui_util.h"
-#include "chrome/browser/sync/sync_setup_wizard.h"
-#include "chrome/browser/views/importer_view.h"
-#include "chrome/browser/views/options/managed_prefs_banner_view.h"
-#include "chrome/browser/views/options/options_group_view.h"
-#include "chrome/browser/views/options/passwords_exceptions_window_view.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
-#include "gfx/canvas.h"
-#include "gfx/native_theme_win.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "views/controls/button/radio_button.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-#include "views/widget/widget.h"
-#include "views/window/window.h"
-
-namespace {
-
-// All the options pages are in the same view hierarchy. This means we need to
-// make sure group identifiers don't collide across different pages.
-const int kPasswordSavingRadioGroup = 201;
-const int kFormAutofillRadioGroup = 202;
-
-// Background color for the status label when it's showing an error.
-static const SkColor kSyncLabelErrorBgColor = SkColorSetRGB(0xff, 0x9a, 0x9a);
-
-static views::Background* CreateErrorBackground() {
- return views::Background::CreateSolidBackground(kSyncLabelErrorBgColor);
-}
-
-} // namespace
-
-ContentPageView::ContentPageView(Profile* profile)
- : show_passwords_button_(NULL),
- passwords_group_(NULL),
- passwords_asktosave_radio_(NULL),
- passwords_neversave_radio_(NULL),
- change_autofill_settings_button_(NULL),
- themes_group_(NULL),
- themes_reset_button_(NULL),
- themes_gallery_link_(NULL),
- browsing_data_group_(NULL),
- import_button_(NULL),
- sync_group_(NULL),
- sync_action_link_(NULL),
- sync_status_label_(NULL),
- sync_start_stop_button_(NULL),
- sync_customize_button_(NULL),
- privacy_dashboard_link_(NULL),
- sync_service_(NULL),
- OptionsPageView(profile) {
- if (profile->GetProfileSyncService()) {
- sync_service_ = profile->GetProfileSyncService();
- sync_service_->AddObserver(this);
- }
-}
-
-ContentPageView::~ContentPageView() {
- if (sync_service_)
- sync_service_->RemoveObserver(this);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ContentPageView, views::ButtonListener implementation:
-
-void ContentPageView::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (sender == passwords_asktosave_radio_ ||
- sender == passwords_neversave_radio_) {
- bool enabled = passwords_asktosave_radio_->checked();
- if (enabled) {
- UserMetricsRecordAction(
- UserMetricsAction("Options_PasswordManager_Enable"),
- profile()->GetPrefs());
- } else {
- UserMetricsRecordAction(
- UserMetricsAction("Options_PasswordManager_Disable"),
- profile()->GetPrefs());
- }
- ask_to_save_passwords_.SetValue(enabled);
- } else if (sender == show_passwords_button_) {
- UserMetricsRecordAction(
- UserMetricsAction("Options_ShowPasswordsExceptions"), NULL);
- PasswordsExceptionsWindowView::Show(profile());
- } else if (sender == change_autofill_settings_button_) {
- // This button should be disabled if we lack PersonalDataManager.
- DCHECK(profile()->GetPersonalDataManager());
- ShowAutoFillDialog(GetWindow()->GetNativeWindow(),
- profile()->GetPersonalDataManager(),
- profile());
- } else if (sender == themes_reset_button_) {
- UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset"),
- profile()->GetPrefs());
- profile()->ClearTheme();
- } else if (sender == import_button_) {
- views::Window::CreateChromeWindow(
- GetWindow()->GetNativeWindow(),
- gfx::Rect(),
- new ImporterView(profile(), importer::ALL))->Show();
- } else if (sender == sync_start_stop_button_) {
- DCHECK(sync_service_ && !sync_service_->IsManaged());
-
- if (sync_service_->HasSyncSetupCompleted()) {
- ConfirmMessageBoxDialog::RunWithCustomConfiguration(
- GetWindow()->GetNativeWindow(),
- this,
- l10n_util::GetStringF(IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL,
- l10n_util::GetString(IDS_PRODUCT_NAME)),
- l10n_util::GetString(IDS_SYNC_STOP_SYNCING_DIALOG_TITLE),
- l10n_util::GetString(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL),
- l10n_util::GetString(IDS_CANCEL),
- gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_CONFIRM_STOP_SYNCING_DIALOG_WIDTH_CHARS,
- IDS_CONFIRM_STOP_SYNCING_DIALOG_HEIGHT_LINES)));
- return;
- } else {
- sync_service_->ShowLoginDialog(GetWindow()->GetNativeWindow());
- ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS);
- }
- } else if (sender == sync_customize_button_) {
- // sync_customize_button_ should be invisible if sync is not yet set up.
- DCHECK(sync_service_->HasSyncSetupCompleted());
- sync_service_->ShowConfigure(GetWindow()->GetNativeWindow());
- }
-}
-
-void ContentPageView::LinkActivated(views::Link* source, int event_flags) {
- if (source == themes_gallery_link_) {
- UserMetricsRecordAction(UserMetricsAction("Options_ThemesGallery"),
- profile()->GetPrefs());
- BrowserList::GetLastActive()->OpenThemeGalleryTabAndActivate();
- return;
- }
- if (source == sync_action_link_) {
- DCHECK(sync_service_ && !sync_service_->IsManaged());
- sync_service_->ShowLoginDialog(GetWindow()->GetNativeWindow());
- return;
- }
- if (source == privacy_dashboard_link_) {
- BrowserList::GetLastActive()->OpenPrivacyDashboardTabAndActivate();
- return;
- }
- NOTREACHED() << "Invalid link source.";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ContentPageView, OptionsPageView implementation:
-
-void ContentPageView::InitControlLayout() {
- using views::GridLayout;
- using views::ColumnSet;
-
- GridLayout* layout = new GridLayout(this);
- layout->SetInsets(5, 5, 5, 5);
- SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(
- new ManagedPrefsBannerView(profile()->GetPrefs(), OPTIONS_PAGE_CONTENT));
-
- if (sync_service_) {
- layout->StartRow(0, single_column_view_set_id);
- InitSyncGroup();
- layout->AddView(sync_group_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- }
-
- layout->StartRow(0, single_column_view_set_id);
- InitPasswordSavingGroup();
- layout->AddView(passwords_group_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- layout->StartRow(0, single_column_view_set_id);
- InitFormAutofillGroup();
- layout->AddView(form_autofill_group_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- layout->StartRow(0, single_column_view_set_id);
- InitBrowsingDataGroup();
- layout->AddView(browsing_data_group_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- layout->StartRow(0, single_column_view_set_id);
- InitThemesGroup();
- layout->AddView(themes_group_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- // Init member prefs so we can update the controls if prefs change.
- ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled,
- profile()->GetPrefs(), this);
- form_autofill_enabled_.Init(prefs::kAutoFillEnabled,
- profile()->GetPrefs(), this);
- is_using_default_theme_.Init(prefs::kCurrentThemeID,
- profile()->GetPrefs(), this);
-}
-
-void ContentPageView::NotifyPrefChanged(const std::string* pref_name) {
- if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) {
- if (ask_to_save_passwords_.GetValue()) {
- passwords_asktosave_radio_->SetChecked(true);
- } else {
- passwords_neversave_radio_->SetChecked(true);
- }
-
- // Disable UI elements that are managed via policy.
- bool enablePasswordManagerElements = !ask_to_save_passwords_.IsManaged();
- passwords_asktosave_radio_->SetEnabled(enablePasswordManagerElements);
- passwords_neversave_radio_->SetEnabled(enablePasswordManagerElements);
- show_passwords_button_->SetEnabled(enablePasswordManagerElements ||
- ask_to_save_passwords_.GetValue());
- }
- if (!pref_name || *pref_name == prefs::kAutoFillEnabled) {
- bool disabled_by_policy = form_autofill_enabled_.IsManaged() &&
- !form_autofill_enabled_.GetValue();
- change_autofill_settings_button_->SetEnabled(
- !disabled_by_policy && profile()->GetPersonalDataManager());
- }
- if (!pref_name || *pref_name == prefs::kCurrentThemeID) {
- themes_reset_button_->SetEnabled(
- is_using_default_theme_.GetValue().length() > 0);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ContentsPageView, views::View overrides:
-
-void ContentPageView::Layout() {
- if (is_initialized())
- UpdateSyncControls();
- View::Layout();
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-// ContentsPageView, ProfileSyncServiceObserver implementation:
-
-void ContentPageView::OnStateChanged() {
- // If the UI controls are not yet initialized, then don't do anything. This
- // can happen if the Options dialog is up, but the Content tab is not yet
- // clicked.
- if (is_initialized())
- Layout();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ContentPageView, private:
-
-void ContentPageView::InitPasswordSavingGroup() {
- passwords_asktosave_radio_ = new views::RadioButton(
- l10n_util::GetString(IDS_OPTIONS_PASSWORDS_ASKTOSAVE),
- kPasswordSavingRadioGroup);
- passwords_asktosave_radio_->set_listener(this);
- passwords_asktosave_radio_->SetMultiLine(true);
- passwords_neversave_radio_ = new views::RadioButton(
- l10n_util::GetString(IDS_OPTIONS_PASSWORDS_NEVERSAVE),
- kPasswordSavingRadioGroup);
- passwords_neversave_radio_->set_listener(this);
- passwords_neversave_radio_->SetMultiLine(true);
- show_passwords_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_OPTIONS_PASSWORDS_SHOWPASSWORDS));
-
- using views::GridLayout;
- using views::ColumnSet;
-
- views::View* contents = new views::View;
- GridLayout* layout = new GridLayout(contents);
- contents->SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(passwords_asktosave_radio_, 1, 1,
- GridLayout::FILL, GridLayout::LEADING);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(passwords_neversave_radio_, 1, 1,
- GridLayout::FILL, GridLayout::LEADING);
- layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(show_passwords_button_);
-
- passwords_group_ = new OptionsGroupView(
- contents, l10n_util::GetString(IDS_OPTIONS_PASSWORDS_GROUP_NAME), L"",
- true);
-}
-
-void ContentPageView::InitFormAutofillGroup() {
- change_autofill_settings_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_AUTOFILL_OPTIONS));
-
- using views::GridLayout;
- using views::ColumnSet;
-
- views::View* contents = new views::View;
- GridLayout* layout = new GridLayout(contents);
- contents->SetLayoutManager(layout);
-
- const int fill_column_view_set_id = 0;
- const int leading_column_view_set_id = 1;
- ColumnSet* column_set = layout->AddColumnSet(fill_column_view_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- column_set = layout->AddColumnSet(leading_column_view_set_id);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, leading_column_view_set_id);
- layout->AddView(change_autofill_settings_button_);
-
- form_autofill_group_ = new OptionsGroupView(
- contents, l10n_util::GetString(IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME),
- L"", true);
-}
-
-void ContentPageView::InitThemesGroup() {
- themes_reset_button_ = new views::NativeButton(this,
- l10n_util::GetString(IDS_THEMES_RESET_BUTTON));
- themes_gallery_link_ = new views::Link(
- l10n_util::GetString(IDS_THEMES_GALLERY_BUTTON));
- themes_gallery_link_->SetController(this);
-
- using views::GridLayout;
- using views::ColumnSet;
-
- views::View* contents = new views::View;
- GridLayout* layout = new GridLayout(contents);
- contents->SetLayoutManager(layout);
-
- const int double_column_view_set_id = 1;
- ColumnSet* double_col_set = layout->AddColumnSet(double_column_view_set_id);
- double_col_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
- double_col_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- double_col_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, double_column_view_set_id);
- layout->AddView(themes_reset_button_);
- layout->AddView(themes_gallery_link_);
-
- themes_group_ = new OptionsGroupView(
- contents, l10n_util::GetString(IDS_THEMES_GROUP_NAME),
- L"", false);
-}
-
-void ContentPageView::InitBrowsingDataGroup() {
- import_button_ = new views::NativeButton(this,
- l10n_util::GetString(IDS_OPTIONS_IMPORT_DATA_BUTTON));
-
- using views::GridLayout;
- using views::ColumnSet;
-
- views::View* contents = new views::View;
- GridLayout* layout = new GridLayout(contents);
- contents->SetLayoutManager(layout);
-
- // Add the browsing data import button.
- const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(import_button_);
-
- browsing_data_group_ = new OptionsGroupView(
- contents, l10n_util::GetString(IDS_OPTIONS_BROWSING_DATA_GROUP_NAME),
- L"", true);
-}
-
-void ContentPageView::OnConfirmMessageAccept() {
- sync_service_->DisableForUser();
- ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
-}
-
-void ContentPageView::InitSyncGroup() {
- sync_status_label_ = new views::Label;
- sync_status_label_->SetMultiLine(true);
- sync_status_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
-
- sync_action_link_ = new views::Link();
- sync_action_link_->set_collapse_when_hidden(true);
- sync_action_link_->SetController(this);
-
- privacy_dashboard_link_ = new views::Link();
- privacy_dashboard_link_->set_collapse_when_hidden(true);
- privacy_dashboard_link_->SetController(this);
- privacy_dashboard_link_->SetText(
- l10n_util::GetString(IDS_SYNC_PRIVACY_DASHBOARD_LINK_LABEL));
-
- sync_start_stop_button_ = new views::NativeButton(this, std::wstring());
- sync_customize_button_ = new views::NativeButton(this, std::wstring());
-
- using views::GridLayout;
- using views::ColumnSet;
-
- views::View* contents = new views::View;
- GridLayout* layout = new GridLayout(contents);
- contents->SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(sync_status_label_, 3, 1,
- GridLayout::FILL, GridLayout::LEADING);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(sync_action_link_, 3, 1);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(sync_start_stop_button_);
- layout->AddView(sync_customize_button_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(privacy_dashboard_link_, 3, 1);
-
- sync_group_ = new OptionsGroupView(contents,
- l10n_util::GetString(IDS_SYNC_OPTIONS_GROUP_NAME), std::wstring(), true);
-}
-
-void ContentPageView::UpdateSyncControls() {
- DCHECK(sync_service_);
- std::wstring status_label;
- std::wstring link_label;
- std::wstring customize_button_label;
- std::wstring button_label;
- bool managed = sync_service_->IsManaged();
- bool sync_setup_completed = sync_service_->HasSyncSetupCompleted();
- bool status_has_error = sync_ui_util::GetStatusLabels(sync_service_,
- &status_label, &link_label) == sync_ui_util::SYNC_ERROR;
- customize_button_label =
- l10n_util::GetString(IDS_SYNC_CUSTOMIZE_BUTTON_LABEL);
- if (sync_setup_completed) {
- button_label = l10n_util::GetString(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL);
- } else if (sync_service_->SetupInProgress()) {
- button_label = l10n_util::GetString(IDS_SYNC_NTP_SETUP_IN_PROGRESS);
- } else {
- button_label = l10n_util::GetString(IDS_SYNC_START_SYNC_BUTTON_LABEL);
- }
-
- sync_status_label_->SetText(status_label);
- sync_start_stop_button_->SetEnabled(
- !sync_service_->WizardIsVisible() && !managed);
- sync_start_stop_button_->SetLabel(button_label);
- sync_customize_button_->SetLabel(customize_button_label);
- sync_customize_button_->SetVisible(sync_setup_completed && !status_has_error);
- sync_customize_button_->SetEnabled(!managed);
- sync_action_link_->SetText(link_label);
- sync_action_link_->SetVisible(!link_label.empty());
- sync_action_link_->SetEnabled(!managed);
-
- if (status_has_error) {
- sync_status_label_->set_background(CreateErrorBackground());
- sync_action_link_->set_background(CreateErrorBackground());
- } else {
- sync_status_label_->set_background(NULL);
- sync_action_link_->set_background(NULL);
- }
-}
diff --git a/chrome/browser/views/options/content_page_view.h b/chrome/browser/views/options/content_page_view.h
index 181f8a1..1335775 100644
--- a/chrome/browser/views/options/content_page_view.h
+++ b/chrome/browser/views/options/content_page_view.h
@@ -6,112 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_PAGE_VIEW_H_
#pragma once
-#include "chrome/browser/autofill/personal_data_manager.h"
-#include "chrome/browser/prefs/pref_member.h"
-#include "chrome/browser/sync/profile_sync_service.h"
-#include "chrome/browser/views/options/options_page_view.h"
-#include "chrome/browser/views/confirm_message_box_dialog.h"
-#include "views/controls/button/button.h"
-#include "views/controls/link.h"
-#include "views/view.h"
-
-namespace views {
-class Checkbox;
-class Label;
-class NativeButton;
-class RadioButton;
-}
-class FileDisplayArea;
-class OptionsGroupView;
-class PrefService;
-
-////////////////////////////////////////////////////////////////////////////////
-// ContentPageView
-
-class ContentPageView : public OptionsPageView,
- public views::LinkController,
- public ProfileSyncServiceObserver,
- public views::ButtonListener,
- public ConfirmMessageBoxObserver {
- public:
- explicit ContentPageView(Profile* profile);
- virtual ~ContentPageView();
-
- // views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // views::LinkController method.
- virtual void LinkActivated(views::Link* source, int event_flags);
-
- // ConfirmMessageBoxObserver implementation.
- virtual void OnConfirmMessageAccept();
-
- // ProfileSyncServiceObserver method.
- virtual void OnStateChanged();
-
- protected:
- // OptionsPageView implementation:
- virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::string* pref_name);
-
- // views::View overrides:
- virtual void Layout();
-
- private:
- // Updates various sync controls based on the current sync state.
- void UpdateSyncControls();
-
- // Returns whether initialization of controls is done or not.
- bool is_initialized() const {
- // If initialization is already done, all the UI controls data members
- // should be non-NULL. So check for one of them to determine if controls
- // are already initialized or not.
- return sync_group_ != NULL;
- }
-
- // Init all the dialog controls.
- void InitPasswordSavingGroup();
- void InitFormAutofillGroup();
- void InitBrowsingDataGroup();
- void InitThemesGroup();
- void InitSyncGroup();
-
- // Controls for the Password Saving group
- views::NativeButton* show_passwords_button_;
- OptionsGroupView* passwords_group_;
- views::RadioButton* passwords_asktosave_radio_;
- views::RadioButton* passwords_neversave_radio_;
-
- // Controls for the Form Autofill group
- views::NativeButton* change_autofill_settings_button_;
- OptionsGroupView* form_autofill_group_;
-
- // Controls for the Themes group
- OptionsGroupView* themes_group_;
- views::NativeButton* themes_reset_button_;
- views::Link* themes_gallery_link_;
-
- // Controls for the browsing data group.
- OptionsGroupView* browsing_data_group_;
- views::NativeButton* import_button_;
-
- // Controls for the Sync group.
- OptionsGroupView* sync_group_;
- views::Label* sync_status_label_;
- views::Link* sync_action_link_;
- views::NativeButton* sync_start_stop_button_;
- views::NativeButton* sync_customize_button_;
- views::Link* privacy_dashboard_link_;
-
- BooleanPrefMember ask_to_save_passwords_;
- BooleanPrefMember form_autofill_enabled_;
- StringPrefMember is_using_default_theme_;
-
- // Cached pointer to ProfileSyncService, if it exists. Kept up to date
- // and NULL-ed out on destruction.
- ProfileSyncService* sync_service_;
-
- DISALLOW_COPY_AND_ASSIGN(ContentPageView);
-};
+#include "chrome/browser/ui/views/options/content_page_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_PAGE_VIEW_H_
+
diff --git a/chrome/browser/views/options/content_settings_window_view.cc b/chrome/browser/views/options/content_settings_window_view.cc
deleted file mode 100644
index 2a2146c..0000000
--- a/chrome/browser/views/options/content_settings_window_view.cc
+++ /dev/null
@@ -1,210 +0,0 @@
-// 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/options/content_settings_window_view.h"
-
-#include "app/l10n_util.h"
-#include "base/stl_util-inl.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/views/options/advanced_page_view.h"
-#include "chrome/browser/views/options/content_filter_page_view.h"
-#include "chrome/browser/views/options/cookie_filter_page_view.h"
-#include "chrome/browser/views/options/general_page_view.h"
-#include "chrome/browser/views/options/plugin_filter_page_view.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/pref_names.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "views/controls/label.h"
-#include "views/widget/root_view.h"
-#include "views/window/dialog_delegate.h"
-#include "views/window/window.h"
-
-static ContentSettingsWindowView* instance_ = NULL;
-// Content setting dialog bounds padding.
-const int kDialogPadding = 7;
-
-namespace browser {
-
-// Declared in browser_dialogs.h so others don't have to depend on our header.
-void ShowContentSettingsWindow(gfx::NativeWindow parent_window,
- ContentSettingsType content_type,
- Profile* profile) {
- DCHECK(profile);
- // If there's already an existing options window, activate it and switch to
- // the specified page.
- // TODO(beng): note this is not multi-simultaneous-profile-safe. When we care
- // about this case this will have to be fixed.
- if (!instance_) {
- instance_ = new ContentSettingsWindowView(profile);
- views::Window::CreateChromeWindow(parent_window, gfx::Rect(), instance_);
- }
- instance_->ShowContentSettingsTab(content_type);
-}
-
-} // namespace browser
-
-ContentSettingsWindowView::ContentSettingsWindowView(Profile* profile)
- // Always show preferences for the original profile. Most state when off
- // the record comes from the original profile, but we explicitly use
- // the original profile to avoid potential problems.
- : profile_(profile->GetOriginalProfile()),
- label_(NULL),
- listbox_(NULL),
- current_page_(0) {
- // We don't need to observe changes in this value.
- last_selected_page_.Init(prefs::kContentSettingsWindowLastTabIndex,
- profile->GetPrefs(), NULL);
-}
-
-ContentSettingsWindowView::~ContentSettingsWindowView() {
- STLDeleteElements(&pages_);
-}
-
-void ContentSettingsWindowView::ShowContentSettingsTab(
- ContentSettingsType page) {
- // This will show invisible windows and bring visible windows to the front.
- window()->Show();
-
- if (page == CONTENT_SETTINGS_TYPE_DEFAULT) {
- // Remember the last visited page from local state.
- page = static_cast<ContentSettingsType>(last_selected_page_.GetValue());
- if (page == CONTENT_SETTINGS_TYPE_DEFAULT)
- page = CONTENT_SETTINGS_TYPE_COOKIES;
- }
- // If the page number is out of bounds, reset to the first tab.
- if (page < 0 || page >= listbox_->GetRowCount())
- page = CONTENT_SETTINGS_TYPE_COOKIES;
-
- listbox_->SelectRow(static_cast<int>(page));
- ShowSettingsPage(listbox_->SelectedRow());
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ContentSettingsWindowView, views::DialogDelegate implementation:
-
-std::wstring ContentSettingsWindowView::GetWindowTitle() const {
- return l10n_util::GetString(IDS_CONTENT_SETTINGS_TITLE);
-}
-
-void ContentSettingsWindowView::WindowClosing() {
- instance_ = NULL;
-}
-
-bool ContentSettingsWindowView::Cancel() {
- return GetCurrentContentSettingsTabView()->CanClose();
-}
-
-views::View* ContentSettingsWindowView::GetContentsView() {
- return this;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ContentSettingsWindowView, views::Listbox::Listener implementation:
-
-void ContentSettingsWindowView::ListboxSelectionChanged(
- views::Listbox* sender) {
- DCHECK_EQ(listbox_, sender);
- ShowSettingsPage(listbox_->SelectedRow());
- last_selected_page_.SetValue(current_page_);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ContentSettingsWindowView, views::View overrides:
-
-void ContentSettingsWindowView::Layout() {
- int listbox_width = views::Window::GetLocalizedContentsWidth(
- IDS_CONTENT_SETTINGS_DIALOG_LISTBOX_WIDTH_CHARS);
- label_->SetBounds(kDialogPadding,
- kDialogPadding,
- listbox_width,
- label_->GetPreferredSize().height());
-
- listbox_->SetBounds(kDialogPadding,
- 2 * kDialogPadding + label_->height(),
- listbox_width,
- height() - (3 * kDialogPadding) - label_->height());
-
- if (pages_[current_page_]->GetParent()) {
- pages_[current_page_]->SetBounds(
- 2 * kDialogPadding + listbox_width,
- 2 * kDialogPadding + label_->height(),
- width() - (3 * kDialogPadding) - listbox_width,
- height() - (2 * kDialogPadding));
- }
-}
-
-gfx::Size ContentSettingsWindowView::GetPreferredSize() {
- return gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_CONTENT_SETTINGS_DIALOG_WIDTH_CHARS,
- IDS_CONTENT_SETTINGS_DIALOG_HEIGHT_LINES));
-}
-
-void ContentSettingsWindowView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- // Can't init before we're inserted into a Container, because we require a
- // HWND to parent native child controls to.
- if (is_add && child == this)
- Init();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ContentSettingsWindowView, private:
-
-void ContentSettingsWindowView::Init() {
- // Make sure we don't leak memory by calling this twice.
- DCHECK(!listbox_);
-
- label_ = new views::Label(
- l10n_util::GetStringUTF16(IDS_CONTENT_SETTINGS_FEATURES_LABEL));
- label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- AddChildView(label_);
-
- pages_.push_back(new CookieFilterPageView(profile_));
- pages_.push_back(
- new ContentFilterPageView(profile_, CONTENT_SETTINGS_TYPE_IMAGES));
- pages_.push_back(
- new ContentFilterPageView(profile_, CONTENT_SETTINGS_TYPE_JAVASCRIPT));
- pages_.push_back(new PluginFilterPageView(profile_));
- pages_.push_back(
- new ContentFilterPageView(profile_, CONTENT_SETTINGS_TYPE_POPUPS));
- pages_.push_back(
- new ContentFilterPageView(profile_, CONTENT_SETTINGS_TYPE_GEOLOCATION));
- pages_.push_back(
- new ContentFilterPageView(profile_, CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
- for (size_t i = 0; i < pages_.size(); ++i) {
- pages_[i]->set_parent_owned(false);
- }
- DCHECK_EQ(static_cast<int>(pages_.size()), CONTENT_SETTINGS_NUM_TYPES);
-
- std::vector<string16> strings;
- strings.push_back(l10n_util::GetStringUTF16(IDS_COOKIES_TAB_LABEL));
- strings.push_back(l10n_util::GetStringUTF16(IDS_IMAGES_TAB_LABEL));
- strings.push_back(l10n_util::GetStringUTF16(IDS_JAVASCRIPT_TAB_LABEL));
- strings.push_back(l10n_util::GetStringUTF16(IDS_PLUGIN_TAB_LABEL));
- strings.push_back(l10n_util::GetStringUTF16(IDS_POPUP_TAB_LABEL));
- strings.push_back(l10n_util::GetStringUTF16(IDS_GEOLOCATION_TAB_LABEL));
- strings.push_back(l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_TAB_LABEL));
- listbox_ = new views::Listbox(strings, this);
- AddChildView(listbox_);
- CHECK_EQ(strings.size(), pages_.size());
-}
-
-void ContentSettingsWindowView::ShowSettingsPage(int page) {
- if (pages_[current_page_]->GetParent())
- RemoveChildView(pages_[current_page_]);
- current_page_ = page;
- AddChildView(pages_[current_page_]);
- Layout();
- SchedulePaint();
-}
-
-const OptionsPageView*
- ContentSettingsWindowView::GetCurrentContentSettingsTabView() const {
- return static_cast<OptionsPageView*>(pages_[current_page_]);
-}
diff --git a/chrome/browser/views/options/content_settings_window_view.h b/chrome/browser/views/options/content_settings_window_view.h
index 2b843b4..a3bc919 100644
--- a/chrome/browser/views/options/content_settings_window_view.h
+++ b/chrome/browser/views/options/content_settings_window_view.h
@@ -6,87 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_SETTINGS_WINDOW_VIEW_H_
#pragma once
-#include "chrome/browser/prefs/pref_member.h"
-#include "chrome/common/content_settings_types.h"
-#include "views/controls/listbox/listbox.h"
-#include "views/view.h"
-#include "views/window/dialog_delegate.h"
-
-class Profile;
-class MessageLoop;
-class OptionsPageView;
-
-namespace views {
-class Label;
-} // namespace views
-
-///////////////////////////////////////////////////////////////////////////////
-// ContentSettingsWindowView
-//
-// The contents of the Options dialog window.
-//
-class ContentSettingsWindowView : public views::View,
- public views::DialogDelegate,
- public views::Listbox::Listener {
- public:
- explicit ContentSettingsWindowView(Profile* profile);
- virtual ~ContentSettingsWindowView();
-
- // Shows the Tab corresponding to the specified Content Settings page.
- void ShowContentSettingsTab(ContentSettingsType page);
-
- protected:
- // views::View overrides:
- virtual void Layout();
- virtual gfx::Size GetPreferredSize();
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
-
- // views::DialogDelegate implementation:
- virtual int GetDialogButtons() const {
- return MessageBoxFlags::DIALOGBUTTON_CANCEL;
- }
- virtual std::wstring GetWindowTitle() const;
- virtual void WindowClosing();
- virtual bool Cancel();
- virtual views::View* GetContentsView();
-
- // views::Listbox::Listener implementation:
- virtual void ListboxSelectionChanged(views::Listbox* sender);
-
- private:
- // Initializes the view.
- void Init();
-
- // Makes |pages_[page]| the currently visible page.
- void ShowSettingsPage(int page);
-
- // Returns the currently selected OptionsPageView.
- const OptionsPageView* GetCurrentContentSettingsTabView() const;
-
- // The Profile associated with these options.
- Profile* profile_;
-
- // The label above the left box.
- views::Label* label_;
-
- // The listbox used to select a page.
- views::Listbox* listbox_;
-
- // The last page the user was on when they opened the Options window.
- IntegerPrefMember last_selected_page_;
-
- // Stores the index of the currently visible page.
- int current_page_;
-
- // Stores the possible content pages displayed on the right.
- // |pages_[current_page_]| is the currently displayed page, and it's the only
- // parented View in |pages_|.
- std::vector<View*> pages_;
-
- DISALLOW_COPY_AND_ASSIGN(ContentSettingsWindowView);
-};
+#include "chrome/browser/ui/views/options/content_settings_window_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_SETTINGS_WINDOW_VIEW_H_
diff --git a/chrome/browser/views/options/cookie_filter_page_view.cc b/chrome/browser/views/options/cookie_filter_page_view.cc
deleted file mode 100644
index d8ab81b..0000000
--- a/chrome/browser/views/options/cookie_filter_page_view.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-// 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/options/cookie_filter_page_view.h"
-
-#include "app/l10n_util.h"
-#include "chrome/browser/host_content_settings_map.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/show_options_url.h"
-#include "chrome/browser/views/options/cookies_view.h"
-#include "chrome/common/pref_names.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "views/controls/button/checkbox.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-
-CookieFilterPageView::CookieFilterPageView(Profile* profile)
- : ContentFilterPageView(profile, CONTENT_SETTINGS_TYPE_COOKIES),
- block_3rdparty_check_(NULL),
- clear_on_close_check_(NULL),
- show_cookies_button_(NULL) {
- clear_site_data_on_exit_.Init(prefs::kClearSiteDataOnExit,
- profile->GetPrefs(), NULL);
-}
-
-CookieFilterPageView::~CookieFilterPageView() {
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookieFilterPageView, ContentFilterPageView override:
-
-void CookieFilterPageView::InitControlLayout() {
- ContentFilterPageView::InitControlLayout();
-
- using views::GridLayout;
-
- GridLayout* layout = static_cast<GridLayout*>(GetLayoutManager());
- const int single_column_set_id = 0;
- layout->AddPaddingRow(0, kUnrelatedControlLargeVerticalSpacing);
-
- block_3rdparty_check_ = new views::Checkbox(
- l10n_util::GetString(IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX));
- block_3rdparty_check_->set_listener(this);
-
- layout->StartRow(0, single_column_set_id);
- layout->AddView(block_3rdparty_check_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- // Now that this has been added to the view hierarchy, it's safe to call
- // SetChecked() on it.
- block_3rdparty_check_->SetChecked(
- profile()->GetHostContentSettingsMap()->BlockThirdPartyCookies());
-
- clear_on_close_check_ = new views::Checkbox(
- l10n_util::GetString(IDS_COOKIES_CLEAR_WHEN_CLOSE_CHKBOX));
- clear_on_close_check_->SetMultiLine(true);
- clear_on_close_check_->set_listener(this);
-
- layout->StartRow(0, single_column_set_id);
- layout->AddView(clear_on_close_check_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- show_cookies_button_ = new views::NativeButton(this,
- l10n_util::GetString(IDS_COOKIES_SHOW_COOKIES_BUTTON));
-
- layout->StartRow(0, single_column_set_id);
- layout->AddView(show_cookies_button_, 1, 1, GridLayout::LEADING,
- GridLayout::FILL);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- views::Link* flash_settings_link = new views::Link(
- l10n_util::GetString(IDS_FLASH_STORAGE_SETTINGS));
- flash_settings_link->SetController(this);
-
- layout->StartRow(0, single_column_set_id);
- layout->AddView(flash_settings_link, 1, 1, GridLayout::LEADING,
- GridLayout::FILL);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookieFilterPageView, OptionsPageView implementation:
-
-void CookieFilterPageView::NotifyPrefChanged(const std::string* pref_name) {
- if (!pref_name || *pref_name == prefs::kClearSiteDataOnExit) {
- clear_on_close_check_->SetChecked(
- clear_site_data_on_exit_.GetValue());
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookieFilterPageView, views::ButtonListener implementation:
-
-void CookieFilterPageView::ButtonPressed(views::Button* sender,
- const views::Event& event) {
- HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap();
- if (sender == block_3rdparty_check_) {
- settings_map->SetBlockThirdPartyCookies(block_3rdparty_check_->checked());
- } else if (sender == clear_on_close_check_) {
- clear_site_data_on_exit_.SetValue(clear_on_close_check_->checked());
- } else if (sender == show_cookies_button_) {
- UserMetricsRecordAction(UserMetricsAction("Options_ShowCookies"), NULL);
- CookiesView::ShowCookiesWindow(profile());
- } else {
- ContentFilterPageView::ButtonPressed(sender, event);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookieFilterPageView, views::LinkController implementation:
-
-void CookieFilterPageView::LinkActivated(views::Link* source, int event_flags) {
- browser::ShowOptionsURL(profile(),
- GURL(l10n_util::GetString(IDS_FLASH_STORAGE_URL)));
-}
diff --git a/chrome/browser/views/options/cookie_filter_page_view.h b/chrome/browser/views/options/cookie_filter_page_view.h
index 0b9b9f7..3168e0e 100644
--- a/chrome/browser/views/options/cookie_filter_page_view.h
+++ b/chrome/browser/views/options/cookie_filter_page_view.h
@@ -6,47 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_COOKIE_FILTER_PAGE_VIEW_H_
#pragma once
-#include "chrome/browser/views/options/content_filter_page_view.h"
-
-#include "chrome/browser/prefs/pref_member.h"
-
-namespace views {
-class Checkbox;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// CookieFilterPageView class is used to render the cookie content settings tab.
-
-class CookieFilterPageView : public ContentFilterPageView,
- public views::LinkController {
- public:
- explicit CookieFilterPageView(Profile* profile);
- virtual ~CookieFilterPageView();
-
- private:
- // Overridden from ContentFilterPageView:
- virtual void InitControlLayout();
-
- // OptionsPageView implementation:
- virtual void NotifyPrefChanged(const std::string* pref_name);
-
- // views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // Overridden from views::LinkController:
- virtual void LinkActivated(views::Link* source, int event_flags);
-
- private:
- // Controls for the cookie filter tab page view.
- views::Checkbox* block_3rdparty_check_;
- views::Checkbox* clear_on_close_check_;
- views::NativeButton* show_cookies_button_;
-
- // Clear locally stored site data on exit pref.
- BooleanPrefMember clear_site_data_on_exit_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(CookieFilterPageView);
-};
+#include "chrome/browser/ui/views/options/cookie_filter_page_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_COOKIE_FILTER_PAGE_VIEW_H_
diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc
deleted file mode 100644
index 5e2b6d0..0000000
--- a/chrome/browser/views/options/cookies_view.cc
+++ /dev/null
@@ -1,397 +0,0 @@
-// 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/options/cookies_view.h"
-
-#include <algorithm>
-
-#include "app/l10n_util.h"
-#include "base/message_loop.h"
-#include "base/string_util.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/views/appcache_info_view.h"
-#include "chrome/browser/views/cookie_info_view.h"
-#include "chrome/browser/views/database_info_view.h"
-#include "chrome/browser/views/indexed_db_info_view.h"
-#include "chrome/browser/views/local_storage_info_view.h"
-#include "gfx/canvas.h"
-#include "gfx/color_utils.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "net/base/cookie_monster.h"
-#include "views/border.h"
-#include "views/grid_layout.h"
-#include "views/controls/label.h"
-#include "views/controls/button/native_button.h"
-#include "views/controls/tree/tree_view.h"
-#include "views/controls/textfield/textfield.h"
-#include "views/standard_layout.h"
-
-// static
-views::Window* CookiesView::instance_ = NULL;
-static const int kSearchFilterDelayMs = 500;
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesTreeView
-// Overridden to handle Delete key presses
-
-class CookiesTreeView : public views::TreeView {
- public:
- explicit CookiesTreeView(CookiesTreeModel* cookies_model);
- virtual ~CookiesTreeView() {}
-
- // Removes the items associated with the selected node in the TreeView
- void RemoveSelectedItems();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CookiesTreeView);
-};
-
-CookiesTreeView::CookiesTreeView(CookiesTreeModel* cookies_model) {
- SetModel(cookies_model);
- SetRootShown(false);
- SetEditable(false);
-}
-
-void CookiesTreeView::RemoveSelectedItems() {
- TreeModelNode* selected_node = GetSelectedNode();
- if (selected_node) {
- static_cast<CookiesTreeModel*>(model())->DeleteCookieNode(
- static_cast<CookieTreeNode*>(GetSelectedNode()));
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesView::InfoPanelView
-// Overridden to handle layout of the various info views.
-//
-// This view is a child of the CookiesView and participates
-// in its GridLayout. The various info views are all children
-// of this view. Only one child is expected to be visible at a time.
-
-class CookiesView::InfoPanelView : public views::View {
- public:
- virtual void Layout() {
- int child_count = GetChildViewCount();
- for (int i = 0; i < child_count; ++i)
- GetChildViewAt(i)->SetBounds(0, 0, width(), height());
- }
-
- virtual gfx::Size GetPreferredSize() {
- DCHECK(GetChildViewCount() > 0);
- return GetChildViewAt(0)->GetPreferredSize();
- }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesView, public:
-
-// static
-void CookiesView::ShowCookiesWindow(Profile* profile) {
- if (!instance_) {
- CookiesView* cookies_view = new CookiesView(profile);
- instance_ = views::Window::CreateChromeWindow(
- NULL, gfx::Rect(), cookies_view);
- }
- if (!instance_->IsVisible()) {
- instance_->Show();
- } else {
- instance_->Activate();
- }
-}
-
-CookiesView::~CookiesView() {
- cookies_tree_->SetModel(NULL);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesView, TreeModelObserver overrides:
-
-void CookiesView::TreeNodesAdded(TreeModel* model,
- TreeModelNode* parent,
- int start,
- int count) {
- UpdateRemoveButtonsState();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesView, views::Buttonlistener implementation:
-
-void CookiesView::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (sender == remove_button_) {
- cookies_tree_->RemoveSelectedItems();
- if (cookies_tree_model_->GetRoot()->GetChildCount() == 0)
- UpdateForEmptyState();
- } else if (sender == remove_all_button_) {
- cookies_tree_model_->DeleteAllStoredObjects();
- UpdateForEmptyState();
- } else if (sender == clear_search_button_) {
- ResetSearchQuery();
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesView, views::Textfield::Controller implementation:
-
-void CookiesView::ContentsChanged(views::Textfield* sender,
- const std::wstring& new_contents) {
- clear_search_button_->SetEnabled(!search_field_->text().empty());
- search_update_factory_.RevokeAll();
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- search_update_factory_.NewRunnableMethod(
- &CookiesView::UpdateSearchResults), kSearchFilterDelayMs);
-}
-
-bool CookiesView::HandleKeystroke(views::Textfield* sender,
- const views::Textfield::Keystroke& key) {
- if (key.GetKeyboardCode() == app::VKEY_ESCAPE) {
- ResetSearchQuery();
- } else if (key.GetKeyboardCode() == app::VKEY_RETURN) {
- search_update_factory_.RevokeAll();
- UpdateSearchResults();
- }
- return false;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesView, views::DialogDelegate implementation:
-
-std::wstring CookiesView::GetWindowTitle() const {
- return l10n_util::GetString(IDS_COOKIES_WEBSITE_PERMISSIONS_WINDOW_TITLE);
-}
-
-void CookiesView::WindowClosing() {
- instance_ = NULL;
-}
-
-views::View* CookiesView::GetContentsView() {
- return this;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesView, views::View overrides:
-
-void CookiesView::Layout() {
- // Lay out the Remove/Remove All buttons in the parent view.
- gfx::Size ps = remove_button_->GetPreferredSize();
- gfx::Rect parent_bounds = GetParent()->GetLocalBounds(false);
- int y_buttons = parent_bounds.bottom() - ps.height() - kButtonVEdgeMargin;
-
- remove_button_->SetBounds(kPanelHorizMargin, y_buttons, ps.width(),
- ps.height());
-
- ps = remove_all_button_->GetPreferredSize();
- int remove_all_x = remove_button_->x() + remove_button_->width() +
- kRelatedControlHorizontalSpacing;
- remove_all_button_->SetBounds(remove_all_x, y_buttons, ps.width(),
- ps.height());
-
- // Lay out this View
- View::Layout();
-}
-
-gfx::Size CookiesView::GetPreferredSize() {
- return gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_COOKIES_DIALOG_WIDTH_CHARS,
- IDS_COOKIES_DIALOG_HEIGHT_LINES));
-}
-
-void CookiesView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- if (is_add && child == this)
- Init();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesView, views::TreeViewController overrides:
-
-void CookiesView::OnTreeViewSelectionChanged(views::TreeView* tree_view) {
- UpdateRemoveButtonsState();
- CookieTreeNode::DetailedInfo detailed_info =
- static_cast<CookieTreeNode*>(tree_view->GetSelectedNode())->
- GetDetailedInfo();
- if (detailed_info.node_type == CookieTreeNode::DetailedInfo::TYPE_COOKIE) {
- UpdateVisibleDetailedInfo(cookie_info_view_);
- cookie_info_view_->SetCookie(detailed_info.cookie->Domain(),
- *detailed_info.cookie);
- } else if (detailed_info.node_type ==
- CookieTreeNode::DetailedInfo::TYPE_DATABASE) {
- UpdateVisibleDetailedInfo(database_info_view_);
- database_info_view_->SetDatabaseInfo(*detailed_info.database_info);
- } else if (detailed_info.node_type ==
- CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE) {
- UpdateVisibleDetailedInfo(local_storage_info_view_);
- local_storage_info_view_->SetLocalStorageInfo(
- *detailed_info.local_storage_info);
- } else if (detailed_info.node_type ==
- CookieTreeNode::DetailedInfo::TYPE_APPCACHE) {
- UpdateVisibleDetailedInfo(appcache_info_view_);
- appcache_info_view_->SetAppCacheInfo(detailed_info.appcache_info);
- } else if (detailed_info.node_type ==
- CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB) {
- UpdateVisibleDetailedInfo(indexed_db_info_view_);
- indexed_db_info_view_->SetIndexedDBInfo(*detailed_info.indexed_db_info);
- } else {
- UpdateVisibleDetailedInfo(cookie_info_view_);
- cookie_info_view_->ClearCookieDisplay();
- }
-}
-
-void CookiesView::OnTreeViewKeyDown(app::KeyboardCode keycode) {
- if (keycode == app::VKEY_DELETE)
- cookies_tree_->RemoveSelectedItems();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesView, public:
-
-void CookiesView::UpdateSearchResults() {
- cookies_tree_model_->UpdateSearchResults(search_field_->text());
- UpdateRemoveButtonsState();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesView, private:
-
-CookiesView::CookiesView(Profile* profile)
- :
- search_label_(NULL),
- search_field_(NULL),
- clear_search_button_(NULL),
- description_label_(NULL),
- cookies_tree_(NULL),
- info_panel_(NULL),
- cookie_info_view_(NULL),
- database_info_view_(NULL),
- local_storage_info_view_(NULL),
- appcache_info_view_(NULL),
- indexed_db_info_view_(NULL),
- remove_button_(NULL),
- remove_all_button_(NULL),
- profile_(profile),
- ALLOW_THIS_IN_INITIALIZER_LIST(search_update_factory_(this)) {
-}
-
-void CookiesView::Init() {
- search_label_ = new views::Label(
- l10n_util::GetString(IDS_COOKIES_SEARCH_LABEL));
- search_field_ = new views::Textfield;
- search_field_->SetController(this);
- clear_search_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_COOKIES_CLEAR_SEARCH_LABEL));
- clear_search_button_->SetEnabled(false);
- description_label_ = new views::Label(
- l10n_util::GetString(IDS_COOKIES_INFO_LABEL));
- description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- cookies_tree_model_.reset(new CookiesTreeModel(
- profile_->GetRequestContext()->GetCookieStore()->GetCookieMonster(),
- new BrowsingDataDatabaseHelper(profile_),
- new BrowsingDataLocalStorageHelper(profile_),
- NULL,
- new BrowsingDataAppCacheHelper(profile_),
- BrowsingDataIndexedDBHelper::Create(profile_)));
- cookies_tree_model_->AddObserver(this);
-
- info_panel_ = new InfoPanelView;
- cookie_info_view_ = new CookieInfoView(false);
- database_info_view_ = new DatabaseInfoView;
- local_storage_info_view_ = new LocalStorageInfoView;
- appcache_info_view_ = new AppCacheInfoView;
- indexed_db_info_view_ = new IndexedDBInfoView;
- info_panel_->AddChildView(cookie_info_view_);
- info_panel_->AddChildView(database_info_view_);
- info_panel_->AddChildView(local_storage_info_view_);
- info_panel_->AddChildView(appcache_info_view_);
- info_panel_->AddChildView(indexed_db_info_view_);
-
- cookies_tree_ = new CookiesTreeView(cookies_tree_model_.get());
- remove_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_COOKIES_REMOVE_LABEL));
- remove_all_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_COOKIES_REMOVE_ALL_LABEL));
-
- using views::GridLayout;
- using views::ColumnSet;
-
- GridLayout* layout = CreatePanelGridLayout(this);
- SetLayoutManager(layout);
-
- const int five_column_layout_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(five_column_layout_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
- GridLayout::USE_PREF, 0, 0);
-
- const int single_column_layout_id = 1;
- column_set = layout->AddColumnSet(single_column_layout_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, five_column_layout_id);
- layout->AddView(search_label_);
- layout->AddView(search_field_);
- layout->AddView(clear_search_button_);
- layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
-
- layout->StartRow(0, single_column_layout_id);
- layout->AddView(description_label_);
-
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(1, single_column_layout_id);
- cookies_tree_->set_lines_at_root(true);
- cookies_tree_->set_auto_expand_children(true);
- layout->AddView(cookies_tree_);
-
- cookies_tree_->SetController(this);
-
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_layout_id);
- layout->AddView(info_panel_);
-
- // Add the Remove/Remove All buttons to the ClientView
- View* parent = GetParent();
- parent->AddChildView(remove_button_);
- parent->AddChildView(remove_all_button_);
- if (!cookies_tree_model_.get()->GetRoot()->GetChildCount()) {
- UpdateForEmptyState();
- } else {
- UpdateVisibleDetailedInfo(cookie_info_view_);
- UpdateRemoveButtonsState();
- }
-}
-
-void CookiesView::ResetSearchQuery() {
- search_field_->SetText(std::wstring());
- clear_search_button_->SetEnabled(false);
- UpdateSearchResults();
-}
-
-void CookiesView::UpdateForEmptyState() {
- cookie_info_view_->ClearCookieDisplay();
- remove_button_->SetEnabled(false);
- remove_all_button_->SetEnabled(false);
- UpdateVisibleDetailedInfo(cookie_info_view_);
-}
-
-void CookiesView::UpdateRemoveButtonsState() {
- remove_button_->SetEnabled(cookies_tree_model_->GetRoot()->
- GetTotalNodeCount() > 1 && cookies_tree_->GetSelectedNode());
- remove_all_button_->SetEnabled(cookies_tree_model_->GetRoot()->
- GetTotalNodeCount() > 1);
-}
-
-void CookiesView::UpdateVisibleDetailedInfo(views::View* view) {
- cookie_info_view_->SetVisible(view == cookie_info_view_);
- database_info_view_->SetVisible(view == database_info_view_);
- local_storage_info_view_->SetVisible(view == local_storage_info_view_);
- appcache_info_view_->SetVisible(view == appcache_info_view_);
- indexed_db_info_view_->SetVisible(view == indexed_db_info_view_);
-}
diff --git a/chrome/browser/views/options/cookies_view.h b/chrome/browser/views/options/cookies_view.h
index dc6b9ff..dd74019 100644
--- a/chrome/browser/views/options/cookies_view.h
+++ b/chrome/browser/views/options/cookies_view.h
@@ -6,154 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H_
#pragma once
-#include <string>
-
-#include "base/task.h"
-#include "chrome/browser/cookies_tree_model.h"
-#include "net/base/cookie_monster.h"
-#include "views/controls/button/button.h"
-#include "views/controls/tree/tree_view.h"
-#include "views/controls/textfield/textfield.h"
-#include "views/view.h"
-#include "views/window/dialog_delegate.h"
-#include "views/window/window.h"
-
-namespace views {
-
-class Label;
-class NativeButton;
-
-} // namespace views
-
-
-class AppCacheInfoView;
-class CookieInfoView;
-class CookiesTreeView;
-class DatabaseInfoView;
-class IndexedDBInfoView;
-class LocalStorageInfoView;
-class Profile;
-class Timer;
-class TreeModel;
-class TreeModelNode;
-
-
-class CookiesView : public CookiesTreeModel::Observer,
- public views::View,
- public views::DialogDelegate,
- public views::ButtonListener,
- public views::TreeViewController,
- public views::Textfield::Controller {
- public:
- // Show the Cookies Window, creating one if necessary.
- static void ShowCookiesWindow(Profile* profile);
-
- virtual ~CookiesView();
-
- // Updates the display to show only the search results.
- void UpdateSearchResults();
-
- // Begin TreeModelObserver implementation.
- virtual void TreeNodesAdded(TreeModel* model,
- TreeModelNode* parent,
- int start,
- int count);
- virtual void TreeNodesRemoved(TreeModel* model,
- TreeModelNode* parent,
- int start,
- int count) {}
- virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node) {}
- // End TreeModelObserver implementation.
-
- // views::ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // views::TreeViewController implementation.
- virtual void OnTreeViewSelectionChanged(views::TreeView* tree_view);
-
- // views::TreeViewController implementation.
- virtual void OnTreeViewKeyDown(app::KeyboardCode keycode);
-
- // views::Textfield::Controller implementation.
- virtual void ContentsChanged(views::Textfield* sender,
- const std::wstring& new_contents);
- virtual bool HandleKeystroke(views::Textfield* sender,
- const views::Textfield::Keystroke& key);
-
- // views::WindowDelegate implementation.
- virtual int GetDialogButtons() const {
- return MessageBoxFlags::DIALOGBUTTON_CANCEL;
- }
- virtual views::View* GetInitiallyFocusedView() {
- return search_field_;
- }
-
- virtual bool CanResize() const { return true; }
- virtual std::wstring GetWindowTitle() const;
- virtual void WindowClosing();
- virtual views::View* GetContentsView();
-
- // views::View overrides:
- virtual void Layout();
- virtual gfx::Size GetPreferredSize();
-
- protected:
- // views::View overrides:
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
-
- private:
- class InfoPanelView;
-
- // Use the static factory method to show.
- explicit CookiesView(Profile* profile);
-
- // Initialize the dialog contents and layout.
- void Init();
-
- // Resets the display to what it would be if there were no search query.
- void ResetSearchQuery();
-
- // Update the UI when there are no cookies.
- void UpdateForEmptyState();
-
- // Enable or disable the remove and remove all buttons.
- void UpdateRemoveButtonsState();
-
- // Updates view to be visible inside detailed_info_view_;
- void UpdateVisibleDetailedInfo(views::View* view);
-
- // Assorted dialog controls
- views::Label* search_label_;
- views::Textfield* search_field_;
- views::NativeButton* clear_search_button_;
- views::Label* description_label_;
- CookiesTreeView* cookies_tree_;
- InfoPanelView* info_panel_;
- CookieInfoView* cookie_info_view_;
- DatabaseInfoView* database_info_view_;
- LocalStorageInfoView* local_storage_info_view_;
- AppCacheInfoView* appcache_info_view_;
- IndexedDBInfoView* indexed_db_info_view_;
- views::NativeButton* remove_button_;
- views::NativeButton* remove_all_button_;
-
- // The Cookies Tree model
- scoped_ptr<CookiesTreeModel> cookies_tree_model_;
-
- // The Profile for which Cookies are displayed
- Profile* profile_;
-
- // A factory to construct Runnable Methods so that we can be called back to
- // re-evaluate the model after the search query string changes.
- ScopedRunnableMethodFactory<CookiesView> search_update_factory_;
-
- // Our containing window. If this is non-NULL there is a visible Cookies
- // window somewhere.
- static views::Window* instance_;
-
- DISALLOW_COPY_AND_ASSIGN(CookiesView);
-};
+#include "chrome/browser/ui/views/options/cookies_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H_
+
diff --git a/chrome/browser/views/options/exception_editor_view.cc b/chrome/browser/views/options/exception_editor_view.cc
deleted file mode 100644
index 93ca859..0000000
--- a/chrome/browser/views/options/exception_editor_view.cc
+++ /dev/null
@@ -1,175 +0,0 @@
-// 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/options/exception_editor_view.h"
-
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/content_exceptions_table_model.h"
-#include "googleurl/src/url_canon.h"
-#include "googleurl/src/url_parse.h"
-#include "grit/app_resources.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "views/grid_layout.h"
-#include "views/controls/image_view.h"
-#include "views/controls/label.h"
-#include "views/standard_layout.h"
-#include "views/window/window.h"
-
-ExceptionEditorView::ExceptionEditorView(
- Delegate* delegate,
- ContentExceptionsTableModel* model,
- bool allow_off_the_record,
- int index,
- const HostContentSettingsMap::Pattern& pattern,
- ContentSetting setting,
- bool is_off_the_record)
- : delegate_(delegate),
- model_(model),
- cb_model_(model->content_type()),
- allow_off_the_record_(allow_off_the_record),
- index_(index),
- pattern_(pattern),
- setting_(setting),
- is_off_the_record_(is_off_the_record) {
- // Geolocation exceptions are handled by SimpleContentExceptionsView.
- DCHECK_NE(setting_, CONTENT_SETTINGS_TYPE_GEOLOCATION);
- // Notification exceptions are handled by SimpleContentExceptionsView.
- DCHECK_NE(setting_, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
- Init();
-}
-
-void ExceptionEditorView::Show(gfx::NativeWindow parent) {
- views::Window* window =
- views::Window::CreateChromeWindow(parent, gfx::Rect(), this);
- window->Show();
- GetDialogClientView()->UpdateDialogButtons();
- pattern_tf_->SelectAll();
- pattern_tf_->RequestFocus();
-}
-
-bool ExceptionEditorView::IsModal() const {
- return true;
-}
-
-std::wstring ExceptionEditorView::GetWindowTitle() const {
- return is_new() ? l10n_util::GetString(IDS_EXCEPTION_EDITOR_NEW_TITLE) :
- l10n_util::GetString(IDS_EXCEPTION_EDITOR_TITLE);
-}
-
-bool ExceptionEditorView::IsDialogButtonEnabled(
- MessageBoxFlags::DialogButton button) const {
- if (button == MessageBoxFlags::DIALOGBUTTON_OK) {
- return IsPatternValid(HostContentSettingsMap::Pattern(
- UTF16ToUTF8(pattern_tf_->text())),
- incognito_cb_->checked());
- }
- return true;
-}
-
-bool ExceptionEditorView::Cancel() {
- return true;
-}
-
-bool ExceptionEditorView::Accept() {
- HostContentSettingsMap::Pattern new_pattern(UTF16ToUTF8(pattern_tf_->text()));
- ContentSetting setting =
- cb_model_.SettingForIndex(action_cb_->selected_item());
- bool is_off_the_record = incognito_cb_->checked();
- delegate_->AcceptExceptionEdit(
- new_pattern, setting, is_off_the_record, index_, is_new());
- return true;
-}
-
-views::View* ExceptionEditorView::GetContentsView() {
- return this;
-}
-
-void ExceptionEditorView::ContentsChanged(views::Textfield* sender,
- const std::wstring& new_contents) {
- GetDialogClientView()->UpdateDialogButtons();
- UpdateImageView(pattern_iv_, IsPatternValid(HostContentSettingsMap::Pattern(
- UTF16ToUTF8(pattern_tf_->text())), incognito_cb_->checked()));
-}
-
-bool ExceptionEditorView::HandleKeystroke(
- views::Textfield* sender,
- const views::Textfield::Keystroke& key) {
- return false;
-}
-
-void ExceptionEditorView::Init() {
- using views::GridLayout;
-
- pattern_tf_ = new views::Textfield();
- pattern_tf_->SetText(UTF8ToUTF16(pattern_.AsString()));
- pattern_tf_->SetController(this);
-
- pattern_iv_ = new views::ImageView;
-
- UpdateImageView(pattern_iv_, IsPatternValid(HostContentSettingsMap::Pattern(
- UTF16ToUTF8(pattern_tf_->text())), is_off_the_record_));
-
- action_cb_ = new views::Combobox(&cb_model_);
- if (!is_new())
- action_cb_->SetSelectedItem(cb_model_.IndexForSetting(setting_));
-
- incognito_cb_ = new views::Checkbox(
- l10n_util::GetString(IDS_EXCEPTION_EDITOR_OTR_TITLE));
- incognito_cb_->SetChecked(is_off_the_record_);
-
- GridLayout* layout = CreatePanelGridLayout(this);
- SetLayoutManager(layout);
-
- // For the Textfields.
- views::ColumnSet* column_set = layout->AddColumnSet(1);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
-
- // Add the contents.
- layout->StartRow(0, 1);
- layout->AddView(CreateLabel(IDS_EXCEPTION_EDITOR_PATTERN_TITLE));
- layout->AddView(pattern_tf_);
- layout->AddView(pattern_iv_);
-
- layout->StartRowWithPadding(0, 1, 0, kRelatedControlVerticalSpacing);
- layout->AddView(CreateLabel(IDS_EXCEPTION_EDITOR_ACTION_TITLE));
- layout->AddView(action_cb_);
-
- if (allow_off_the_record_) {
- layout->StartRowWithPadding(0, 1, 0, kRelatedControlVerticalSpacing);
- layout->AddView(incognito_cb_, 3, 1, GridLayout::FILL, GridLayout::FILL);
- }
-}
-
-views::Label* ExceptionEditorView::CreateLabel(int message_id) {
- views::Label* label = new views::Label(l10n_util::GetString(message_id));
- label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- return label;
-}
-
-bool ExceptionEditorView::IsPatternValid(
- const HostContentSettingsMap::Pattern& pattern,
- bool is_off_the_record) const {
- bool is_valid_pattern = pattern.IsValid() &&
- (model_->IndexOfExceptionByPattern(pattern, is_off_the_record) == -1);
-
- return is_new() ? is_valid_pattern : (!pattern.AsString().empty() &&
- ((pattern_ == pattern) || is_valid_pattern));
-}
-
-void ExceptionEditorView::UpdateImageView(views::ImageView* image_view,
- bool is_valid) {
- return image_view->SetImage(
- ResourceBundle::GetSharedInstance().GetBitmapNamed(
- is_valid ? IDR_INPUT_GOOD : IDR_INPUT_ALERT));
-}
diff --git a/chrome/browser/views/options/exception_editor_view.h b/chrome/browser/views/options/exception_editor_view.h
index 3dfab19..fb63617 100644
--- a/chrome/browser/views/options/exception_editor_view.h
+++ b/chrome/browser/views/options/exception_editor_view.h
@@ -6,109 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_EXCEPTION_EDITOR_VIEW_H_
#pragma once
-#include <string>
-
-#include "chrome/browser/content_setting_combo_model.h"
-#include "chrome/browser/host_content_settings_map.h"
-#include "chrome/common/content_settings.h"
-#include "chrome/common/content_settings_types.h"
-#include "views/window/dialog_delegate.h"
-#include "views/controls/button/checkbox.h"
-#include "views/controls/combobox/combobox.h"
-#include "views/controls/textfield/textfield.h"
-
-namespace views {
-class ImageView;
-class Label;
-}
-
-class ContentExceptionsTableModel;
-
-// ExceptionEditorView is responsible for showing a dialog that allows the user
-// to create or edit a single content exception. If the user clicks ok the
-// delegate is notified and completes the edit.
-//
-// To use an ExceptionEditorView create one and invoke Show on it.
-// ExceptionEditorView is deleted when the dialog closes.
-class ExceptionEditorView : public views::View,
- public views::Textfield::Controller,
- public views::DialogDelegate {
- public:
- class Delegate {
- public:
- // Invoked when the user accepts the edit.
- virtual void AcceptExceptionEdit(
- const HostContentSettingsMap::Pattern& pattern,
- ContentSetting setting,
- bool is_off_the_record,
- int index,
- bool is_new) = 0;
-
- protected:
- virtual ~Delegate() {}
- };
-
- // Creates a new ExceptionEditorView with the supplied args. |index| is the
- // index into the ContentExceptionsTableModel of the exception. This is not
- // used by ExceptionEditorView but instead passed to the delegate.
- ExceptionEditorView(Delegate* delegate,
- ContentExceptionsTableModel* model,
- bool allow_off_the_record,
- int index,
- const HostContentSettingsMap::Pattern& pattern,
- ContentSetting setting,
- bool is_off_the_record);
- virtual ~ExceptionEditorView() {}
-
- void Show(gfx::NativeWindow parent);
-
- // views::DialogDelegate overrides.
- virtual bool IsModal() const;
- virtual std::wstring GetWindowTitle() const;
- virtual bool IsDialogButtonEnabled(
- MessageBoxFlags::DialogButton button) const;
- virtual bool Cancel();
- virtual bool Accept();
- virtual views::View* GetContentsView();
-
- // views::Textfield::Controller overrides. Updates whether the user can
- // accept the dialog as well as updating image views showing whether value is
- // valid.
- virtual void ContentsChanged(views::Textfield* sender,
- const std::wstring& new_contents);
- virtual bool HandleKeystroke(views::Textfield* sender,
- const views::Textfield::Keystroke& key);
-
- private:
- void Init();
-
- views::Label* CreateLabel(int message_id);
-
- // Returns true if we're adding a new item.
- bool is_new() const { return index_ == -1; }
-
- bool IsPatternValid(const HostContentSettingsMap::Pattern& pattern,
- bool is_off_the_record) const;
-
- void UpdateImageView(views::ImageView* image_view, bool is_valid);
-
- Delegate* delegate_;
- ContentExceptionsTableModel* model_;
- ContentSettingComboModel cb_model_;
-
- // Index of the item being edited. If -1, indices this is a new entry.
- const bool allow_off_the_record_;
- const int index_;
- const HostContentSettingsMap::Pattern pattern_;
- const ContentSetting setting_;
- const bool is_off_the_record_;
-
- views::Textfield* pattern_tf_;
- views::ImageView* pattern_iv_;
- views::Combobox* action_cb_;
- views::Checkbox* incognito_cb_;
-
- DISALLOW_COPY_AND_ASSIGN(ExceptionEditorView);
-};
+#include "chrome/browser/ui/views/options/exception_editor_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_EXCEPTION_EDITOR_VIEW_H_
+
diff --git a/chrome/browser/views/options/exceptions_page_view.cc b/chrome/browser/views/options/exceptions_page_view.cc
deleted file mode 100644
index 7788c5c..0000000
--- a/chrome/browser/views/options/exceptions_page_view.cc
+++ /dev/null
@@ -1,193 +0,0 @@
-// Copyright (c) 2009 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/options/exceptions_page_view.h"
-
-#include "app/l10n_util.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profile.h"
-#include "chrome/common/pref_names.h"
-#include "grit/generated_resources.h"
-#include "views/background.h"
-#include "views/controls/button/native_button.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-
-using views::ColumnSet;
-using views::GridLayout;
-using webkit_glue::PasswordForm;
-
-///////////////////////////////////////////////////////////////////////////////
-// ExceptionsTableModel
-ExceptionsTableModel::ExceptionsTableModel(Profile* profile)
- : PasswordsTableModel(profile) {
-}
-
-ExceptionsTableModel::~ExceptionsTableModel() {
-}
-
-std::wstring ExceptionsTableModel::GetText(int row, int col_id) {
- DCHECK_EQ(col_id, IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN);
- return PasswordsTableModel::GetText(row, col_id);
-}
-
-int ExceptionsTableModel::CompareValues(int row1, int row2,
- int col_id) {
- DCHECK_EQ(col_id, IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN);
- return PasswordsTableModel::CompareValues(row1, row2, col_id);
-}
-
-void ExceptionsTableModel::GetAllExceptionsForProfile() {
- DCHECK(!pending_login_query_);
- pending_login_query_ = password_store()->GetBlacklistLogins(this);
-}
-
-void ExceptionsTableModel::OnPasswordStoreRequestDone(
- int handle, const std::vector<webkit_glue::PasswordForm*>& result) {
- DCHECK_EQ(pending_login_query_, handle);
- pending_login_query_ = NULL;
-
- STLDeleteElements<PasswordRows>(&saved_signons_);
- std::wstring languages =
- UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
- for (size_t i = 0; i < result.size(); ++i) {
- saved_signons_.push_back(new PasswordRow(
- gfx::SortedDisplayURL(result[i]->origin, languages), result[i]));
- }
- if (observer_)
- observer_->OnModelChanged();
- if (row_count_observer_)
- row_count_observer_->OnRowCountChanged(RowCount());
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ExceptionsPageView, public
-ExceptionsPageView::ExceptionsPageView(Profile* profile)
- : OptionsPageView(profile),
- ALLOW_THIS_IN_INITIALIZER_LIST(show_button_(
- this,
- l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON),
- l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON))),
- ALLOW_THIS_IN_INITIALIZER_LIST(remove_button_(
- this,
- l10n_util::GetString(IDS_EXCEPTIONS_PAGE_VIEW_REMOVE_BUTTON))),
- ALLOW_THIS_IN_INITIALIZER_LIST(remove_all_button_(
- this,
- l10n_util::GetString(IDS_EXCEPTIONS_PAGE_VIEW_REMOVE_ALL_BUTTON))),
- table_model_(profile),
- table_view_(NULL) {
-}
-
-ExceptionsPageView::~ExceptionsPageView() {
- // The model is going away, prevent the table from accessing it.
- if (table_view_)
- table_view_->SetModel(NULL);
-}
-
-void ExceptionsPageView::OnSelectionChanged() {
- bool has_selection = table_view_->SelectedRowCount() > 0;
- remove_button_.SetEnabled(has_selection);
-}
-
-void ExceptionsPageView::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- // Close will result in our destruction.
- if (sender == &remove_all_button_) {
- table_model_.ForgetAndRemoveAllSignons();
- return;
- }
-
- // The following require a selection (and only one, since table is single-
- // select only).
- views::TableSelectionIterator iter = table_view_->SelectionBegin();
- int row = *iter;
- DCHECK(++iter == table_view_->SelectionEnd());
-
- if (sender == &remove_button_) {
- table_model_.ForgetAndRemoveSignon(row);
- } else {
- NOTREACHED() << "Invalid button.";
- }
-}
-
-void ExceptionsPageView::OnRowCountChanged(size_t rows) {
- remove_all_button_.SetEnabled(rows > 0);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ExceptionsPageView, protected
-void ExceptionsPageView::InitControlLayout() {
- SetupButtons();
- SetupTable();
-
- // Do the layout thing.
- GridLayout* layout = CreatePanelGridLayout(this);
- SetLayoutManager(layout);
-
- const int top_column_set_id = 0;
-
- // Design the grid.
- ColumnSet* column_set = layout->AddColumnSet(top_column_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
-
- // Fill the grid.
- layout->StartRow(0, top_column_set_id);
- layout->AddView(table_view_, 1, 6, GridLayout::FILL,
- GridLayout::FILL);
- layout->AddView(&remove_button_);
- layout->StartRowWithPadding(0, top_column_set_id, 0,
- kRelatedControlVerticalSpacing);
- layout->SkipColumns(1);
- layout->AddView(&remove_all_button_);
- layout->StartRowWithPadding(0, top_column_set_id, 0,
- kRelatedControlVerticalSpacing);
-
- layout->SkipColumns(1);
- layout->AddView(&show_button_);
- layout->AddPaddingRow(1, 0);
-
- // Ask the database for exception data.
- table_model_.GetAllExceptionsForProfile();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ExceptionsPageView, private
-void ExceptionsPageView::SetupButtons() {
- // Disable all buttons in the first place.
- remove_button_.set_parent_owned(false);
- remove_button_.SetEnabled(false);
-
- remove_all_button_.set_parent_owned(false);
- remove_all_button_.SetEnabled(false);
-
- show_button_.set_parent_owned(false);
- show_button_.SetEnabled(false);
- show_button_.SetVisible(false);
-}
-
-void ExceptionsPageView::SetupTable() {
- // Tell the table model we are concerned about how many rows it has.
- table_model_.set_row_count_observer(this);
-
- // Creates the different columns for the table.
- // The float resize values are the result of much tinkering.
- std::vector<TableColumn> columns;
- columns.push_back(TableColumn(IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN,
- TableColumn::LEFT, -1, 0.55f));
- columns.back().sortable = true;
- table_view_ = new views::TableView(&table_model_, columns, views::TEXT_ONLY,
- true, true, true);
- // Make the table initially sorted by host.
- views::TableView::SortDescriptors sort;
- sort.push_back(views::TableView::SortDescriptor(
- IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN, true));
- table_view_->SetSortDescriptors(sort);
- table_view_->SetObserver(this);
-}
diff --git a/chrome/browser/views/options/exceptions_page_view.h b/chrome/browser/views/options/exceptions_page_view.h
index 9417118..c9eab58 100644
--- a/chrome/browser/views/options/exceptions_page_view.h
+++ b/chrome/browser/views/options/exceptions_page_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
@@ -6,70 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_EXCEPTIONS_PAGE_VIEW_H_
#pragma once
-#include <vector>
-
-#include "chrome/browser/views/options/options_page_view.h"
-#include "chrome/browser/views/options/passwords_page_view.h"
-#include "views/controls/table/table_view_observer.h"
-
-class Profile;
-
-///////////////////////////////////////////////////////////////////////////////
-// ExceptionsTableModel
-class ExceptionsTableModel : public PasswordsTableModel {
- public:
- explicit ExceptionsTableModel(Profile* profile);
- virtual ~ExceptionsTableModel();
-
- // TableModel methods.
- virtual std::wstring GetText(int row, int column);
- virtual int CompareValues(int row1, int row2, int col_id);
-
- // PasswordStoreConsumer implementation.
- virtual void OnPasswordStoreRequestDone(
- int handle, const std::vector<webkit_glue::PasswordForm*>& result);
- // Request all logins data.
- void GetAllExceptionsForProfile();
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// ExceptionsPageView
-class ExceptionsPageView : public OptionsPageView,
- public views::TableViewObserver,
- public views::ButtonListener,
- public PasswordsTableModelObserver {
- public:
- explicit ExceptionsPageView(Profile* profile);
- virtual ~ExceptionsPageView();
-
- // views::TableViewObserverImplementation.
- virtual void OnSelectionChanged();
-
- // views::ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // PasswordsTableModelObserver implementation.
- virtual void OnRowCountChanged(size_t rows);
-
- protected:
- virtual void InitControlLayout();
-
- private:
- // Helper to configure our buttons and labels.
- void SetupButtons();
-
- // Helper to configure our table view.
- void SetupTable();
-
- ExceptionsTableModel table_model_;
- views::TableView* table_view_;
-
- // The buttons and labels.
- views::NativeButton remove_button_;
- views::NativeButton remove_all_button_;
- MultiLabelButtons show_button_;
-
- DISALLOW_COPY_AND_ASSIGN(ExceptionsPageView);
-};
+#include "chrome/browser/ui/views/options/exceptions_page_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_EXCEPTIONS_PAGE_VIEW_H_
+
diff --git a/chrome/browser/views/options/exceptions_view.cc b/chrome/browser/views/options/exceptions_view.cc
deleted file mode 100644
index eadaf75..0000000
--- a/chrome/browser/views/options/exceptions_view.cc
+++ /dev/null
@@ -1,275 +0,0 @@
-// 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/options/exceptions_view.h"
-
-#include <algorithm>
-#include <vector>
-
-#include "app/l10n_util.h"
-#include "chrome/browser/views/options/content_exceptions_table_view.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "gfx/rect.h"
-#include "views/controls/button/native_button.h"
-#include "views/controls/label.h"
-#include "views/controls/table/table_view.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-#include "views/window/window.h"
-
-static const int kExceptionsViewInsetSize = 5;
-static ExceptionsView* instances[CONTENT_SETTINGS_NUM_TYPES] = { NULL };
-
-// static
-void ExceptionsView::ShowExceptionsWindow(
- gfx::NativeWindow parent,
- HostContentSettingsMap* map,
- HostContentSettingsMap* off_the_record_map,
- ContentSettingsType content_type) {
- if (!instances[content_type]) {
- instances[content_type] =
- new ExceptionsView(map, off_the_record_map, content_type);
- views::Window::CreateChromeWindow(parent, gfx::Rect(),
- instances[content_type]);
- }
-
- // This will show invisible windows and bring visible windows to the front.
- instances[content_type]->window()->Show();
-}
-
-ExceptionsView::~ExceptionsView() {
- instances[model_.content_type()] = NULL;
- table_->SetModel(NULL);
-}
-
-void ExceptionsView::OnSelectionChanged() {
- UpdateButtonState();
-}
-
-void ExceptionsView::OnDoubleClick() {
- if (table_->SelectedRowCount() == 1)
- Edit();
-}
-
-void ExceptionsView::OnTableViewDelete(views::TableView* table_view) {
- Remove();
-}
-
-void ExceptionsView::ButtonPressed(views::Button* sender,
- const views::Event& event) {
- switch (sender->tag()) {
- case IDS_EXCEPTIONS_ADD_BUTTON:
- Add();
- break;
- case IDS_EXCEPTIONS_EDIT_BUTTON:
- Edit();
- break;
- case IDS_EXCEPTIONS_REMOVEALL_BUTTON:
- RemoveAll();
- break;
- case IDS_EXCEPTIONS_REMOVE_BUTTON:
- Remove();
- break;
- default:
- NOTREACHED();
- }
-}
-
-void ExceptionsView::Layout() {
- views::NativeButton* buttons[] = { add_button_, edit_button_,
- remove_button_, remove_all_button_ };
-
- // The buttons are placed in the parent, but we need to lay them out.
- int max_y = GetParent()->GetLocalBounds(false).bottom() - kButtonVEdgeMargin;
- int x = kPanelHorizMargin;
-
- for (size_t i = 0; i < arraysize(buttons); ++i) {
- gfx::Size pref = buttons[i]->GetPreferredSize();
- buttons[i]->SetBounds(x, max_y - pref.height(), pref.width(),
- pref.height());
- x += pref.width() + kRelatedControlHorizontalSpacing;
- }
-
- // Lay out the rest of this view.
- View::Layout();
-}
-
-gfx::Size ExceptionsView::GetPreferredSize() {
- return gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_CONTENT_EXCEPTION_DIALOG_WIDTH_CHARS,
- IDS_CONTENT_EXCEPTION_DIALOG_HEIGHT_LINES));
-}
-
-void ExceptionsView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- if (is_add && child == this)
- Init();
-}
-
-std::wstring ExceptionsView::GetWindowTitle() const {
- switch (model_.content_type()) {
- case CONTENT_SETTINGS_TYPE_COOKIES:
- return l10n_util::GetString(IDS_COOKIE_EXCEPTION_TITLE);
- case CONTENT_SETTINGS_TYPE_IMAGES:
- return l10n_util::GetString(IDS_IMAGES_EXCEPTION_TITLE);
- case CONTENT_SETTINGS_TYPE_JAVASCRIPT:
- return l10n_util::GetString(IDS_JS_EXCEPTION_TITLE);
- case CONTENT_SETTINGS_TYPE_PLUGINS:
- return l10n_util::GetString(IDS_PLUGINS_EXCEPTION_TITLE);
- case CONTENT_SETTINGS_TYPE_POPUPS:
- return l10n_util::GetString(IDS_POPUP_EXCEPTION_TITLE);
- default:
- NOTREACHED();
- }
- return std::wstring();
-}
-
-void ExceptionsView::AcceptExceptionEdit(
- const HostContentSettingsMap::Pattern& pattern,
- ContentSetting setting,
- bool is_off_the_record,
- int index,
- bool is_new) {
- DCHECK(!is_off_the_record || allow_off_the_record_);
-
- if (!is_new)
- model_.RemoveException(index);
- model_.AddException(pattern, setting, is_off_the_record);
-
- int new_index = model_.IndexOfExceptionByPattern(pattern, is_off_the_record);
- DCHECK(new_index != -1);
- table_->Select(new_index);
-}
-
-ExceptionsView::ExceptionsView(HostContentSettingsMap* map,
- HostContentSettingsMap* off_the_record_map,
- ContentSettingsType type)
- : model_(map, off_the_record_map, type),
- allow_off_the_record_(off_the_record_map != NULL),
- table_(NULL),
- add_button_(NULL),
- edit_button_(NULL),
- remove_button_(NULL),
- remove_all_button_(NULL) {
-}
-
-void ExceptionsView::Init() {
- if (table_)
- return; // We've already Init'd.
-
- using views::GridLayout;
-
- std::vector<TableColumn> columns;
- columns.push_back(
- TableColumn(IDS_EXCEPTIONS_PATTERN_HEADER, TableColumn::LEFT, -1, .75));
- columns.back().sortable = true;
- columns.push_back(
- TableColumn(IDS_EXCEPTIONS_ACTION_HEADER, TableColumn::LEFT, -1, .25));
- columns.back().sortable = true;
- table_ = new ContentExceptionsTableView(&model_, columns);
- views::TableView::SortDescriptors sort;
- sort.push_back(
- views::TableView::SortDescriptor(IDS_EXCEPTIONS_PATTERN_HEADER, true));
- table_->SetSortDescriptors(sort);
- table_->SetObserver(this);
-
- add_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_EXCEPTIONS_ADD_BUTTON));
- add_button_->set_tag(IDS_EXCEPTIONS_ADD_BUTTON);
- edit_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_EXCEPTIONS_EDIT_BUTTON));
- edit_button_->set_tag(IDS_EXCEPTIONS_EDIT_BUTTON);
- remove_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_EXCEPTIONS_REMOVE_BUTTON));
- remove_button_->set_tag(IDS_EXCEPTIONS_REMOVE_BUTTON);
- remove_all_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_EXCEPTIONS_REMOVEALL_BUTTON));
- remove_all_button_->set_tag(IDS_EXCEPTIONS_REMOVEALL_BUTTON);
-
- View* parent = GetParent();
- parent->AddChildView(add_button_);
- parent->AddChildView(edit_button_);
- parent->AddChildView(remove_button_);
- parent->AddChildView(remove_all_button_);
-
- GridLayout* layout = new GridLayout(this);
- layout->SetInsets(kExceptionsViewInsetSize, kExceptionsViewInsetSize,
- kExceptionsViewInsetSize, kExceptionsViewInsetSize);
- SetLayoutManager(layout);
-
- const int single_column_layout_id = 0;
- views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- layout->StartRow(1, single_column_layout_id);
- layout->AddView(table_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- if (allow_off_the_record_) {
- views::Label* label = new views::Label(l10n_util::GetString(
- IDS_EXCEPTIONS_OTR_IN_ITALICS));
- label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- layout->StartRow(0, single_column_layout_id);
- layout->AddView(label, 1, 1, GridLayout::LEADING, GridLayout::CENTER);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- }
-
- UpdateButtonState();
-}
-
-void ExceptionsView::UpdateButtonState() {
- int selected_row_count = table_->SelectedRowCount();
- // TODO: 34177, support editing of more than one entry at a time.
- edit_button_->SetEnabled(selected_row_count == 1);
- remove_button_->SetEnabled(selected_row_count >= 1);
- remove_all_button_->SetEnabled(model_.RowCount() > 0);
-}
-
-void ExceptionsView::Add() {
- ExceptionEditorView* view =
- new ExceptionEditorView(this, &model_, allow_off_the_record_, -1,
- HostContentSettingsMap::Pattern(),
- CONTENT_SETTING_BLOCK, false);
- view->Show(window()->GetNativeWindow());
-
- UpdateButtonState();
-}
-
-void ExceptionsView::Edit() {
- DCHECK(table_->FirstSelectedRow() != -1);
- int index = table_->FirstSelectedRow();
- const HostContentSettingsMap::PatternSettingPair& entry =
- model_.entry_at(index);
- ExceptionEditorView* view =
- new ExceptionEditorView(this, &model_, allow_off_the_record_, index,
- entry.first, entry.second,
- model_.entry_is_off_the_record(index));
- view->Show(window()->GetNativeWindow());
-}
-
-void ExceptionsView::Remove() {
- std::vector<int> indices;
- for (views::TableView::iterator i = table_->SelectionBegin();
- i != table_->SelectionEnd(); ++i) {
- indices.push_back(*i);
- }
- std::sort(indices.begin(), indices.end());
- for (std::vector<int>::reverse_iterator i = indices.rbegin();
- i != indices.rend(); ++i) {
- model_.RemoveException(*i);
- }
-
- UpdateButtonState();
-}
-
-void ExceptionsView::RemoveAll() {
- model_.RemoveAll();
-
- UpdateButtonState();
-}
diff --git a/chrome/browser/views/options/exceptions_view.h b/chrome/browser/views/options/exceptions_view.h
index 4e66e6d..6ff6f02 100644
--- a/chrome/browser/views/options/exceptions_view.h
+++ b/chrome/browser/views/options/exceptions_view.h
@@ -6,112 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_EXCEPTIONS_VIEW_H_
#pragma once
-#include <string>
-
-#include "chrome/browser/content_exceptions_table_model.h"
-#include "chrome/browser/views/options/exception_editor_view.h"
-#include "chrome/common/content_settings.h"
-#include "chrome/common/content_settings_types.h"
-#include "views/controls/button/button.h"
-#include "views/controls/table/table_view_observer.h"
-#include "views/window/dialog_delegate.h"
-
-class HostContentSettingsMap;
-
-namespace views {
-class NativeButton;
-class TableView;
-}
-
-// ExceptionsView is responsible for showing the user the set of content
-// exceptions for a specific type. The exceptions are shown in a table view
-// by way of a ContentExceptionsTableModel. The user can add/edit/remove
-// exceptions. Editing and creating new exceptions is done way of the
-// ExceptionEditorView.
-// Use the ShowExceptionsWindow method to create and show an ExceptionsView
-// for a specific type. ExceptionsView is deleted when the window closes.
-class ExceptionsView : public ExceptionEditorView::Delegate,
- public views::View,
- public views::ButtonListener,
- public views::DialogDelegate,
- public views::TableViewObserver {
- public:
- // Shows the Exceptions window.
- static void ShowExceptionsWindow(gfx::NativeWindow parent,
- HostContentSettingsMap* map,
- HostContentSettingsMap* off_the_record_map,
- ContentSettingsType content_type);
-
- virtual ~ExceptionsView();
-
- // TableViewObserver overrides:
- virtual void OnSelectionChanged();
- virtual void OnDoubleClick();
- virtual void OnTableViewDelete(views::TableView* table_view);
-
- // views::ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // views::View overrides:
- virtual void Layout();
- virtual gfx::Size GetPreferredSize();
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
-
- // views::WindowDelegate implementation.
- virtual int GetDialogButtons() const {
- return MessageBoxFlags::DIALOGBUTTON_CANCEL;
- }
- virtual bool CanResize() const { return true; }
- virtual std::wstring GetWindowTitle() const;
- virtual views::View* GetContentsView() { return this; }
-
- // ExceptionEditorView::Delegate implementation.
- virtual void AcceptExceptionEdit(
- const HostContentSettingsMap::Pattern& pattern,
- ContentSetting setting,
- bool is_off_the_record,
- int index,
- bool is_new);
-
- private:
- ExceptionsView(HostContentSettingsMap* map,
- HostContentSettingsMap* off_the_record_map,
- ContentSettingsType type);
-
- void Init();
-
- // Resets the enabled state of the buttons from the model.
- void UpdateButtonState();
-
- // Adds a new item.
- void Add();
-
- // Edits the selected item.
- void Edit();
-
- // Removes the selected item.
- void Remove();
-
- // Removes all.
- void RemoveAll();
-
- // The model displayed in the table.
- ContentExceptionsTableModel model_;
-
- // True if the user can also add off the record entries.
- bool allow_off_the_record_;
-
- views::TableView* table_;
-
- views::NativeButton* add_button_;
- views::NativeButton* edit_button_;
- views::NativeButton* remove_button_;
- views::NativeButton* remove_all_button_;
-
- DISALLOW_COPY_AND_ASSIGN(ExceptionsView);
-};
+#include "chrome/browser/ui/views/options/exceptions_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_EXCEPTIONS_VIEW_H_
diff --git a/chrome/browser/views/options/fonts_languages_window_view.cc b/chrome/browser/views/options/fonts_languages_window_view.cc
deleted file mode 100644
index cab82c7..0000000
--- a/chrome/browser/views/options/fonts_languages_window_view.cc
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright (c) 2006-2008 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/options/fonts_languages_window_view.h"
-
-#include "app/l10n_util.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/views/options/fonts_page_view.h"
-#include "chrome/browser/views/options/languages_page_view.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/pref_names.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "views/controls/tabbed_pane/tabbed_pane.h"
-#include "views/window/window.h"
-
-// static
-static FontsLanguagesWindowView* instance_ = NULL;
-static const int kDialogPadding = 7;
-
-///////////////////////////////////////////////////////////////////////////////
-// FontsLanguagesWindowView, public:
-
-FontsLanguagesWindowView::FontsLanguagesWindowView(Profile* profile)
- // Always show preferences for the original profile. Most state when off
- // the record comes from the original profile, but we explicitly use
- // the original profile to avoid potential problems.
- : profile_(profile->GetOriginalProfile()),
- fonts_page_(NULL),
- languages_page_(NULL) {
-}
-
-FontsLanguagesWindowView::~FontsLanguagesWindowView() {
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// FontsLanguagesWindowView, views::DialogDelegate implementation:
-
-bool FontsLanguagesWindowView::Accept() {
- fonts_page_->SaveChanges();
- languages_page_->SaveChanges();
- return true;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// FontsLanguagesWindowView, views::WindowDelegate implementation:
-
-std::wstring FontsLanguagesWindowView::GetWindowTitle() const {
- return l10n_util::GetString(IDS_FONT_LANGUAGE_SETTING_WINDOWS_TITLE);
-}
-
-void FontsLanguagesWindowView::WindowClosing() {
- // Clear the static instance so that the next time ShowOptionsWindow() is
- // called a new window is opened.
- instance_ = NULL;
-}
-
-views::View* FontsLanguagesWindowView::GetContentsView() {
- return this;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// FontsLanguagesWindowView, views::View overrides:
-
-void FontsLanguagesWindowView::Layout() {
- tabs_->SetBounds(kDialogPadding, kDialogPadding,
- width() - (2 * kDialogPadding),
- height() - (2 * kDialogPadding));
-}
-
-gfx::Size FontsLanguagesWindowView::GetPreferredSize() {
- return gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_FONTSLANG_DIALOG_WIDTH_CHARS,
- IDS_FONTSLANG_DIALOG_HEIGHT_LINES));
-}
-
-void FontsLanguagesWindowView::ShowTabPage(FontsLanguagesPage page) {
- // If the window is not yet visible, we need to show it (it will become
- // active), otherwise just bring it to the front.
- if (!window()->IsVisible()) {
- window()->Show();
- } else {
- window()->Activate();
- }
-
- // If the page is out of bounds, reset to the first tab.
- if (page < 0 || page >= tabs_->GetTabCount())
- page = FONTS_ENCODING_PAGE;
-
- tabs_->SelectTabAt(page);
-}
-
-void FontsLanguagesWindowView::ViewHierarchyChanged(
- bool is_add, views::View* parent, views::View* child) {
- // Can't init before we're inserted into a Container, because we require
- // a HWND to parent native child controls to.
- if (is_add && child == this)
- Init();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// FontsLanguagesWindowView, private:
-
-void FontsLanguagesWindowView::Init() {
- tabs_ = new views::TabbedPane;
- AddChildView(tabs_);
-
- fonts_page_ = new FontsPageView(profile_);
- tabs_->AddTab(l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_FONT_TAB_TITLE), fonts_page_);
-
- languages_page_ = new LanguagesPageView(profile_);
- tabs_->AddTab(l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_LANGUAGES_TAB_TITLE), languages_page_);
-}
-
-void ShowFontsLanguagesWindow(gfx::NativeWindow window,
- FontsLanguagesPage page,
- Profile* profile) {
- DCHECK(profile);
-
- // If there's already an existing fonts and language window, activate it and
- // switch to the specified page.
- // TODO(beng): note this is not multi-simultaneous-profile-safe. When we care
- // about this case this will have to be fixed.
- if (!instance_) {
- instance_ = new FontsLanguagesWindowView(profile);
- views::Window::CreateChromeWindow(window, gfx::Rect(), instance_);
- }
- instance_->ShowTabPage(page);
-}
diff --git a/chrome/browser/views/options/fonts_languages_window_view.h b/chrome/browser/views/options/fonts_languages_window_view.h
index 4af9d01..1702d9a 100644
--- a/chrome/browser/views/options/fonts_languages_window_view.h
+++ b/chrome/browser/views/options/fonts_languages_window_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
@@ -6,69 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_FONTS_LANGUAGES_WINDOW_VIEW_H_
#pragma once
-#include "chrome/browser/fonts_languages_window.h"
-#include "views/view.h"
-#include "views/window/dialog_delegate.h"
-
-class Profile;
-class FontsPageView;
-class LanguagesPageView;
-
-namespace views {
-class TabbedPane;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// FontsLanguagesWindowView
-//
-// The contents of the "Fonts and Languages Preferences" dialog window.
-//
-class FontsLanguagesWindowView : public views::View,
- public views::DialogDelegate {
- public:
- explicit FontsLanguagesWindowView(Profile* profile);
- virtual ~FontsLanguagesWindowView();
-
- // views::DialogDelegate implementation:
- virtual bool Accept();
-
- // views::WindowDelegate Methods:
- virtual bool IsModal() const { return true; }
- virtual std::wstring GetWindowTitle() const;
- virtual views::View* GetContentsView();
- virtual void WindowClosing();
-
- // views::View overrides:
- virtual void Layout();
- virtual gfx::Size GetPreferredSize();
-
- // Shows the tab corresponding to the specified |page|.
- void ShowTabPage(FontsLanguagesPage page);
-
- protected:
- // views::View overrides:
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
- private:
- // Init the assorted Tabbed pages
- void Init();
-
- // The Tab view that contains all of the options pages.
- views::TabbedPane* tabs_;
-
- // Fonts Page View handle remembered so that prefs is updated only when
- // OK is pressed.
- FontsPageView* fonts_page_;
-
- // Languages Page View handle remembered so that prefs is updated only when
- // OK is pressed.
- LanguagesPageView* languages_page_;
-
- // The Profile associated with these options.
- Profile* profile_;
-
- DISALLOW_COPY_AND_ASSIGN(FontsLanguagesWindowView);
-};
+#include "chrome/browser/ui/views/options/fonts_languages_window_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_FONTS_LANGUAGES_WINDOW_VIEW_H_
+
diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc
deleted file mode 100644
index 3a98b15..0000000
--- a/chrome/browser/views/options/fonts_page_view.cc
+++ /dev/null
@@ -1,435 +0,0 @@
-// 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/options/fonts_page_view.h"
-
-#include <windows.h>
-#include <shlobj.h>
-#include <vsstyle.h>
-#include <vssym32.h>
-
-#include <vector>
-
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "base/file_util.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/default_encoding_combo_model.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/shell_dialogs.h"
-#include "chrome/common/pref_names.h"
-#include "gfx/canvas_skia.h"
-#include "gfx/font.h"
-#include "gfx/native_theme_win.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "grit/locale_settings.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "views/controls/button/native_button.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-#include "views/widget/widget.h"
-
-////////////////////////////////////////////////////////////////////////////////
-// FontDisplayView
-
-class FontDisplayView : public views::View {
- public:
- FontDisplayView();
- virtual ~FontDisplayView();
-
- // This method takes in font size in pixel units, instead of the normal point
- // unit because users expect the font size number to represent pixels and not
- // points.
- void SetFontType(const std::wstring& font_name,
- int font_size);
-
- std::wstring font_name() { return font_name_; }
- int font_size() { return font_size_; }
-
- // views::View overrides:
- virtual void Paint(gfx::Canvas* canvas);
- virtual void Layout();
- virtual gfx::Size GetPreferredSize();
-
- private:
- views::Label* font_text_label_;
- std::wstring font_name_;
- int font_size_;
- std::wstring font_text_label_string_;
-
- static const int kFontDisplayMaxWidthChars = 50;
- static const int kFontDisplayMaxHeightChars = 1;
- static const int kFontDisplayLabelPadding = 5;
-
- DISALLOW_COPY_AND_ASSIGN(FontDisplayView);
-};
-
-FontDisplayView::FontDisplayView()
- : font_text_label_(new views::Label) {
- AddChildView(font_text_label_);
-}
-
-FontDisplayView::~FontDisplayView() {
-}
-
-void FontDisplayView::SetFontType(const std::wstring& font_name,
- int font_size) {
- if (font_name.empty())
- return;
-
- font_name_ = font_name;
- font_size_ = font_size;
- std::wstring displayed_text = font_name_;
-
- // Append the font type and size.
- displayed_text += L", ";
- displayed_text += UTF8ToWide(::StringPrintf("%d", font_size_));
- HDC hdc = GetDC(NULL);
- int font_size_point = MulDiv(font_size, 72, GetDeviceCaps(hdc, LOGPIXELSY));
- gfx::Font font = gfx::Font(font_name, font_size_point);
- font_text_label_->SetFont(font);
- font_text_label_->SetText(displayed_text);
-}
-
-void FontDisplayView::Paint(gfx::Canvas* canvas) {
- HDC dc = canvas->BeginPlatformPaint();
- RECT rect = { 0, 0, width(), height() };
- gfx::NativeTheme::instance()->PaintTextField(
- dc, EP_BACKGROUND, EBS_NORMAL, 0, &rect, ::GetSysColor(COLOR_3DFACE),
- true, true);
- canvas->EndPlatformPaint();
-}
-
-void FontDisplayView::Layout() {
- font_text_label_->SetBounds(0, 0, width(), height());
-}
-
-gfx::Size FontDisplayView::GetPreferredSize() {
- gfx::Size size = font_text_label_->GetPreferredSize();
- size.set_width(size.width() + 2 * kFontDisplayLabelPadding);
- size.set_height(size.height() + 2 * kFontDisplayLabelPadding);
- return size;
-}
-
-void EmbellishTitle(views::Label* title_label) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- gfx::Font title_font =
- rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD);
- title_label->SetFont(title_font);
- SkColor title_color =
- gfx::NativeTheme::instance()->GetThemeColorWithDefault(
- gfx::NativeTheme::BUTTON, BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR,
- COLOR_WINDOWTEXT);
- title_label->SetColor(title_color);
-}
-
-FontsPageView::FontsPageView(Profile* profile)
- : ALLOW_THIS_IN_INITIALIZER_LIST(
- select_font_dialog_(SelectFontDialog::Create(this))),
- fonts_group_title_(NULL),
- encoding_group_title_(NULL),
- fixed_width_font_change_page_button_(NULL),
- serif_font_change_page_button_(NULL),
- sans_serif_font_change_page_button_(NULL),
- fixed_width_font_label_(NULL),
- serif_font_label_(NULL),
- sans_serif_font_label_(NULL),
- default_encoding_combobox_(NULL),
- serif_button_pressed_(false),
- sans_serif_button_pressed_(false),
- fixed_width_button_pressed_(false),
- encoding_dropdown_clicked_(false),
- font_type_being_changed_(NONE),
- OptionsPageView(profile),
- font_changed_(false),
- default_encoding_changed_(false),
- serif_font_size_pixel_(0),
- sans_serif_font_size_pixel_(0),
- fixed_width_font_size_pixel_(0) {
- serif_name_.Init(prefs::kWebKitSerifFontFamily, profile->GetPrefs(), NULL);
- serif_size_.Init(prefs::kWebKitDefaultFontSize, profile->GetPrefs(), NULL);
-
- sans_serif_name_.Init(prefs::kWebKitSansSerifFontFamily, profile->GetPrefs(),
- NULL);
- sans_serif_size_.Init(prefs::kWebKitDefaultFontSize, profile->GetPrefs(),
- NULL);
-
- fixed_width_name_.Init(prefs::kWebKitFixedFontFamily, profile->GetPrefs(),
- NULL);
- fixed_width_size_.Init(prefs::kWebKitDefaultFixedFontSize,
- profile->GetPrefs(), NULL);
-
- default_encoding_.Init(prefs::kDefaultCharset, profile->GetPrefs(), NULL);
-}
-
-FontsPageView::~FontsPageView() {
-}
-
-void FontsPageView::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- HWND owning_hwnd = GetAncestor(GetWidget()->GetNativeView(), GA_ROOT);
- std::wstring font_name;
- int font_size = 0;
- if (sender == serif_font_change_page_button_) {
- font_type_being_changed_ = SERIF;
- font_name = serif_font_display_view_->font_name();
- font_size = serif_font_size_pixel_;
- } else if (sender == sans_serif_font_change_page_button_) {
- font_type_being_changed_ = SANS_SERIF;
- font_name = sans_serif_font_display_view_->font_name();
- font_size = sans_serif_font_size_pixel_;
- } else if (sender == fixed_width_font_change_page_button_) {
- font_type_being_changed_ = FIXED_WIDTH;
- font_name = fixed_width_font_display_view_->font_name();
- font_size = fixed_width_font_size_pixel_;
- } else {
- NOTREACHED();
- return;
- }
-
- select_font_dialog_->SelectFont(owning_hwnd, NULL, font_name, font_size);
-}
-
-void FontsPageView::ItemChanged(views::Combobox* combo_box,
- int prev_index, int new_index) {
- if (combo_box == default_encoding_combobox_) {
- if (prev_index != new_index) { // Default-Encoding has been changed.
- encoding_dropdown_clicked_ = true;
- default_encoding_selected_ = default_encoding_combobox_model_->
- GetEncodingCharsetByIndex(new_index);
- default_encoding_changed_ = true;
- }
- }
-}
-
-void FontsPageView::FontSelected(const gfx::Font& font, void* params) {
- if (font.GetFontName().empty())
- return;
- int font_size = font.GetFontSize();
- // Currently we do not have separate font sizes for Serif and Sans Serif.
- // Therefore, when Serif font size is changed, Sans-Serif font size changes,
- // and vice versa.
- if (font_type_being_changed_ == SERIF) {
- sans_serif_font_size_pixel_ = serif_font_size_pixel_ = font_size;
- serif_font_display_view_->SetFontType(
- font.GetFontName(),
- serif_font_size_pixel_);
- sans_serif_font_display_view_->SetFontType(
- sans_serif_font_display_view_->font_name(),
- sans_serif_font_size_pixel_);
- } else if (font_type_being_changed_ == SANS_SERIF) {
- sans_serif_font_size_pixel_ = serif_font_size_pixel_ = font_size;
- sans_serif_font_display_view_->SetFontType(
- font.GetFontName(),
- sans_serif_font_size_pixel_);
- serif_font_display_view_->SetFontType(
- serif_font_display_view_->font_name(),
- sans_serif_font_size_pixel_);
- } else if (font_type_being_changed_ == FIXED_WIDTH) {
- fixed_width_font_size_pixel_ = font_size;
- fixed_width_font_display_view_->SetFontType(font.GetFontName(), font_size);
- }
- font_changed_ = true;
-}
-
-void FontsPageView::SaveChanges() {
- // Set Fonts.
- if (font_changed_) {
- serif_name_.SetValue(WideToUTF8(serif_font_display_view_->font_name()));
- serif_size_.SetValue(serif_font_size_pixel_);
- sans_serif_name_.SetValue(
- WideToUTF8(sans_serif_font_display_view_->font_name()));
- sans_serif_size_.SetValue(sans_serif_font_size_pixel_);
- fixed_width_name_.SetValue(WideToUTF8(
- fixed_width_font_display_view_->font_name()));
- fixed_width_size_.SetValue(fixed_width_font_size_pixel_);
- }
- // Set Encoding.
- if (default_encoding_changed_)
- default_encoding_.SetValue(default_encoding_selected_);
-}
-
-void FontsPageView::InitControlLayout() {
- using views::GridLayout;
- using views::ColumnSet;
-
- GridLayout* layout = CreatePanelGridLayout(this);
- SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
-
- // Fonts group.
- column_set->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1,
- GridLayout::USE_PREF, 0, 0);
- fonts_group_title_ = new views::Label(
- l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_FONT_SUB_DIALOG_FONT_TITLE));
- EmbellishTitle(fonts_group_title_);
- fonts_group_title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(fonts_group_title_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_view_set_id);
- InitFontLayout();
- layout->AddView(fonts_contents_);
- layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
-
- // Encoding group.
- encoding_group_title_ = new views::Label(
- l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_FONT_SUB_DIALOG_ENCODING_TITLE));
- EmbellishTitle(encoding_group_title_);
- encoding_group_title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(encoding_group_title_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_view_set_id);
- InitEncodingLayout();
- layout->AddView(encoding_contents_);
-}
-
-void FontsPageView::NotifyPrefChanged(const std::string* pref_name) {
- if (!pref_name || *pref_name == prefs::kWebKitFixedFontFamily) {
- fixed_width_font_size_pixel_ = fixed_width_size_.GetValue();
- fixed_width_font_display_view_->SetFontType(
- UTF8ToWide(fixed_width_name_.GetValue()),
- fixed_width_font_size_pixel_);
- }
- if (!pref_name || *pref_name == prefs::kWebKitSerifFontFamily) {
- serif_font_size_pixel_ = serif_size_.GetValue();
- serif_font_display_view_->SetFontType(
- UTF8ToWide(serif_name_.GetValue()),
- serif_font_size_pixel_);
- }
- if (!pref_name || *pref_name == prefs::kWebKitSansSerifFontFamily) {
- sans_serif_font_size_pixel_ = sans_serif_size_.GetValue();
- sans_serif_font_display_view_->SetFontType(
- UTF8ToWide(sans_serif_name_.GetValue()),
- sans_serif_font_size_pixel_);
- }
-}
-
-void FontsPageView::InitFontLayout() {
- // Fixed width.
- fixed_width_font_display_view_ = new FontDisplayView;
- fixed_width_font_change_page_button_ = new views::NativeButton(
- this,
- l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_FONT_SELECTOR_BUTTON_LABEL));
-
- fixed_width_font_label_ = new views::Label(
- l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_FONT_SELECTOR_FIXED_WIDTH_LABEL));
- fixed_width_font_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
-
- // Serif font.
- serif_font_display_view_ = new FontDisplayView;
- serif_font_change_page_button_ = new views::NativeButton(
- this,
- l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_FONT_SELECTOR_BUTTON_LABEL));
-
- serif_font_label_ = new views::Label(
- l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_FONT_SELECTOR_SERIF_LABEL));
- serif_font_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
-
- // Sans Serif font.
- sans_serif_font_display_view_ = new FontDisplayView;
- sans_serif_font_change_page_button_ = new views::NativeButton(
- this,
- l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_FONT_SELECTOR_BUTTON_LABEL));
-
- sans_serif_font_label_ = new views::Label(
- l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_FONT_SELECTOR_SANS_SERIF_LABEL));
- sans_serif_font_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
-
- // Now add the views.
- using views::GridLayout;
- using views::ColumnSet;
-
- fonts_contents_ = new views::View;
- GridLayout* layout = new GridLayout(fonts_contents_);
- fonts_contents_->SetLayoutManager(layout);
-
- const int triple_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(triple_column_view_set_id);
-
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
-
- // Serif font controls.
- layout->StartRow(0, triple_column_view_set_id);
- layout->AddView(serif_font_label_);
- layout->AddView(serif_font_display_view_, 1, 1,
- GridLayout::FILL, GridLayout::CENTER);
- layout->AddView(serif_font_change_page_button_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- // Sans serif font controls.
- layout->StartRow(0, triple_column_view_set_id);
- layout->AddView(sans_serif_font_label_);
- layout->AddView(sans_serif_font_display_view_, 1, 1,
- GridLayout::FILL, GridLayout::CENTER);
- layout->AddView(sans_serif_font_change_page_button_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- // Fixed-width font controls.
- layout->StartRow(0, triple_column_view_set_id);
- layout->AddView(fixed_width_font_label_);
- layout->AddView(fixed_width_font_display_view_, 1, 1,
- GridLayout::FILL, GridLayout::CENTER);
- layout->AddView(fixed_width_font_change_page_button_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-}
-
-void FontsPageView::InitEncodingLayout() {
- default_encoding_combobox_label_ = new views::Label(
- l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_FONT_DEFAULT_ENCODING_SELECTOR_LABEL));
- default_encoding_combobox_model_.reset(new DefaultEncodingComboboxModel);
- default_encoding_combobox_ = new views::Combobox(
- default_encoding_combobox_model_.get());
- int selected_encoding_index = default_encoding_combobox_model_->
- GetSelectedEncodingIndex(profile());
- default_encoding_combobox_->SetSelectedItem(selected_encoding_index);
- default_encoding_selected_ = default_encoding_combobox_model_->
- GetEncodingCharsetByIndex(selected_encoding_index);
- default_encoding_combobox_->set_listener(this);
-
- // Now add the views.
- using views::GridLayout;
- using views::ColumnSet;
-
- encoding_contents_ = new views::View;
- GridLayout* layout = new GridLayout(encoding_contents_);
- encoding_contents_->SetLayoutManager(layout);
-
- // Double column.
- const int double_column_view_set_id = 2;
- ColumnSet* column_set = layout->AddColumnSet(double_column_view_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
-
- // Add Encoding Combobox.
- layout->StartRow(0, double_column_view_set_id);
- layout->AddView(default_encoding_combobox_label_);
- layout->AddView(default_encoding_combobox_, 1, 1, GridLayout::FILL,
- GridLayout::CENTER);
-}
diff --git a/chrome/browser/views/options/fonts_page_view.h b/chrome/browser/views/options/fonts_page_view.h
index 477bf91..22cad00 100644
--- a/chrome/browser/views/options/fonts_page_view.h
+++ b/chrome/browser/views/options/fonts_page_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -6,125 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_FONTS_PAGE_VIEW_H_
#pragma once
-#include <string>
-
-#include "chrome/browser/prefs/pref_member.h"
-#include "chrome/browser/shell_dialogs.h"
-#include "chrome/browser/views/options/options_page_view.h"
-#include "views/controls/combobox/combobox.h"
-#include "views/controls/button/button.h"
-#include "views/view.h"
-
-namespace views {
-class GroupboxView;
-class Label;
-class NativeButton;
-class TableView;
-}
-
-class DefaultEncodingComboboxModel;
-class FontDisplayView;
-class TableModel;
-
-///////////////////////////////////////////////////////////////////////////////
-// FontsPageView
-
-class FontsPageView : public OptionsPageView,
- public views::Combobox::Listener,
- public SelectFontDialog::Listener,
- public views::ButtonListener {
- public:
- explicit FontsPageView(Profile* profile);
-
- // views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // views::Combobox::Listener implementation:
- virtual void ItemChanged(views::Combobox* combo_box,
- int prev_index,
- int new_index);
-
- // SelectFontDialog::Listener implementation:
- virtual void FontSelected(const gfx::Font& font, void* params);
-
- // Save Changes made to relevent pref members associated with this tab.
- // This is public since it is called by FontsLanguageWindowView in its
- // Dialog Delegate Accept() method.
- void SaveChanges();
-
- protected:
- // OptionsPageView implementation:
- virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::string* pref_name);
-
- private:
- enum FontTypeBeingChanged {
- NONE,
- SERIF,
- SANS_SERIF,
- FIXED_WIDTH
- };
-
- virtual ~FontsPageView();
-
- // Init Dialog controls.
- void InitFontLayout();
- void InitEncodingLayout();
-
- bool serif_button_pressed_;
- bool sans_serif_button_pressed_;
- bool fixed_width_button_pressed_;
- bool encoding_dropdown_clicked_;
-
- views::Label* fonts_group_title_;
- views::Label* encoding_group_title_;
-
- views::View* fonts_contents_;
- views::View* encoding_contents_;
-
- // Fonts settings.
- // Select Font dialogs.
- scoped_refptr<SelectFontDialog> select_font_dialog_;
-
- // Buttons.
- views::NativeButton* fixed_width_font_change_page_button_;
- views::NativeButton* serif_font_change_page_button_;
- views::NativeButton* sans_serif_font_change_page_button_;
-
- // FontDisplayView objects to display selected font.
- FontDisplayView* fixed_width_font_display_view_;
- FontDisplayView* serif_font_display_view_;
- FontDisplayView* sans_serif_font_display_view_;
-
- // Labels to describe what is to be changed.
- views::Label* fixed_width_font_label_;
- views::Label* serif_font_label_;
- views::Label* sans_serif_font_label_;
-
- // Advanced Font names and sizes as PrefMembers.
- StringPrefMember serif_name_;
- StringPrefMember sans_serif_name_;
- StringPrefMember fixed_width_name_;
- IntegerPrefMember serif_size_;
- IntegerPrefMember sans_serif_size_;
- IntegerPrefMember fixed_width_size_;
- int serif_font_size_pixel_;
- int sans_serif_font_size_pixel_;
- int fixed_width_font_size_pixel_;
- StringPrefMember default_encoding_;
- bool font_changed_;
-
- // Windows font picker flag;
- FontTypeBeingChanged font_type_being_changed_;
-
- // Default Encoding.
- scoped_ptr<DefaultEncodingComboboxModel> default_encoding_combobox_model_;
- views::Label* default_encoding_combobox_label_;
- views::Combobox* default_encoding_combobox_;
- std::string default_encoding_selected_;
- bool default_encoding_changed_;
-
- DISALLOW_COPY_AND_ASSIGN(FontsPageView);
-};
+#include "chrome/browser/ui/views/options/fonts_page_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_FONTS_PAGE_VIEW_H_
+
diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc
deleted file mode 100644
index e7c4d3e..0000000
--- a/chrome/browser/views/options/general_page_view.cc
+++ /dev/null
@@ -1,883 +0,0 @@
-// 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/options/general_page_view.h"
-
-#include "app/combobox_model.h"
-#include "app/l10n_util.h"
-#include "base/callback.h"
-#include "base/message_loop.h"
-#include "base/string16.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_window.h"
-#include "chrome/browser/custom_home_pages_table_model.h"
-#include "chrome/browser/dom_ui/new_tab_ui.h"
-#include "chrome/browser/instant/instant_confirm_dialog.h"
-#include "chrome/browser/net/url_fixer_upper.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/prefs/session_startup_pref.h"
-#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/browser/search_engines/template_url_model_observer.h"
-#include "chrome/browser/show_options_url.h"
-#include "chrome/browser/views/keyword_editor_view.h"
-#include "chrome/browser/views/options/managed_prefs_banner_view.h"
-#include "chrome/browser/views/options/options_group_view.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/installer/util/browser_distribution.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "views/controls/button/radio_button.h"
-#include "views/controls/label.h"
-#include "views/controls/table/table_view.h"
-#include "views/controls/textfield/textfield.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-
-namespace {
-
-// All the options pages are in the same view hierarchy. This means we need to
-// make sure group identifiers don't collide across different pages.
-const int kStartupRadioGroup = 101;
-const int kHomePageRadioGroup = 102;
-const SkColor kDefaultBrowserLabelColor = SkColorSetRGB(0, 135, 0);
-const SkColor kNotDefaultBrowserLabelColor = SkColorSetRGB(135, 0, 0);
-const int kHomePageTextfieldWidthChars = 40;
-
-bool IsNewTabUIURLString(const GURL& url) {
- return url == GURL(chrome::kChromeUINewTabURL);
-}
-} // namespace
-
-///////////////////////////////////////////////////////////////////////////////
-// OptionsGroupContents
-class OptionsGroupContents : public views::View {
- public:
- OptionsGroupContents() { }
-
- // views::View overrides:
- virtual AccessibilityTypes::Role GetAccessibleRole() {
- return AccessibilityTypes::ROLE_GROUPING;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(OptionsGroupContents);
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// SearchEngineListModel
-
-class SearchEngineListModel : public ComboboxModel,
- public TemplateURLModelObserver {
- public:
- explicit SearchEngineListModel(Profile* profile);
- virtual ~SearchEngineListModel();
-
- // Sets the Combobox. SearchEngineListModel needs a handle to the Combobox
- // so that when the TemplateURLModel changes the combobox can be updated.
- void SetCombobox(views::Combobox* combobox);
-
- // ComboboxModel overrides:
- virtual int GetItemCount();
- virtual string16 GetItemAt(int index);
-
- // Returns the TemplateURL at the specified index.
- const TemplateURL* GetTemplateURLAt(int index);
-
- TemplateURLModel* model() { return template_url_model_; }
-
- private:
- // TemplateURLModelObserver methods.
- virtual void OnTemplateURLModelChanged();
-
- // Recalculates the TemplateURLs to display and notifies the combobox.
- void ResetContents();
-
- // Resets the selection of the combobox based on the users selected search
- // engine.
- void ChangeComboboxSelection();
-
- TemplateURLModel* template_url_model_;
-
- // The combobox hosting us.
- views::Combobox* combobox_;
-
- // The TemplateURLs we're showing.
- typedef std::vector<const TemplateURL*> TemplateURLs;
- TemplateURLs template_urls_;
-
- DISALLOW_COPY_AND_ASSIGN(SearchEngineListModel);
-};
-
-SearchEngineListModel::SearchEngineListModel(Profile* profile)
- : template_url_model_(profile->GetTemplateURLModel()),
- combobox_(NULL) {
- if (template_url_model_) {
- template_url_model_->Load();
- template_url_model_->AddObserver(this);
- }
- ResetContents();
-}
-
-SearchEngineListModel::~SearchEngineListModel() {
- if (template_url_model_)
- template_url_model_->RemoveObserver(this);
-}
-
-void SearchEngineListModel::SetCombobox(views::Combobox* combobox) {
- combobox_ = combobox;
- if (template_url_model_ && template_url_model_->loaded())
- ChangeComboboxSelection();
- else
- combobox_->SetEnabled(false);
-}
-
-int SearchEngineListModel::GetItemCount() {
- return static_cast<int>(template_urls_.size());
-}
-
-string16 SearchEngineListModel::GetItemAt(int index) {
- DCHECK(index < GetItemCount());
- return WideToUTF16Hack(template_urls_[index]->short_name());
-}
-
-const TemplateURL* SearchEngineListModel::GetTemplateURLAt(int index) {
- DCHECK(index >= 0 && index < static_cast<int>(template_urls_.size()));
- return template_urls_[static_cast<int>(index)];
-}
-
-void SearchEngineListModel::OnTemplateURLModelChanged() {
- ResetContents();
-}
-
-void SearchEngineListModel::ResetContents() {
- if (!template_url_model_ || !template_url_model_->loaded())
- return;
- template_urls_.clear();
- TemplateURLs model_urls = template_url_model_->GetTemplateURLs();
- for (size_t i = 0; i < model_urls.size(); ++i) {
- if (model_urls[i]->ShowInDefaultList())
- template_urls_.push_back(model_urls[i]);
- }
-
- if (combobox_) {
- combobox_->ModelChanged();
- ChangeComboboxSelection();
- }
-}
-
-void SearchEngineListModel::ChangeComboboxSelection() {
- if (template_urls_.size()) {
- const TemplateURL* default_search_provider =
- template_url_model_->GetDefaultSearchProvider();
- if (default_search_provider) {
- TemplateURLs::iterator i =
- find(template_urls_.begin(), template_urls_.end(),
- default_search_provider);
- if (i != template_urls_.end()) {
- combobox_->SetSelectedItem(
- static_cast<int>(i - template_urls_.begin()));
- }
- } else {
- combobox_->SetSelectedItem(-1);
- }
- }
- // If the default search is managed or there are no URLs, disable the control.
- combobox_->SetEnabled(!template_urls_.empty() &&
- !template_url_model_->is_default_search_managed());
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// GeneralPageView, public:
-
-GeneralPageView::GeneralPageView(Profile* profile)
- : startup_group_(NULL),
- startup_homepage_radio_(NULL),
- startup_last_session_radio_(NULL),
- startup_custom_radio_(NULL),
- startup_add_custom_page_button_(NULL),
- startup_remove_custom_page_button_(NULL),
- startup_use_current_page_button_(NULL),
- startup_custom_pages_table_(NULL),
- homepage_group_(NULL),
- homepage_use_newtab_radio_(NULL),
- homepage_use_url_radio_(NULL),
- homepage_use_url_textfield_(NULL),
- homepage_show_home_button_checkbox_(NULL),
- default_search_group_(NULL),
- default_search_manage_engines_button_(NULL),
- instant_checkbox_(NULL),
- instant_link_(NULL),
- default_browser_group_(NULL),
- default_browser_status_label_(NULL),
- default_browser_use_as_default_button_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- default_browser_worker_(
- new ShellIntegration::DefaultBrowserWorker(this))),
- OptionsPageView(profile) {
-}
-
-GeneralPageView::~GeneralPageView() {
- if (startup_custom_pages_table_)
- startup_custom_pages_table_->SetModel(NULL);
- default_browser_worker_->ObserverDestroyed();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// GeneralPageView, views::ButtonListener implementation:
-
-void GeneralPageView::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (sender == startup_homepage_radio_ ||
- sender == startup_last_session_radio_ ||
- sender == startup_custom_radio_) {
- SaveStartupPref();
- if (sender == startup_homepage_radio_) {
- UserMetricsRecordAction(UserMetricsAction("Options_Startup_Homepage"),
- profile()->GetPrefs());
- } else if (sender == startup_last_session_radio_) {
- UserMetricsRecordAction(UserMetricsAction("Options_Startup_LastSession"),
- profile()->GetPrefs());
- } else if (sender == startup_custom_radio_) {
- UserMetricsRecordAction(UserMetricsAction("Options_Startup_Custom"),
- profile()->GetPrefs());
- }
- } else if (sender == startup_add_custom_page_button_) {
- AddURLToStartupURLs();
- } else if (sender == startup_remove_custom_page_button_) {
- RemoveURLsFromStartupURLs();
- } else if (sender == startup_use_current_page_button_) {
- SetStartupURLToCurrentPage();
- } else if (sender == homepage_use_newtab_radio_) {
- UserMetricsRecordAction(UserMetricsAction("Options_Homepage_UseNewTab"),
- profile()->GetPrefs());
- UpdateHomepagePrefs();
- EnableHomepageURLField(false);
- } else if (sender == homepage_use_url_radio_) {
- UserMetricsRecordAction(UserMetricsAction("Options_Homepage_UseURL"),
- profile()->GetPrefs());
- UpdateHomepagePrefs();
- EnableHomepageURLField(true);
- } else if (sender == homepage_show_home_button_checkbox_) {
- bool show_button = homepage_show_home_button_checkbox_->checked();
- if (show_button) {
- UserMetricsRecordAction(
- UserMetricsAction("Options_Homepage_ShowHomeButton"),
- profile()->GetPrefs());
- } else {
- UserMetricsRecordAction(
- UserMetricsAction("Options_Homepage_HideHomeButton"),
- profile()->GetPrefs());
- }
- show_home_button_.SetValue(show_button);
- } else if (sender == default_browser_use_as_default_button_) {
- default_browser_worker_->StartSetAsDefaultBrowser();
- UserMetricsRecordAction(UserMetricsAction("Options_SetAsDefaultBrowser"),
- NULL);
- // If the user made Chrome the default browser, then he/she arguably wants
- // to be notified when that changes.
- profile()->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, true);
- } else if (sender == default_search_manage_engines_button_) {
- UserMetricsRecordAction(UserMetricsAction("Options_ManageSearchEngines"),
- NULL);
- KeywordEditorView::Show(profile());
- } else if (sender == instant_checkbox_) {
- if (instant_checkbox_->checked()) {
- // Don't toggle immediately, instead let
- // ShowInstantConfirmDialogIfNecessary do it.
- instant_checkbox_->SetChecked(false);
- browser::ShowInstantConfirmDialogIfNecessary(
- GetWindow()->GetNativeWindow(), profile());
- } else {
- profile()->GetPrefs()->SetBoolean(prefs::kInstantEnabled, false);
- }
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// GeneralPageView, views::Combobox::Listener implementation:
-
-void GeneralPageView::ItemChanged(views::Combobox* combobox,
- int prev_index, int new_index) {
- if (combobox == default_search_engine_combobox_) {
- SetDefaultSearchProvider();
- UserMetricsRecordAction(UserMetricsAction("Options_SearchEngineChanged"),
- NULL);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// GeneralPageView, views::Textfield::Controller implementation:
-
-void GeneralPageView::ContentsChanged(views::Textfield* sender,
- const std::wstring& new_contents) {
- if (sender == homepage_use_url_textfield_) {
- UpdateHomepagePrefs();
- }
-}
-
-bool GeneralPageView::HandleKeystroke(views::Textfield* sender,
- const views::Textfield::Keystroke&) {
- return false;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// GeneralPageView, OptionsPageView implementation:
-
-void GeneralPageView::InitControlLayout() {
- using views::GridLayout;
- using views::ColumnSet;
-
- GridLayout* layout = new GridLayout(this);
- layout->SetInsets(5, 5, 5, 5);
- SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(
- new ManagedPrefsBannerView(profile()->GetPrefs(), OPTIONS_PAGE_GENERAL));
-
- layout->StartRow(0, single_column_view_set_id);
- InitStartupGroup();
- layout->AddView(startup_group_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- layout->StartRow(0, single_column_view_set_id);
- InitHomepageGroup();
- layout->AddView(homepage_group_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- layout->StartRow(0, single_column_view_set_id);
- InitDefaultSearchGroup();
- layout->AddView(default_search_group_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
-#if !defined(OS_CHROMEOS)
- layout->StartRow(0, single_column_view_set_id);
- InitDefaultBrowserGroup();
- layout->AddView(default_browser_group_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-#endif
-
- // Register pref observers that update the controls when a pref changes.
- registrar_.Init(profile()->GetPrefs());
- registrar_.Add(prefs::kRestoreOnStartup, this);
- registrar_.Add(prefs::kURLsToRestoreOnStartup, this);
- registrar_.Add(prefs::kInstantEnabled, this);
-
- new_tab_page_is_home_page_.Init(prefs::kHomePageIsNewTabPage,
- profile()->GetPrefs(), this);
- homepage_.Init(prefs::kHomePage, profile()->GetPrefs(), this);
- show_home_button_.Init(prefs::kShowHomeButton, profile()->GetPrefs(), this);
-}
-
-void GeneralPageView::NotifyPrefChanged(const std::string* pref_name) {
- PrefService* prefs = profile()->GetPrefs();
- if (!pref_name ||
- *pref_name == prefs::kRestoreOnStartup ||
- *pref_name == prefs::kURLsToRestoreOnStartup) {
- const SessionStartupPref startup_pref =
- SessionStartupPref::GetStartupPref(prefs);
- bool radio_buttons_enabled = !SessionStartupPref::TypeIsManaged(prefs);
- bool restore_urls_enabled = !SessionStartupPref::URLsAreManaged(prefs);
- switch (startup_pref.type) {
- case SessionStartupPref::DEFAULT:
- startup_homepage_radio_->SetChecked(true);
- restore_urls_enabled = false;
- break;
-
- case SessionStartupPref::LAST:
- startup_last_session_radio_->SetChecked(true);
- restore_urls_enabled = false;
- break;
-
- case SessionStartupPref::URLS:
- startup_custom_radio_->SetChecked(true);
- break;
- }
- startup_homepage_radio_->SetEnabled(radio_buttons_enabled);
- startup_last_session_radio_->SetEnabled(radio_buttons_enabled);
- startup_custom_radio_->SetEnabled(radio_buttons_enabled);
- EnableCustomHomepagesControls(restore_urls_enabled);
- startup_custom_pages_table_model_->SetURLs(startup_pref.urls);
- }
-
- if (!pref_name ||
- *pref_name == prefs::kHomePageIsNewTabPage ||
- *pref_name == prefs::kHomePage) {
- bool new_tab_page_is_home_page_managed =
- new_tab_page_is_home_page_.IsManaged();
- bool homepage_managed = homepage_.IsManaged();
- bool homepage_url_is_new_tab =
- IsNewTabUIURLString(GURL(homepage_.GetValue()));
- bool homepage_is_new_tab = homepage_url_is_new_tab ||
- new_tab_page_is_home_page_.GetValue();
- // If HomepageIsNewTab is managed or
- // Homepage is 'chrome://newtab' and managed, disable the radios.
- bool disable_homepage_choice_buttons =
- new_tab_page_is_home_page_managed ||
- homepage_managed && homepage_url_is_new_tab;
- if (!homepage_url_is_new_tab)
- homepage_use_url_textfield_->SetText(UTF8ToWide(homepage_.GetValue()));
- UpdateHomepageIsNewTabRadio(
- homepage_is_new_tab, !disable_homepage_choice_buttons);
- EnableHomepageURLField(!homepage_is_new_tab);
- }
-
- if (!pref_name || *pref_name == prefs::kShowHomeButton) {
- homepage_show_home_button_checkbox_->SetChecked(
- show_home_button_.GetValue());
- homepage_show_home_button_checkbox_->SetEnabled(
- !show_home_button_.IsManaged());
- }
-
- if (!pref_name || *pref_name == prefs::kInstantEnabled)
- instant_checkbox_->SetChecked(prefs->GetBoolean(prefs::kInstantEnabled));
-}
-
-void GeneralPageView::HighlightGroup(OptionsGroup highlight_group) {
- if (highlight_group == OPTIONS_GROUP_DEFAULT_SEARCH)
- default_search_group_->SetHighlighted(true);
-}
-
-void GeneralPageView::LinkActivated(views::Link* source, int event_flags) {
- DCHECK(source == instant_link_);
- browser::ShowOptionsURL(profile(),
- GURL(browser::kInstantLearnMoreURL));
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// GeneralPageView, private:
-
-void GeneralPageView::SetDefaultBrowserUIState(
- ShellIntegration::DefaultBrowserUIState state) {
- bool button_enabled = state == ShellIntegration::STATE_NOT_DEFAULT;
- default_browser_use_as_default_button_->SetEnabled(button_enabled);
- default_browser_use_as_default_button_->SetNeedElevation(true);
- if (state == ShellIntegration::STATE_IS_DEFAULT) {
- default_browser_status_label_->SetText(
- l10n_util::GetStringF(IDS_OPTIONS_DEFAULTBROWSER_DEFAULT,
- l10n_util::GetString(IDS_PRODUCT_NAME)));
- default_browser_status_label_->SetColor(kDefaultBrowserLabelColor);
- Layout();
- } else if (state == ShellIntegration::STATE_NOT_DEFAULT) {
- default_browser_status_label_->SetText(
- l10n_util::GetStringF(IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT,
- l10n_util::GetString(IDS_PRODUCT_NAME)));
- default_browser_status_label_->SetColor(kNotDefaultBrowserLabelColor);
- Layout();
- } else if (state == ShellIntegration::STATE_UNKNOWN) {
- default_browser_status_label_->SetText(
- l10n_util::GetStringF(IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN,
- l10n_util::GetString(IDS_PRODUCT_NAME)));
- default_browser_status_label_->SetColor(kNotDefaultBrowserLabelColor);
- Layout();
- }
-}
-
-void GeneralPageView::SetDefaultBrowserUIStateForSxS() {
- default_browser_use_as_default_button_->SetEnabled(false);
- default_browser_status_label_->SetText(
- l10n_util::GetStringF(IDS_OPTIONS_DEFAULTBROWSER_SXS,
- l10n_util::GetString(IDS_PRODUCT_NAME)));
- default_browser_status_label_->SetColor(kNotDefaultBrowserLabelColor);
- Layout();
-}
-
-void GeneralPageView::InitStartupGroup() {
- startup_homepage_radio_ = new views::RadioButton(
- l10n_util::GetString(IDS_OPTIONS_STARTUP_SHOW_DEFAULT_AND_NEWTAB),
- kStartupRadioGroup);
- startup_homepage_radio_->set_listener(this);
- startup_last_session_radio_ = new views::RadioButton(
- l10n_util::GetString(IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION),
- kStartupRadioGroup);
- startup_last_session_radio_->set_listener(this);
- startup_last_session_radio_->SetMultiLine(true);
- startup_custom_radio_ = new views::RadioButton(
- l10n_util::GetString(IDS_OPTIONS_STARTUP_SHOW_PAGES),
- kStartupRadioGroup);
- startup_custom_radio_->set_listener(this);
- startup_add_custom_page_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_OPTIONS_STARTUP_ADD_BUTTON));
- startup_remove_custom_page_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_OPTIONS_STARTUP_REMOVE_BUTTON));
- startup_remove_custom_page_button_->SetEnabled(false);
- startup_use_current_page_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_OPTIONS_STARTUP_USE_CURRENT));
-
- startup_custom_pages_table_model_.reset(
- new CustomHomePagesTableModel(profile()));
- std::vector<TableColumn> columns;
- columns.push_back(TableColumn());
- startup_custom_pages_table_ = new views::TableView(
- startup_custom_pages_table_model_.get(), columns,
- views::ICON_AND_TEXT, false, false, true);
- startup_custom_pages_table_->SetObserver(this);
-
- using views::GridLayout;
- using views::ColumnSet;
-
- views::View* contents = new OptionsGroupContents;
- GridLayout* layout = new GridLayout(contents);
- contents->SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
-
- const int double_column_view_set_id = 1;
- column_set = layout->AddColumnSet(double_column_view_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(startup_homepage_radio_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(startup_last_session_radio_, 1, 1,
- GridLayout::FILL, GridLayout::LEADING);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(startup_custom_radio_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- layout->StartRow(0, double_column_view_set_id);
- layout->AddView(startup_custom_pages_table_, 1, 1,
- GridLayout::FILL, GridLayout::FILL);
-
- views::View* button_stack = new views::View;
- GridLayout* button_stack_layout = new GridLayout(button_stack);
- button_stack->SetLayoutManager(button_stack_layout);
-
- column_set = button_stack_layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- button_stack_layout->StartRow(0, single_column_view_set_id);
- button_stack_layout->AddView(startup_add_custom_page_button_,
- 1, 1, GridLayout::FILL, GridLayout::CENTER);
- button_stack_layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- button_stack_layout->StartRow(0, single_column_view_set_id);
- button_stack_layout->AddView(startup_remove_custom_page_button_,
- 1, 1, GridLayout::FILL, GridLayout::CENTER);
- button_stack_layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- button_stack_layout->StartRow(0, single_column_view_set_id);
- button_stack_layout->AddView(startup_use_current_page_button_,
- 1, 1, GridLayout::FILL, GridLayout::CENTER);
- layout->AddView(button_stack);
-
- startup_group_ = new OptionsGroupView(
- contents, l10n_util::GetString(IDS_OPTIONS_STARTUP_GROUP_NAME),
- std::wstring(), true);
-}
-
-void GeneralPageView::InitHomepageGroup() {
- homepage_use_newtab_radio_ = new views::RadioButton(
- l10n_util::GetString(IDS_OPTIONS_HOMEPAGE_USE_NEWTAB),
- kHomePageRadioGroup);
- homepage_use_newtab_radio_->set_listener(this);
- homepage_use_newtab_radio_->SetMultiLine(true);
- homepage_use_url_radio_ = new views::RadioButton(
- l10n_util::GetString(IDS_OPTIONS_HOMEPAGE_USE_URL),
- kHomePageRadioGroup);
- homepage_use_url_radio_->set_listener(this);
- homepage_use_url_textfield_ = new views::Textfield;
- homepage_use_url_textfield_->SetController(this);
- homepage_use_url_textfield_->set_default_width_in_chars(
- kHomePageTextfieldWidthChars);
- homepage_show_home_button_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_HOMEPAGE_SHOW_BUTTON));
- homepage_show_home_button_checkbox_->set_listener(this);
- homepage_show_home_button_checkbox_->SetMultiLine(true);
-
- using views::GridLayout;
- using views::ColumnSet;
-
- views::View* contents = new views::View;
- GridLayout* layout = new GridLayout(contents);
- contents->SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
-
- const int double_column_view_set_id = 1;
- column_set = layout->AddColumnSet(double_column_view_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(homepage_use_newtab_radio_, 1, 1,
- GridLayout::FILL, GridLayout::LEADING);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, double_column_view_set_id);
- layout->AddView(homepage_use_url_radio_);
- layout->AddView(homepage_use_url_textfield_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(homepage_show_home_button_checkbox_, 1, 1,
- GridLayout::FILL, GridLayout::LEADING);
-
- homepage_group_ = new OptionsGroupView(
- contents, l10n_util::GetString(IDS_OPTIONS_HOMEPAGE_GROUP_NAME),
- std::wstring(), true);
-}
-
-
-void GeneralPageView::InitDefaultSearchGroup() {
- default_search_engines_model_.reset(new SearchEngineListModel(profile()));
- default_search_engine_combobox_ =
- new views::Combobox(default_search_engines_model_.get());
- default_search_engines_model_->SetCombobox(default_search_engine_combobox_);
- default_search_engine_combobox_->set_listener(this);
-
- default_search_manage_engines_button_ = new views::NativeButton(
- this,
- l10n_util::GetString(IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES_LINK));
-
- instant_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_INSTANT_PREF));
- instant_checkbox_->SetMultiLine(true);
- instant_checkbox_->set_listener(this);
-
- instant_link_ = new views::Link(l10n_util::GetString(IDS_LEARN_MORE));
- instant_link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- instant_link_->SetController(this);
-
- using views::GridLayout;
- using views::ColumnSet;
-
- views::View* contents = new views::View;
- GridLayout* layout = new GridLayout(contents);
- contents->SetLayoutManager(layout);
-
- const int double_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(double_column_view_set_id);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
-
- const int single_column_view_set_id = 1;
- column_set = layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
-
- const int link_column_set_id = 2;
- column_set = layout->AddColumnSet(link_column_set_id);
- // TODO(sky): this isn't right, we need a method to determine real indent.
- column_set->AddPaddingColumn(0, views::Checkbox::GetTextIndent() + 3);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, double_column_view_set_id);
- layout->AddView(default_search_engine_combobox_);
- layout->AddView(default_search_manage_engines_button_);
- layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
-
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(instant_checkbox_);
- layout->AddPaddingRow(0, 0);
-
- layout->StartRow(0, link_column_set_id);
- layout->AddView(
- new views::Label(l10n_util::GetString(IDS_INSTANT_PREF_WARNING)));
- layout->AddView(instant_link_);
-
- default_search_group_ = new OptionsGroupView(
- contents, l10n_util::GetString(IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME),
- std::wstring(), true);
-}
-
-void GeneralPageView::InitDefaultBrowserGroup() {
- default_browser_status_label_ = new views::Label;
- default_browser_status_label_->SetMultiLine(true);
- default_browser_status_label_->SetHorizontalAlignment(
- views::Label::ALIGN_LEFT);
- default_browser_use_as_default_button_ = new views::NativeButton(
- this,
- l10n_util::GetStringF(IDS_OPTIONS_DEFAULTBROWSER_USEASDEFAULT,
- l10n_util::GetString(IDS_PRODUCT_NAME)));
-
- using views::GridLayout;
- using views::ColumnSet;
-
- views::View* contents = new views::View;
- GridLayout* layout = new GridLayout(contents);
- contents->SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(default_browser_status_label_, 1, 1,
- GridLayout::FILL, GridLayout::LEADING);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(default_browser_use_as_default_button_);
-
- default_browser_group_ = new OptionsGroupView(
- contents, l10n_util::GetString(IDS_OPTIONS_DEFAULTBROWSER_GROUP_NAME),
- std::wstring(), false);
-
- if (BrowserDistribution::GetDistribution()->CanSetAsDefault())
- default_browser_worker_->StartCheckDefaultBrowser();
- else
- SetDefaultBrowserUIStateForSxS();
-}
-
-void GeneralPageView::SaveStartupPref() {
- SessionStartupPref pref;
-
- if (startup_last_session_radio_->checked()) {
- pref.type = SessionStartupPref::LAST;
- } else if (startup_custom_radio_->checked()) {
- pref.type = SessionStartupPref::URLS;
- }
-
- pref.urls = startup_custom_pages_table_model_->GetURLs();
-
- SessionStartupPref::SetStartupPref(profile()->GetPrefs(), pref);
-}
-
-void GeneralPageView::AddURLToStartupURLs() {
- UrlPicker* dialog = new UrlPicker(this, profile());
- dialog->Show(GetWindow()->GetNativeWindow());
-}
-
-void GeneralPageView::RemoveURLsFromStartupURLs() {
- int selected_row = 0;
- for (views::TableView::iterator i =
- startup_custom_pages_table_->SelectionBegin();
- i != startup_custom_pages_table_->SelectionEnd(); ++i) {
- startup_custom_pages_table_model_->Remove(*i);
- selected_row = *i;
- }
- int row_count = startup_custom_pages_table_->RowCount();
- if (selected_row >= row_count)
- selected_row = row_count - 1;
- if (selected_row >= 0) {
- // Select the next row after the last row deleted, or the above item if the
- // latest item was deleted or nothing when the table doesn't have any items.
- startup_custom_pages_table_->Select(selected_row);
- }
- SaveStartupPref();
-}
-
-void GeneralPageView::SetStartupURLToCurrentPage() {
- startup_custom_pages_table_model_->SetToCurrentlyOpenPages();
-
- SaveStartupPref();
-}
-
-void GeneralPageView::EnableCustomHomepagesControls(bool enable) {
- startup_add_custom_page_button_->SetEnabled(enable);
- bool has_selected_rows = startup_custom_pages_table_->SelectedRowCount() > 0;
- startup_remove_custom_page_button_->SetEnabled(enable && has_selected_rows);
- startup_use_current_page_button_->SetEnabled(enable);
- startup_custom_pages_table_->SetEnabled(enable);
-}
-
-void GeneralPageView::AddBookmark(UrlPicker* dialog,
- const std::wstring& title,
- const GURL& url) {
- // The restore URLs policy might have become managed while the dialog is
- // displayed. While the model makes sure that no changes are made in this
- // condition, we should still avoid changing the graphic elements.
- if (SessionStartupPref::URLsAreManaged(profile()->GetPrefs()))
- return;
- int index = startup_custom_pages_table_->FirstSelectedRow();
- if (index == -1)
- index = startup_custom_pages_table_model_->RowCount();
- else
- index++;
- startup_custom_pages_table_model_->Add(index, url);
- startup_custom_pages_table_->Select(index);
-
- SaveStartupPref();
-}
-
-void GeneralPageView::UpdateHomepagePrefs() {
- // If the text field contains a valid URL, sync it to prefs. We run it
- // through the fixer upper to allow input like "google.com" to be converted
- // to something valid ("http://google.com"). If the field contains an
- // empty or null-host URL, a blank homepage is synced to prefs.
- const GURL& homepage =
- URLFixerUpper::FixupURL(
- UTF16ToUTF8(homepage_use_url_textfield_->text()), std::string());
- bool new_tab_page_is_home_page = homepage_use_newtab_radio_->checked();
- if (IsNewTabUIURLString(homepage)) { // 'chrome://newtab/'
- // This should be handled differently than invalid URLs.
- // When the control arrives here, then |homepage| contains
- // 'chrome://newtab/', and the homepage preference contains the previous
- // valid content of the textfield (fixed up), most likely
- // 'chrome://newta/'. This has to be cleared, because keeping it makes no
- // sense to the user.
- new_tab_page_is_home_page = true;
- homepage_.SetValueIfNotManaged(std::string());
- } else if (!homepage.is_valid()) {
- new_tab_page_is_home_page = true;
- // The URL is invalid either with a host (e.g. http://chr%mium.org)
- // or without a host (e.g. http://). In case there is a host, then
- // the URL is not cleared, saving a fragment of the URL to the
- // preferences (e.g. http://chr in case the characters of the above example
- // were typed by the user one by one).
- // See bug 40996.
- if (!homepage.has_host())
- homepage_.SetValueIfNotManaged(std::string());
- } else {
- homepage_.SetValueIfNotManaged(homepage.spec());
- }
- new_tab_page_is_home_page_.SetValueIfNotManaged(new_tab_page_is_home_page);
-}
-
-void GeneralPageView::UpdateHomepageIsNewTabRadio(bool homepage_is_new_tab,
- bool enabled) {
- homepage_use_newtab_radio_->SetChecked(homepage_is_new_tab);
- homepage_use_url_radio_->SetChecked(!homepage_is_new_tab);
- homepage_use_newtab_radio_->SetEnabled(enabled);
- homepage_use_url_radio_->SetEnabled(enabled);
-}
-
-void GeneralPageView::OnSelectionChanged() {
- startup_remove_custom_page_button_->SetEnabled(
- startup_custom_pages_table_->SelectedRowCount() > 0);
-}
-
-void GeneralPageView::EnableHomepageURLField(bool enabled) {
- if (homepage_.IsManaged()) {
- enabled = false;
- }
- homepage_use_url_textfield_->SetEnabled(enabled);
- homepage_use_url_textfield_->SetReadOnly(!enabled);
-}
-
-void GeneralPageView::SetDefaultSearchProvider() {
- const int index = default_search_engine_combobox_->selected_item();
- default_search_engines_model_->model()->SetDefaultSearchProvider(
- default_search_engines_model_->GetTemplateURLAt(index));
-}
diff --git a/chrome/browser/views/options/general_page_view.h b/chrome/browser/views/options/general_page_view.h
index a663c82..f9072e1 100644
--- a/chrome/browser/views/options/general_page_view.h
+++ b/chrome/browser/views/options/general_page_view.h
@@ -6,167 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_GENERAL_PAGE_VIEW_H_
#pragma once
-#include "chrome/browser/prefs/pref_change_registrar.h"
-#include "chrome/browser/prefs/pref_member.h"
-#include "chrome/browser/shell_integration.h"
-#include "chrome/browser/views/options/options_page_view.h"
-#include "chrome/browser/views/url_picker.h"
-#include "views/controls/combobox/combobox.h"
-#include "views/controls/button/button.h"
-#include "views/controls/link.h"
-#include "views/controls/table/table_view_observer.h"
-#include "views/view.h"
-
-namespace views {
-class Checkbox;
-class GroupboxView;
-class Label;
-class NativeButton;
-class RadioButton;
-class TableView;
-class Textfield;
-}
-class CustomHomePagesTableModel;
-class OptionsGroupView;
-class SearchEngineListModel;
-class TableModel;
-
-///////////////////////////////////////////////////////////////////////////////
-// GeneralPageView
-
-class GeneralPageView : public OptionsPageView,
- public views::Combobox::Listener,
- public views::ButtonListener,
- public views::Textfield::Controller,
- public UrlPickerDelegate,
- public views::TableViewObserver,
- public ShellIntegration::DefaultBrowserObserver,
- public views::LinkController {
- public:
- explicit GeneralPageView(Profile* profile);
- virtual ~GeneralPageView();
-
- protected:
- // views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // views::Combobox::Listener implementation:
- virtual void ItemChanged(views::Combobox* combobox,
- int prev_index,
- int new_index);
-
- // views::Textfield::Controller implementation:
- virtual void ContentsChanged(views::Textfield* sender,
- const std::wstring& new_contents);
- virtual bool HandleKeystroke(views::Textfield* sender,
- const views::Textfield::Keystroke& key);
-
- // OptionsPageView implementation:
- virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::string* pref_name);
- virtual void HighlightGroup(OptionsGroup highlight_group);
-
- // LinkController implementation:
- virtual void LinkActivated(views::Link* source, int event_flags);
-
- private:
- // ShellIntegration::DefaultBrowserObserver implementation:
- // Updates the UI state to reflect the current default browser state.
- virtual void SetDefaultBrowserUIState(
- ShellIntegration::DefaultBrowserUIState state);
-
- // For Side by Side installs, this will disable the Default Browser setting
- // and display an explanitory message.
- void SetDefaultBrowserUIStateForSxS();
-
- // Init all the dialog controls
- void InitStartupGroup();
- void InitHomepageGroup();
- void InitDefaultSearchGroup();
- void InitDefaultBrowserGroup();
-
- // Saves the startup preference from that of the ui.
- void SaveStartupPref();
-
- // Shows a dialog allowing the user to add a new URL to the set of URLs
- // launched on startup.
- void AddURLToStartupURLs();
-
- // Removes the selected URL from the list of startup urls.
- void RemoveURLsFromStartupURLs();
-
- // Resets the list of urls to launch on startup from the list of open
- // browsers.
- void SetStartupURLToCurrentPage();
-
- // Enables/Disables the controls associated with the custom start pages
- // option if that preference is not selected.
- void EnableCustomHomepagesControls(bool enable);
-
- // UrlPickerDelegate. Adds the URL to the list of startup urls.
- virtual void AddBookmark(UrlPicker* dialog,
- const std::wstring& title,
- const GURL& url);
-
- // Copies the home page preferences from the gui controls to
- // kNewTabPageIsHomePage and kHomePage. If an empty or null-host
- // URL is specified, then we revert to using NewTab page as the Homepage.
- void UpdateHomepagePrefs();
-
- // Invoked when the selection of the table view changes. Updates the enabled
- // property of the remove button.
- virtual void OnSelectionChanged();
-
- // Enables or disables the field for entering a custom homepage URL.
- void EnableHomepageURLField(bool enabled);
-
- // Sets the state and enables/disables the radio buttons that control
- // if the home page is the new tab page.
- void UpdateHomepageIsNewTabRadio(bool homepage_is_new_tab, bool enabled);
-
- // Sets the default search provider for the selected item in the combobox.
- void SetDefaultSearchProvider();
-
- // Controls for the Startup group
- OptionsGroupView* startup_group_;
- views::RadioButton* startup_homepage_radio_;
- views::RadioButton* startup_last_session_radio_;
- views::RadioButton* startup_custom_radio_;
- views::NativeButton* startup_add_custom_page_button_;
- views::NativeButton* startup_remove_custom_page_button_;
- views::NativeButton* startup_use_current_page_button_;
- views::TableView* startup_custom_pages_table_;
- scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_;
-
- // Controls for the Home Page group
- OptionsGroupView* homepage_group_;
- views::RadioButton* homepage_use_newtab_radio_;
- views::RadioButton* homepage_use_url_radio_;
- views::Textfield* homepage_use_url_textfield_;
- views::Checkbox* homepage_show_home_button_checkbox_;
- BooleanPrefMember new_tab_page_is_home_page_;
- StringPrefMember homepage_;
- BooleanPrefMember show_home_button_;
-
- // Controls for the Search group
- OptionsGroupView* default_search_group_;
- views::Combobox* default_search_engine_combobox_;
- views::NativeButton* default_search_manage_engines_button_;
- scoped_ptr<SearchEngineListModel> default_search_engines_model_;
- views::Checkbox* instant_checkbox_;
- views::Link* instant_link_;
-
- // Controls for the Default Browser group
- OptionsGroupView* default_browser_group_;
- views::Label* default_browser_status_label_;
- views::NativeButton* default_browser_use_as_default_button_;
-
- // The helper object that performs default browser set/check tasks.
- scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_;
-
- PrefChangeRegistrar registrar_;
-
- DISALLOW_COPY_AND_ASSIGN(GeneralPageView);
-};
+#include "chrome/browser/ui/views/options/general_page_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_GENERAL_PAGE_VIEW_H_
+
diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc
deleted file mode 100644
index 207841c..0000000
--- a/chrome/browser/views/options/languages_page_view.cc
+++ /dev/null
@@ -1,579 +0,0 @@
-// 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 <windows.h>
-#include <shlobj.h>
-#include <vsstyle.h>
-#include <vssym32.h>
-
-#include "chrome/browser/views/options/languages_page_view.h"
-
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "base/command_line.h"
-#include "base/file_util.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/language_combobox_model.h"
-#include "chrome/browser/language_order_table_model.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/shell_dialogs.h"
-#include "chrome/browser/views/restart_message_box.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/spellcheck_common.h"
-#include "gfx/canvas.h"
-#include "gfx/font.h"
-#include "gfx/native_theme_win.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "unicode/uloc.h"
-#include "views/controls/button/radio_button.h"
-#include "views/controls/tabbed_pane/tabbed_pane.h"
-#include "views/controls/table/table_view.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-#include "views/widget/widget.h"
-#include "views/window/window.h"
-
-///////////////////////////////////////////////////////////////////////////////
-// AddLanguageWindowView
-//
-// This opens another window from where a new accept language can be selected.
-//
-class AddLanguageWindowView : public views::View,
- public views::Combobox::Listener,
- public views::DialogDelegate {
- public:
- AddLanguageWindowView(LanguagesPageView* language_delegate, Profile* profile);
- views::Window* container() const { return container_; }
- void set_container(views::Window* container) {
- container_ = container;
- }
-
- // views::DialogDelegate methods.
- virtual bool Accept();
- virtual std::wstring GetWindowTitle() const;
-
- // views::WindowDelegate method.
- virtual bool IsModal() const { return true; }
- virtual views::View* GetContentsView() { return this; }
-
- // views::Combobox::Listener implementation:
- virtual void ItemChanged(views::Combobox* combobox,
- int prev_index,
- int new_index);
-
- // views::View overrides.
- virtual void Layout();
- virtual gfx::Size GetPreferredSize();
-
- protected:
- virtual void ViewHierarchyChanged(bool is_add, views::View* parent,
- views::View* child);
-
- private:
- void Init();
-
- // The Options dialog window.
- views::Window* container_;
-
- // Used for Call back to LanguagePageView that language has been selected.
- LanguagesPageView* language_delegate_;
- std::string accept_language_selected_;
-
- // Combobox and its corresponding model.
- scoped_ptr<LanguageComboboxModel> accept_language_combobox_model_;
- views::Combobox* accept_language_combobox_;
-
- // The Profile associated with this window.
- Profile* profile_;
-
- DISALLOW_COPY_AND_ASSIGN(AddLanguageWindowView);
-};
-
-static const int kDialogPadding = 7;
-static int kDefaultWindowWidthChars = 60;
-static int kDefaultWindowHeightLines = 3;
-
-AddLanguageWindowView::AddLanguageWindowView(
- LanguagesPageView* language_delegate,
- Profile* profile)
- : profile_(profile->GetOriginalProfile()),
- language_delegate_(language_delegate),
- accept_language_combobox_(NULL) {
- Init();
-
- // Initialize accept_language_selected_ to the first index in drop down.
- accept_language_selected_ = accept_language_combobox_model_->
- GetLocaleFromIndex(0);
-}
-
-std::wstring AddLanguageWindowView::GetWindowTitle() const {
- return l10n_util::GetString(IDS_FONT_LANGUAGE_SETTING_LANGUAGES_TAB_TITLE);
-}
-
-bool AddLanguageWindowView::Accept() {
- if (language_delegate_) {
- language_delegate_->OnAddLanguage(accept_language_selected_);
- }
- return true;
-}
-
-void AddLanguageWindowView::ItemChanged(views::Combobox* combobox,
- int prev_index,
- int new_index) {
- accept_language_selected_ = accept_language_combobox_model_->
- GetLocaleFromIndex(new_index);
-}
-
-void AddLanguageWindowView::Layout() {
- gfx::Size sz = accept_language_combobox_->GetPreferredSize();
- accept_language_combobox_->SetBounds(kDialogPadding, kDialogPadding,
- width() - 2*kDialogPadding,
- sz.height());
-}
-
-gfx::Size AddLanguageWindowView::GetPreferredSize() {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- const gfx::Font& font = rb.GetFont(ResourceBundle::BaseFont);
- return gfx::Size(font.GetAverageCharacterWidth() * kDefaultWindowWidthChars,
- font.GetHeight() * kDefaultWindowHeightLines);
-}
-
-void AddLanguageWindowView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- // Can't init before we're inserted into a Widget, because we require
- // a HWND to parent native child controls to.
- if (is_add && child == this)
- Init();
-}
-
-void AddLanguageWindowView::Init() {
- // Determine Locale Codes.
- const std::string app_locale = g_browser_process->GetApplicationLocale();
- std::vector<std::string> locale_codes;
- l10n_util::GetAcceptLanguagesForLocale(app_locale, &locale_codes);
-
- accept_language_combobox_model_.reset(new LanguageComboboxModel(
- profile_, locale_codes));
- accept_language_combobox_ = new views::Combobox(
- accept_language_combobox_model_.get());
- accept_language_combobox_->SetSelectedItem(0);
- accept_language_combobox_->set_listener(this);
- AddChildView(accept_language_combobox_);
-}
-
-LanguagesPageView::LanguagesPageView(Profile* profile)
- : languages_instructions_(NULL),
- languages_contents_(NULL),
- language_order_table_(NULL),
- add_button_(NULL),
- remove_button_(NULL),
- move_up_button_(NULL),
- move_down_button_(NULL),
- button_stack_(NULL),
- language_info_label_(NULL),
- ui_language_label_(NULL),
- change_ui_language_combobox_(NULL),
- change_dictionary_language_combobox_(NULL),
- enable_spellchecking_checkbox_(NULL),
- enable_autospellcorrect_checkbox_(NULL),
- dictionary_language_label_(NULL),
- OptionsPageView(profile),
- language_table_edited_(false),
- language_warning_shown_(false),
- enable_spellcheck_checkbox_clicked_(false),
- enable_autospellcorrect_checkbox_clicked_(false),
- spellcheck_language_index_selected_(-1),
- ui_language_index_selected_(-1),
- starting_ui_language_index_(-1) {
- accept_languages_.Init(prefs::kAcceptLanguages,
- profile->GetPrefs(), NULL);
- enable_spellcheck_.Init(prefs::kEnableSpellCheck,
- profile->GetPrefs(), NULL);
- enable_autospellcorrect_.Init(prefs::kEnableAutoSpellCorrect,
- profile->GetPrefs(), NULL);
-}
-
-LanguagesPageView::~LanguagesPageView() {
- if (language_order_table_)
- language_order_table_->SetModel(NULL);
-}
-
-void LanguagesPageView::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (sender == move_up_button_) {
- OnMoveUpLanguage();
- language_table_edited_ = true;
- } else if (sender == move_down_button_) {
- OnMoveDownLanguage();
- language_table_edited_ = true;
- } else if (sender == remove_button_) {
- OnRemoveLanguage();
- language_table_edited_ = true;
- } else if (sender == add_button_) {
- views::Window::CreateChromeWindow(
- GetWindow()->GetNativeWindow(),
- gfx::Rect(),
- new AddLanguageWindowView(this, profile()))->Show();
- language_table_edited_ = true;
- } else if (sender == enable_spellchecking_checkbox_) {
- enable_spellcheck_checkbox_clicked_ = true;
- } else if (sender == enable_autospellcorrect_checkbox_) {
- enable_autospellcorrect_checkbox_clicked_ = true;
- }
-}
-
-void LanguagesPageView::OnAddLanguage(const std::string& new_language) {
- if (language_order_table_model_->Add(new_language)) {
- language_order_table_->Select(language_order_table_model_->RowCount() - 1);
- OnSelectionChanged();
- }
-}
-
-void LanguagesPageView::InitControlLayout() {
- // Define the buttons.
- add_button_ = new views::NativeButton(this, l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_LANGUAGES_SELECTOR_ADD_BUTTON_LABEL));
- remove_button_ = new views::NativeButton(this, l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_LANGUAGES_SELECTOR_REMOVE_BUTTON_LABEL));
- remove_button_->SetEnabled(false);
- move_up_button_ = new views::NativeButton(this, l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_LANGUAGES_SELECTOR_MOVEUP_BUTTON_LABEL));
- move_up_button_->SetEnabled(false);
- move_down_button_ = new views::NativeButton(this, l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_LANGUAGES_SELECTOR_MOVEDOWN_BUTTON_LABEL));
- move_down_button_->SetEnabled(false);
-
- languages_contents_ = new views::View;
- using views::GridLayout;
- using views::ColumnSet;
-
- GridLayout* layout = CreatePanelGridLayout(this);
- SetLayoutManager(layout);
-
- const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
-
- // Add the instructions label.
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- languages_instructions_ = new views::Label(
- l10n_util::GetString(
- IDS_FONT_LANGUAGE_SETTING_LANGUAGES_INSTRUCTIONS));
- languages_instructions_->SetMultiLine(true);
- languages_instructions_->SetHorizontalAlignment(
- views::Label::ALIGN_LEFT);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(languages_instructions_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- // Add two columns - for table, and for button stack.
- std::vector<TableColumn> columns;
- columns.push_back(TableColumn());
- language_order_table_model_.reset(new LanguageOrderTableModel);
- language_order_table_ = new views::TableView(
- language_order_table_model_.get(), columns,
- views::TEXT_ONLY, false, true, true);
- language_order_table_->SetObserver(this);
-
- const int double_column_view_set_id = 1;
- column_set = layout->AddColumnSet(double_column_view_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, double_column_view_set_id);
-
- // Add the table to the the first column.
- layout->AddView(language_order_table_);
-
- // Now add the four buttons to the second column.
- button_stack_ = new views::View;
- GridLayout* button_stack_layout = new GridLayout(button_stack_);
- button_stack_->SetLayoutManager(button_stack_layout);
-
- column_set = button_stack_layout->AddColumnSet(single_column_view_set_id);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- button_stack_layout->StartRow(0, single_column_view_set_id);
- button_stack_layout->AddView(add_button_, 1, 1, GridLayout::FILL,
- GridLayout::CENTER);
- button_stack_layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- button_stack_layout->StartRow(0, single_column_view_set_id);
- button_stack_layout->AddView(remove_button_, 1, 1, GridLayout::FILL,
- GridLayout::CENTER);
- button_stack_layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- button_stack_layout->StartRow(0, single_column_view_set_id);
- button_stack_layout->AddView(move_up_button_, 1, 1, GridLayout::FILL,
- GridLayout::CENTER);
- button_stack_layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- button_stack_layout->StartRow(0, single_column_view_set_id);
- button_stack_layout->AddView(move_down_button_, 1, 1, GridLayout::FILL,
- GridLayout::CENTER);
-
- layout->AddView(button_stack_);
-
- layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
-
- language_info_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_CHROME_LANGUAGE_INFO));
- language_info_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- ui_language_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_CHROME_UI_LANGUAGE));
- ui_language_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- ui_language_model_.reset(new LanguageComboboxModel);
- change_ui_language_combobox_ =
- new views::Combobox(ui_language_model_.get());
- change_ui_language_combobox_->set_listener(this);
- dictionary_language_label_ = new views::Label(
- l10n_util::GetString(IDS_OPTIONS_CHROME_DICTIONARY_LANGUAGE));
- dictionary_language_label_->SetHorizontalAlignment(
- views::Label::ALIGN_LEFT);
- enable_spellchecking_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_ENABLE_SPELLCHECK));
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures)) {
- enable_autospellcorrect_checkbox_ = new views::Checkbox(
- l10n_util::GetString(IDS_OPTIONS_ENABLE_AUTO_SPELL_CORRECTION));
- enable_autospellcorrect_checkbox_->set_listener(this);
- }
- enable_spellchecking_checkbox_->set_listener(this);
- enable_spellchecking_checkbox_->SetMultiLine(true);
-
- // Determine Locale Codes.
- std::vector<std::string> spell_check_languages;
- SpellCheckCommon::SpellCheckLanguages(&spell_check_languages);
- dictionary_language_model_.reset(new LanguageComboboxModel(profile(),
- spell_check_languages));
- change_dictionary_language_combobox_ =
- new views::Combobox(dictionary_language_model_.get());
- change_dictionary_language_combobox_->set_listener(this);
-
- // SpellCheck language settings.
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(enable_spellchecking_checkbox_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- if (command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures)) {
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(enable_autospellcorrect_checkbox_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- }
- const int double_column_view_set_2_id = 2;
- column_set = layout->AddColumnSet(double_column_view_set_2_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
-
- layout->StartRow(0, double_column_view_set_2_id);
- layout->AddView(dictionary_language_label_);
- layout->AddView(change_dictionary_language_combobox_);
-
- // UI language settings.
- layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
- layout->StartRow(0, single_column_view_set_id);
- layout->AddView(language_info_label_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- layout->StartRow(0, double_column_view_set_2_id);
- layout->AddView(ui_language_label_);
- layout->AddView(change_ui_language_combobox_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- // Init member prefs so we can update the controls if prefs change.
- app_locale_.Init(prefs::kApplicationLocale,
- g_browser_process->local_state(), this);
- dictionary_language_.Init(prefs::kSpellCheckDictionary,
- profile()->GetPrefs(), this);
-}
-
-void LanguagesPageView::NotifyPrefChanged(const std::string* pref_name) {
- if (!pref_name || *pref_name == prefs::kAcceptLanguages) {
- language_order_table_model_->SetAcceptLanguagesString(
- accept_languages_.GetValue());
- }
- if (!pref_name || *pref_name == prefs::kApplicationLocale) {
- int index = ui_language_model_->GetSelectedLanguageIndex(
- prefs::kApplicationLocale);
- if (-1 == index) {
- // The pref value for locale isn't valid. Use the current app locale
- // (which is what we're currently using).
- index = ui_language_model_->GetIndexFromLocale(
- g_browser_process->GetApplicationLocale());
- }
- DCHECK(-1 != index);
- change_ui_language_combobox_->SetSelectedItem(index);
- starting_ui_language_index_ = index;
- }
- if (!pref_name || *pref_name == prefs::kSpellCheckDictionary) {
- int index = dictionary_language_model_->GetSelectedLanguageIndex(
- prefs::kSpellCheckDictionary);
-
- // If the index for the current language cannot be found, it is due to
- // the fact that the pref-member value for the last dictionary language
- // set by the user still uses the old format; i.e. language-region, even
- // when region is not necessary. For example, if the user sets the
- // dictionary language to be French, the pref-member value in the user
- // profile is "fr-FR", whereas we now use only "fr". To resolve this issue,
- // if "fr-FR" is read from the pref, the language code ("fr" here) is
- // extracted, and re-written in the pref, so that the pref-member value for
- // dictionary language in the user profile now correctly stores "fr"
- // instead of "fr-FR".
- if (index < 0) {
- const std::string& lang_region = dictionary_language_.GetValue();
- dictionary_language_.SetValue(
- SpellCheckCommon::GetLanguageFromLanguageRegion(lang_region));
- index = dictionary_language_model_->GetSelectedLanguageIndex(
- prefs::kSpellCheckDictionary);
- }
-
- change_dictionary_language_combobox_->SetSelectedItem(index);
- spellcheck_language_index_selected_ = -1;
- }
- if (!pref_name || *pref_name == prefs::kEnableSpellCheck) {
- enable_spellchecking_checkbox_->SetChecked(
- enable_spellcheck_.GetValue());
- }
- if (!pref_name || *pref_name == prefs::kEnableAutoSpellCorrect) {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures)) {
- enable_autospellcorrect_checkbox_->SetChecked(
- enable_autospellcorrect_.GetValue());
- }
- }
-}
-
-void LanguagesPageView::ItemChanged(views::Combobox* sender,
- int prev_index,
- int new_index) {
- if (prev_index == new_index)
- return;
-
- if (sender == change_ui_language_combobox_) {
- if (new_index == starting_ui_language_index_)
- ui_language_index_selected_ = -1;
- else
- ui_language_index_selected_ = new_index;
-
- if (!language_warning_shown_) {
- RestartMessageBox::ShowMessageBox(GetWindow()->GetNativeWindow());
- language_warning_shown_ = true;
- }
- } else if (sender == change_dictionary_language_combobox_) {
- // Set the spellcheck language selected.
- spellcheck_language_index_selected_ = new_index;
-
- // Remove the previously added spell check language to the accept list.
- if (!spellcheck_language_added_.empty()) {
- int old_index = language_order_table_model_->GetIndex(
- spellcheck_language_added_);
- if (old_index > -1)
- language_order_table_model_->Remove(old_index);
- }
-
- // Add this new spell check language only if it is not already in the
- // accept language list.
- std::string language =
- dictionary_language_model_->GetLocaleFromIndex(new_index);
- int index = language_order_table_model_->GetIndex(language);
- if (index == -1) {
- // Add the new language.
- OnAddLanguage(language);
- language_table_edited_ = true;
- spellcheck_language_added_ = language;
- } else {
- spellcheck_language_added_ = "";
- }
- }
-}
-
-void LanguagesPageView::OnSelectionChanged() {
- move_up_button_->SetEnabled(language_order_table_->FirstSelectedRow() > 0 &&
- language_order_table_->SelectedRowCount() == 1);
- move_down_button_->SetEnabled(language_order_table_->FirstSelectedRow() <
- language_order_table_->RowCount() - 1 &&
- language_order_table_->SelectedRowCount() ==
- 1);
- remove_button_->SetEnabled(language_order_table_->SelectedRowCount() > 0);
-}
-
-void LanguagesPageView::OnRemoveLanguage() {
- int item_selected = 0;
- for (views::TableView::iterator i =
- language_order_table_->SelectionBegin();
- i != language_order_table_->SelectionEnd(); ++i) {
- language_order_table_model_->Remove(*i);
- item_selected = *i;
- }
-
- move_up_button_->SetEnabled(false);
- move_down_button_->SetEnabled(false);
- remove_button_->SetEnabled(false);
- int items_left = language_order_table_model_->RowCount();
- if (items_left <= 0)
- return;
- if (item_selected > items_left - 1)
- item_selected = items_left - 1;
- language_order_table_->Select(item_selected);
- OnSelectionChanged();
-}
-
-void LanguagesPageView::OnMoveDownLanguage() {
- int item_selected = language_order_table_->FirstSelectedRow();
- language_order_table_model_->MoveDown(item_selected);
- language_order_table_->Select(item_selected + 1);
- OnSelectionChanged();
-}
-
-void LanguagesPageView::OnMoveUpLanguage() {
- int item_selected = language_order_table_->FirstSelectedRow();
- language_order_table_model_->MoveUp(item_selected);
- language_order_table_->Select(item_selected - 1);
-
- OnSelectionChanged();
-}
-
-void LanguagesPageView::SaveChanges() {
- if (language_order_table_model_.get() && language_table_edited_) {
- accept_languages_.SetValue(
- language_order_table_model_->GetLanguageList());
- }
-
- if (ui_language_index_selected_ != -1) {
- UserMetricsRecordAction(UserMetricsAction("Options_AppLanguage"),
- g_browser_process->local_state());
- app_locale_.SetValue(ui_language_model_->
- GetLocaleFromIndex(ui_language_index_selected_));
-
- // Remove pref values for spellcheck dictionaries forcefully.
- PrefService* prefs = profile()->GetPrefs();
- if (prefs)
- prefs->ClearPref(prefs::kSpellCheckDictionary);
- }
-
- if (spellcheck_language_index_selected_ != -1) {
- UserMetricsRecordAction(UserMetricsAction("Options_DictionaryLanguage"),
- profile()->GetPrefs());
- dictionary_language_.SetValue(dictionary_language_model_->
- GetLocaleFromIndex(spellcheck_language_index_selected_));
- }
-
- if (enable_spellcheck_checkbox_clicked_)
- enable_spellcheck_.SetValue(enable_spellchecking_checkbox_->checked());
-
- if (enable_autospellcorrect_checkbox_clicked_) {
- enable_autospellcorrect_.SetValue(
- enable_autospellcorrect_checkbox_->checked());
- }
-}
diff --git a/chrome/browser/views/options/languages_page_view.h b/chrome/browser/views/options/languages_page_view.h
index ace044e..722a893 100644
--- a/chrome/browser/views/options/languages_page_view.h
+++ b/chrome/browser/views/options/languages_page_view.h
@@ -2,118 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGES_PAGE_VIEW_H__
-#define CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGES_PAGE_VIEW_H__
+#ifndef CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGES_PAGE_VIEW_H_
+#define CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGES_PAGE_VIEW_H_
#pragma once
-#include "chrome/browser/prefs/pref_member.h"
-#include "chrome/browser/views/options/options_page_view.h"
-#include "views/controls/combobox/combobox.h"
-#include "views/controls/button/button.h"
-#include "views/controls/table/table_view_observer.h"
-#include "views/view.h"
+#include "chrome/browser/ui/views/options/languages_page_view.h"
+// TODO(beng): remove this file once all includes have been updated.
-namespace views {
-class Checkbox;
-class Label;
-class NativeButton;
-class TableView;
-}
+#endif // CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGES_PAGE_VIEW_H_
-class AddLanguageView;
-class LanguageComboboxModel;
-class LanguageOrderTableModel;
-class TableModel;
-
-///////////////////////////////////////////////////////////////////////////////
-// LanguagesPageView
-
-class LanguagesPageView : public OptionsPageView,
- public views::ButtonListener,
- public views::TableViewObserver,
- public views::Combobox::Listener {
- public:
- explicit LanguagesPageView(Profile* profile);
- virtual ~LanguagesPageView();
-
- // views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // Save Changes made to relevant pref members associated with this tab.
- // This is public since it is called by FontsLanguageWindowView in its
- // Dialog Delegate Accept() method.
- void SaveChanges();
-
- // This is public because when user clicks OK in AddLanguageView dialog,
- // this is called back in the LanguagePageView delegate in order to add
- // this language to the table model in this tab.
- void OnAddLanguage(const std::string& new_language);
-
- protected:
- // OptionsPageView implementation:
- virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::string* pref_name);
-
- // views::Combobox::Listener implementation:
- virtual void ItemChanged(views::Combobox* sender,
- int prev_index,
- int new_index);
-
- private:
- // Invoked when the selection of the table view changes. Updates the enabled
- // property of the remove button.
- virtual void OnSelectionChanged();
- void OnRemoveLanguage();
- void OnMoveDownLanguage();
- void OnMoveUpLanguage();
-
- views::Label* languages_instructions_;
- views::View* languages_contents_;
- views::View* button_stack_;
- views::TableView* language_order_table_;
- views::NativeButton* move_up_button_;
- views::NativeButton* move_down_button_;
- views::NativeButton* add_button_;
- views::NativeButton* remove_button_;
- views::Label* language_info_label_;
- views::Label* ui_language_label_;
- views::Combobox* change_ui_language_combobox_;
- views::Combobox* change_dictionary_language_combobox_;
- views::Checkbox* enable_autospellcorrect_checkbox_;
- views::Checkbox* enable_spellchecking_checkbox_;
- views::Label* dictionary_language_label_;
-
- scoped_ptr<LanguageOrderTableModel> language_order_table_model_;
- AddLanguageView* add_language_instance_;
- StringPrefMember accept_languages_;
-
- // The contents of the "user interface language" combobox.
- scoped_ptr<LanguageComboboxModel> ui_language_model_;
- StringPrefMember app_locale_;
- int ui_language_index_selected_;
- int starting_ui_language_index_;
-
- // The contents of the "dictionary language" combobox.
- scoped_ptr<LanguageComboboxModel> dictionary_language_model_;
- StringPrefMember dictionary_language_;
-
- // SpellChecker enable pref.
- BooleanPrefMember enable_spellcheck_;
-
- // Auto spell correction pref.
- BooleanPrefMember enable_autospellcorrect_;
-
- // This is assigned the new index of spellcheck language if the language
- // is changed. Otherwise, it remains -1, and pref members are not updated.
- int spellcheck_language_index_selected_;
- std::string spellcheck_language_added_;
-
- bool language_table_edited_;
- bool language_warning_shown_;
- bool enable_spellcheck_checkbox_clicked_;
- bool enable_autospellcorrect_checkbox_clicked_;
-
- DISALLOW_COPY_AND_ASSIGN(LanguagesPageView);
-};
-
-#endif // CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGES_PAGE_VIEW_H__
diff --git a/chrome/browser/views/options/managed_prefs_banner_view.cc b/chrome/browser/views/options/managed_prefs_banner_view.cc
deleted file mode 100644
index e063d14..0000000
--- a/chrome/browser/views/options/managed_prefs_banner_view.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// 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/options/managed_prefs_banner_view.h"
-
-#include "app/resource_bundle.h"
-#include "gfx/color_utils.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "views/box_layout.h"
-#include "views/controls/image_view.h"
-#include "views/controls/label.h"
-#include "views/standard_layout.h"
-
-// Spacing between the banner frame and its contents.
-static const int kPrefsBannerPadding = 3;
-// Width of the banner frame.
-static const int kPrefsBannerBorderSize = 1;
-
-ManagedPrefsBannerView::ManagedPrefsBannerView(PrefService* prefs,
- OptionsPage page)
- : policy::ManagedPrefsBannerBase(prefs, page) {
- content_ = new views::View;
- SkColor border_color = color_utils::GetSysSkColor(COLOR_3DSHADOW);
- views::Border* border = views::Border::CreateSolidBorder(
- kPrefsBannerBorderSize, border_color);
- content_->set_border(border);
-
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- warning_image_ = new views::ImageView();
- warning_image_->SetImage(rb.GetBitmapNamed(IDR_WARNING));
- label_ = new views::Label(rb.GetLocalizedString(IDS_OPTIONS_MANAGED_PREFS));
-}
-
-void ManagedPrefsBannerView::Init() {
- AddChildView(content_);
- content_->SetLayoutManager(
- new views::BoxLayout(views::BoxLayout::kHorizontal,
- kPrefsBannerPadding,
- kPrefsBannerPadding,
- kRelatedControlSmallHorizontalSpacing));
- content_->AddChildView(warning_image_);
- content_->AddChildView(label_);
- OnUpdateVisibility();
-}
-
-gfx::Size ManagedPrefsBannerView::GetPreferredSize() {
- if (!IsVisible())
- return gfx::Size();
-
- // Add space below the banner.
- gfx::Size size(content_->GetPreferredSize());
- size.Enlarge(0, kRelatedControlVerticalSpacing);
- return size;
-}
-
-void ManagedPrefsBannerView::Layout() {
- content_->SetBounds(0, 0, width(), height() - kRelatedControlVerticalSpacing);
-}
-
-void ManagedPrefsBannerView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- if (is_add && child == this)
- Init();
-}
-
-void ManagedPrefsBannerView::OnUpdateVisibility() {
- SetVisible(DetermineVisibility());
-}
diff --git a/chrome/browser/views/options/managed_prefs_banner_view.h b/chrome/browser/views/options/managed_prefs_banner_view.h
index f34ab30..d1efb86 100644
--- a/chrome/browser/views/options/managed_prefs_banner_view.h
+++ b/chrome/browser/views/options/managed_prefs_banner_view.h
@@ -6,47 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_MANAGED_PREFS_BANNER_VIEW_H_
#pragma once
-#include "chrome/browser/policy/managed_prefs_banner_base.h"
-#include "views/view.h"
-
-namespace views {
-class ImageView;
-class Label;
-}
-
-// Displays a banner showing a warning message that tells the user some options
-// cannot be changed because the relevant preferences are managed by their
-// system administrator.
-class ManagedPrefsBannerView : public policy::ManagedPrefsBannerBase,
- public views::View {
- public:
- // Initialize the banner. |page| is used to determine the names of the
- // preferences that control the banner visibility through their managed flag.
- ManagedPrefsBannerView(PrefService* pref_service, OptionsPage page);
- virtual ~ManagedPrefsBannerView() {}
-
- private:
- // Initialize contents and layout.
- void Init();
-
- // views::View overrides.
- virtual gfx::Size GetPreferredSize();
- virtual void Layout();
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
-
- // ManagedPrefsBannerBase override.
- virtual void OnUpdateVisibility();
-
- // Holds the warning icon image and text label and renders the border.
- views::View* content_;
- // Warning icon image.
- views::ImageView* warning_image_;
- // The label responsible for rendering the warning text.
- views::Label* label_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(ManagedPrefsBannerView);
-};
+#include "chrome/browser/ui/views/options/managed_prefs_banner_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_MANAGED_PREFS_BANNER_VIEW_H_
+
diff --git a/chrome/browser/views/options/options_group_view.cc b/chrome/browser/views/options/options_group_view.cc
deleted file mode 100644
index ef3e5dd..0000000
--- a/chrome/browser/views/options/options_group_view.cc
+++ /dev/null
@@ -1,141 +0,0 @@
-// 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 <vsstyle.h>
-#include <vssym32.h>
-
-#include "chrome/browser/views/options/options_group_view.h"
-
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "gfx/canvas.h"
-#include "gfx/font.h"
-#include "gfx/native_theme_win.h"
-#include "grit/locale_settings.h"
-#include "grit/generated_resources.h"
-#include "views/grid_layout.h"
-#include "views/controls/label.h"
-#include "views/controls/separator.h"
-#include "views/standard_layout.h"
-
-static const int kLeftColumnWidthChars = 20;
-static const int kOptionsGroupViewColumnSpacing = 30;
-
-///////////////////////////////////////////////////////////////////////////////
-// OptionsGroupView, public:
-
-OptionsGroupView::OptionsGroupView(views::View* contents,
- const std::wstring& title,
- const std::wstring& description,
- bool show_separator)
- : contents_(contents),
- title_label_(new views::Label(title)),
- description_label_(new views::Label(description)),
- separator_(NULL),
- show_separator_(show_separator),
- highlighted_(false) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- const gfx::Font& title_font =
- rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD);
- title_label_->SetFont(title_font);
- SkColor title_color = gfx::NativeTheme::instance()->GetThemeColorWithDefault(
- gfx::NativeTheme::BUTTON, BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR,
- COLOR_WINDOWTEXT);
- title_label_->SetColor(title_color);
- title_label_->SetMultiLine(true);
- title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
-
- description_label_->SetMultiLine(true);
- description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
-
- SetAccessibleName(title);
- contents->SetAccessibleName(title);
-}
-
-OptionsGroupView::~OptionsGroupView() {
-}
-
-void OptionsGroupView::SetHighlighted(bool highlighted) {
- highlighted_ = highlighted;
- SchedulePaint();
-}
-
-int OptionsGroupView::GetContentsWidth() const {
- return contents_->width();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// OptionsGroupView, views::View overrides:
-
-AccessibilityTypes::Role OptionsGroupView::GetAccessibleRole() {
- return AccessibilityTypes::ROLE_GROUPING;
-}
-
-void OptionsGroupView::Paint(gfx::Canvas* canvas) {
- if (highlighted_) {
- COLORREF infocolor = GetSysColor(COLOR_INFOBK);
- SkColor background_color = SkColorSetRGB(GetRValue(infocolor),
- GetGValue(infocolor),
- GetBValue(infocolor));
- int y_offset = kUnrelatedControlVerticalSpacing / 2;
- canvas->FillRectInt(background_color, 0, 0, width(),
- height() - y_offset);
- }
-}
-
-void OptionsGroupView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- if (is_add && child == this)
- Init();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// OptionsGroupView, private:
-
-void OptionsGroupView::Init() {
- using views::GridLayout;
- using views::ColumnSet;
-
- GridLayout* layout = new GridLayout(this);
- SetLayoutManager(layout);
-
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- const gfx::Font& font = rb.GetFont(ResourceBundle::BaseFont);
- std::wstring left_column_chars =
- l10n_util::GetString(IDS_OPTIONS_DIALOG_LEFT_COLUMN_WIDTH_CHARS);
- int left_column_width =
- font.GetExpectedTextWidth(_wtoi(left_column_chars.c_str()));
-
- const int two_column_layout_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(two_column_layout_id);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::FIXED, left_column_width, 0);
- column_set->AddPaddingColumn(0, kOptionsGroupViewColumnSpacing);
- column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 1,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
-
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, two_column_layout_id);
- layout->AddView(title_label_, 1, 1, GridLayout::FILL, GridLayout::LEADING);
- layout->AddView(contents_, 1, 3, GridLayout::FILL, GridLayout::FILL);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(1, two_column_layout_id);
- layout->AddView(description_label_, 1, 1,
- GridLayout::FILL, GridLayout::LEADING);
- layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
-
- if (show_separator_) {
- const int single_column_layout_id = 1;
- column_set = layout->AddColumnSet(single_column_layout_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
-
- separator_ = new views::Separator;
- layout->StartRow(0, single_column_layout_id);
- layout->AddView(separator_);
- }
-}
diff --git a/chrome/browser/views/options/options_group_view.h b/chrome/browser/views/options/options_group_view.h
index b79a36e..b3bf71b 100644
--- a/chrome/browser/views/options/options_group_view.h
+++ b/chrome/browser/views/options/options_group_view.h
@@ -2,62 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_GROUP_VIEW_H__
-#define CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_GROUP_VIEW_H__
+#ifndef CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_GROUP_VIEW_H_
+#define CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_GROUP_VIEW_H_
#pragma once
-#include "views/view.h"
+#include "chrome/browser/ui/views/options/options_group_view.h"
+// TODO(beng): remove this file once all includes have been updated.
-namespace views {
-class Label;
-class Separator;
-};
+#endif // CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_GROUP_VIEW_H_
-///////////////////////////////////////////////////////////////////////////////
-// OptionsGroupView
-//
-// A helper View that gathers related options into groups with a title and
-// optional description.
-//
-class OptionsGroupView : public views::View {
- public:
- OptionsGroupView(views::View* contents,
- const std::wstring& title,
- const std::wstring& description,
- bool show_separator);
- virtual ~OptionsGroupView();
-
- // Sets the group as being highlighted to attract attention.
- void SetHighlighted(bool highlighted);
-
- // Retrieves the width of the ContentsView. Used to help size wrapping items.
- int GetContentsWidth() const;
-
- protected:
- // views::View overrides:
- virtual AccessibilityTypes::Role GetAccessibleRole();
- virtual void Paint(gfx::Canvas* canvas);
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
-
- private:
- void Init();
-
- views::View* contents_;
- views::Label* title_label_;
- views::Label* description_label_;
- views::Separator* separator_;
-
- // True if we should show a separator line below the contents of this
- // section.
- bool show_separator_;
-
- // True if this section should have a highlighted treatment to draw the
- // user's attention.
- bool highlighted_;
-
- DISALLOW_COPY_AND_ASSIGN(OptionsGroupView);
-};
-
-#endif // CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_GROUP_VIEW_H__
diff --git a/chrome/browser/views/options/options_page_view.cc b/chrome/browser/views/options/options_page_view.cc
deleted file mode 100644
index 6073442..0000000
--- a/chrome/browser/views/options/options_page_view.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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/options/options_page_view.h"
-
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/metrics/user_metrics.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/common/notification_service.h"
-#include "views/widget/widget.h"
-
-///////////////////////////////////////////////////////////////////////////////
-// OptionsPageView
-
-OptionsPageView::OptionsPageView(Profile* profile)
- : OptionsPageBase(profile),
- initialized_(false) {
-}
-
-OptionsPageView::~OptionsPageView() {
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// OptionsPageView, views::View overrides:
-
-void OptionsPageView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- if (!initialized_ && is_add && GetWidget()) {
- // It is important that this only get done _once_ otherwise we end up
- // duplicating the view hierarchy when tabs are switched.
- initialized_ = true;
- InitControlLayout();
- NotifyPrefChanged(NULL);
- }
-}
-
-AccessibilityTypes::Role OptionsPageView::GetAccessibleRole() {
- return AccessibilityTypes::ROLE_PAGETAB;
-}
-
diff --git a/chrome/browser/views/options/options_page_view.h b/chrome/browser/views/options/options_page_view.h
index 698cb99..2920edb 100644
--- a/chrome/browser/views/options/options_page_view.h
+++ b/chrome/browser/views/options/options_page_view.h
@@ -2,51 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_PAGE_VIEW_H__
-#define CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_PAGE_VIEW_H__
+#ifndef CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_PAGE_VIEW_H_
+#define CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_PAGE_VIEW_H_
#pragma once
-#include "chrome/browser/options_page_base.h"
-#include "views/controls/link.h"
-#include "views/controls/button/native_button.h"
+#include "chrome/browser/ui/views/options/options_page_view.h"
+// TODO(beng): remove this file once all includes have been updated.
-class PrefService;
+#endif // CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_PAGE_VIEW_H_
-///////////////////////////////////////////////////////////////////////////////
-// OptionsPageView
-//
-// A base class for Options dialog pages that handles ensuring control
-// initialization is done just once.
-//
-class OptionsPageView : public views::View,
- public OptionsPageBase {
- public:
- virtual ~OptionsPageView();
-
- // Returns true if the window containing this view can be closed, given the
- // current state of this view. This can be used to prevent the window from
- // being closed when a modal dialog box is showing, for example.
- virtual bool CanClose() const { return true; }
-
- protected:
- // This class cannot be instantiated directly, but its constructor must be
- // called by derived classes.
- explicit OptionsPageView(Profile* profile);
-
- // Initializes the layout of the controls within the panel.
- virtual void InitControlLayout() = 0;
-
- // views::View overrides:
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
- virtual AccessibilityTypes::Role GetAccessibleRole();
-
- private:
- // Whether or not the control layout has been initialized for this page.
- bool initialized_;
-
- DISALLOW_COPY_AND_ASSIGN(OptionsPageView);
-};
-
-#endif // CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_PAGE_VIEW_H__
diff --git a/chrome/browser/views/options/options_window_view.cc b/chrome/browser/views/options/options_window_view.cc
deleted file mode 100644
index 8201bd8..0000000
--- a/chrome/browser/views/options/options_window_view.cc
+++ /dev/null
@@ -1,244 +0,0 @@
-// 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/options_window.h"
-
-#include "app/l10n_util.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/browser_window.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/views/options/advanced_page_view.h"
-#include "chrome/browser/views/options/content_page_view.h"
-#include "chrome/browser/views/options/general_page_view.h"
-#include "chrome/browser/window_sizer.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/pref_names.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "views/controls/tabbed_pane/tabbed_pane.h"
-#include "views/widget/root_view.h"
-#include "views/window/dialog_delegate.h"
-#include "views/window/window.h"
-
-///////////////////////////////////////////////////////////////////////////////
-// OptionsWindowView
-//
-// The contents of the Options dialog window.
-//
-class OptionsWindowView : public views::View,
- public views::DialogDelegate,
- public views::TabbedPane::Listener {
- public:
- explicit OptionsWindowView(Profile* profile);
- virtual ~OptionsWindowView();
-
- // Shows the Tab corresponding to the specified OptionsPage.
- void ShowOptionsPage(OptionsPage page, OptionsGroup highlight_group);
-
- // views::DialogDelegate implementation:
- virtual int GetDialogButtons() const {
- return MessageBoxFlags::DIALOGBUTTON_CANCEL;
- }
- virtual std::wstring GetWindowTitle() const;
- virtual std::wstring GetWindowName() const;
- virtual void WindowClosing();
- virtual bool Cancel();
- virtual views::View* GetContentsView();
- virtual bool ShouldRestoreWindowSize() const;
-
- // views::TabbedPane::Listener implementation:
- virtual void TabSelectedAt(int index);
-
- // views::View overrides:
- virtual AccessibilityTypes::Role GetAccessibleRole();
- virtual void Layout();
- virtual gfx::Size GetPreferredSize();
-
- protected:
- // views::View overrides:
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
- private:
- // Init the assorted Tabbed pages
- void Init();
-
- // Returns the currently selected OptionsPageView.
- OptionsPageView* GetCurrentOptionsPageView() const;
-
- // The Tab view that contains all of the options pages.
- views::TabbedPane* tabs_;
-
- // The Profile associated with these options.
- Profile* profile_;
-
- // The last page the user was on when they opened the Options window.
- IntegerPrefMember last_selected_page_;
-
- DISALLOW_COPY_AND_ASSIGN(OptionsWindowView);
-};
-
-// static
-static OptionsWindowView* instance_ = NULL;
-static const int kDialogPadding = 7;
-
-///////////////////////////////////////////////////////////////////////////////
-// OptionsWindowView, public:
-
-OptionsWindowView::OptionsWindowView(Profile* profile)
- // Always show preferences for the original profile. Most state when off
- // the record comes from the original profile, but we explicitly use
- // the original profile to avoid potential problems.
- : profile_(profile->GetOriginalProfile()) {
- // We don't need to observe changes in this value.
- last_selected_page_.Init(prefs::kOptionsWindowLastTabIndex,
- g_browser_process->local_state(), NULL);
-}
-
-OptionsWindowView::~OptionsWindowView() {
-}
-
-void OptionsWindowView::ShowOptionsPage(OptionsPage page,
- OptionsGroup highlight_group) {
- // Positioning is handled by window_delegate. we just need to show the window.
- // This will show invisible windows and bring visible windows to the front.
- window()->Show();
-
- if (page == OPTIONS_PAGE_DEFAULT) {
- // Remember the last visited page from local state.
- page = static_cast<OptionsPage>(last_selected_page_.GetValue());
- if (page == OPTIONS_PAGE_DEFAULT)
- page = OPTIONS_PAGE_GENERAL;
- }
- // If the page number is out of bounds, reset to the first tab.
- if (page < 0 || page >= tabs_->GetTabCount())
- page = OPTIONS_PAGE_GENERAL;
-
- tabs_->SelectTabAt(static_cast<int>(page));
-
- GetCurrentOptionsPageView()->HighlightGroup(highlight_group);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// OptionsWindowView, views::DialogDelegate implementation:
-
-std::wstring OptionsWindowView::GetWindowTitle() const {
- return l10n_util::GetStringF(IDS_OPTIONS_DIALOG_TITLE,
- l10n_util::GetString(IDS_PRODUCT_NAME));
-}
-
-std::wstring OptionsWindowView::GetWindowName() const {
- return UTF8ToWide(prefs::kPreferencesWindowPlacement);
-}
-
-void OptionsWindowView::WindowClosing() {
- // Clear the static instance so that the next time ShowOptionsWindow() is
- // called a new window is opened.
- instance_ = NULL;
-}
-
-bool OptionsWindowView::Cancel() {
- return GetCurrentOptionsPageView()->CanClose();
-}
-
-views::View* OptionsWindowView::GetContentsView() {
- return this;
-}
-
-bool OptionsWindowView::ShouldRestoreWindowSize() const {
- // By returning false the options window is always sized to its preferred
- // size.
- return false;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// OptionsWindowView, views::TabbedPane::Listener implementation:
-
-void OptionsWindowView::TabSelectedAt(int index) {
- DCHECK(index > OPTIONS_PAGE_DEFAULT && index < OPTIONS_PAGE_COUNT);
- last_selected_page_.SetValue(index);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// OptionsWindowView, views::View overrides:
-
-AccessibilityTypes::Role OptionsWindowView::GetAccessibleRole() {
- return AccessibilityTypes::ROLE_CLIENT;
-}
-
-void OptionsWindowView::Layout() {
- tabs_->SetBounds(kDialogPadding, kDialogPadding,
- width() - (2 * kDialogPadding),
- height() - (2 * kDialogPadding));
-}
-
-gfx::Size OptionsWindowView::GetPreferredSize() {
- gfx::Size size(tabs_->GetPreferredSize());
- size.Enlarge(2 * kDialogPadding, 2 * kDialogPadding);
- return size;
-}
-
-void OptionsWindowView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- // Can't init before we're inserted into a Container, because we require a
- // HWND to parent native child controls to.
- if (is_add && child == this)
- Init();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// OptionsWindowView, private:
-
-void OptionsWindowView::Init() {
- tabs_ = new views::TabbedPane;
- tabs_->SetAccessibleName(l10n_util::GetStringF(IDS_OPTIONS_DIALOG_TITLE,
- l10n_util::GetString(IDS_PRODUCT_NAME)));
- tabs_->SetListener(this);
- AddChildView(tabs_);
-
- int tab_index = 0;
- GeneralPageView* general_page = new GeneralPageView(profile_);
- tabs_->AddTabAtIndex(tab_index++,
- l10n_util::GetString(IDS_OPTIONS_GENERAL_TAB_LABEL),
- general_page, false);
-
- ContentPageView* content_page = new ContentPageView(profile_);
- tabs_->AddTabAtIndex(tab_index++,
- l10n_util::GetString(IDS_OPTIONS_CONTENT_TAB_LABEL),
- content_page, false);
-
- AdvancedPageView* advanced_page = new AdvancedPageView(profile_);
- tabs_->AddTabAtIndex(tab_index++,
- l10n_util::GetString(IDS_OPTIONS_ADVANCED_TAB_LABEL),
- advanced_page, false);
-
- DCHECK(tabs_->GetTabCount() == OPTIONS_PAGE_COUNT);
-}
-
-OptionsPageView* OptionsWindowView::GetCurrentOptionsPageView() const {
- return static_cast<OptionsPageView*>(tabs_->GetSelectedTab());
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Factory/finder method:
-
-void ShowOptionsWindow(OptionsPage page,
- OptionsGroup highlight_group,
- Profile* profile) {
- DCHECK(profile);
- // If there's already an existing options window, activate it and switch to
- // the specified page.
- // TODO(beng): note this is not multi-simultaneous-profile-safe. When we care
- // about this case this will have to be fixed.
- if (!instance_) {
- instance_ = new OptionsWindowView(profile);
- views::Window::CreateChromeWindow(NULL, gfx::Rect(), instance_);
- }
- instance_->ShowOptionsPage(page, highlight_group);
-}
diff --git a/chrome/browser/views/options/passwords_exceptions_window_view.cc b/chrome/browser/views/options/passwords_exceptions_window_view.cc
deleted file mode 100644
index 5c786ac..0000000
--- a/chrome/browser/views/options/passwords_exceptions_window_view.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (c) 2009 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/options/passwords_exceptions_window_view.h"
-
-#include "app/l10n_util.h"
-#include "chrome/browser/views/options/passwords_page_view.h"
-#include "chrome/browser/views/options/exceptions_page_view.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "views/controls/tabbed_pane/tabbed_pane.h"
-#include "views/window/window.h"
-
-// static
-PasswordsExceptionsWindowView* PasswordsExceptionsWindowView::instance_ = NULL;
-
-static const int kDialogPadding = 7;
-
-namespace browser {
-
-// Declared in browser_dialogs.h so others don't have to depend on our header.
-void ShowPasswordsExceptionsWindowView(Profile* profile) {
- PasswordsExceptionsWindowView::Show(profile);
-}
-
-} // namespace browser
-
-///////////////////////////////////////////////////////////////////////////////
-// PasswordsExceptionsWindowView, public
-
-PasswordsExceptionsWindowView::PasswordsExceptionsWindowView(Profile* profile)
- : tabs_(NULL),
- passwords_page_view_(NULL),
- exceptions_page_view_(NULL),
- profile_(profile) {
-}
-
-// static
-void PasswordsExceptionsWindowView::Show(Profile* profile) {
- DCHECK(profile);
- if (!instance_) {
- instance_ = new PasswordsExceptionsWindowView(profile);
-
- // |instance_| will get deleted once Close() is called.
- views::Window::CreateChromeWindow(NULL, gfx::Rect(), instance_);
- }
- if (!instance_->window()->IsVisible()) {
- instance_->window()->Show();
- } else {
- instance_->window()->Activate();
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// PasswordsExceptionsWindowView, views::View implementations
-
-void PasswordsExceptionsWindowView::Layout() {
- tabs_->SetBounds(kDialogPadding, kDialogPadding,
- width() - (2 * kDialogPadding),
- height() - (2 * kDialogPadding));
-}
-
-gfx::Size PasswordsExceptionsWindowView::GetPreferredSize() {
- return gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_PASSWORDS_DIALOG_WIDTH_CHARS,
- IDS_PASSWORDS_DIALOG_HEIGHT_LINES));
-}
-
-void PasswordsExceptionsWindowView::ViewHierarchyChanged(
- bool is_add, views::View* parent, views::View* child) {
- if (is_add && child == this)
- Init();
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// PasswordsExceptionsWindowView, views::DisloagDelegate implementations
-
-int PasswordsExceptionsWindowView::GetDialogButtons() const {
- return MessageBoxFlags::DIALOGBUTTON_CANCEL;
-}
-
-std::wstring PasswordsExceptionsWindowView::GetWindowTitle() const {
- return l10n_util::GetString(IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE);
-}
-
-void PasswordsExceptionsWindowView::WindowClosing() {
- // |instance_| is deleted once the window is closed, so we just have to set
- // it to NULL.
- instance_ = NULL;
-}
-
-views::View* PasswordsExceptionsWindowView::GetContentsView() {
- return this;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// PasswordsExceptionsWindowView, private
-
-void PasswordsExceptionsWindowView::Init() {
- tabs_ = new views::TabbedPane();
- AddChildView(tabs_);
-
- passwords_page_view_ = new PasswordsPageView(profile_);
- tabs_->AddTab(l10n_util::GetString(
- IDS_PASSWORDS_SHOW_PASSWORDS_TAB_TITLE), passwords_page_view_);
-
- exceptions_page_view_ = new ExceptionsPageView(profile_);
- tabs_->AddTab(l10n_util::GetString(
- IDS_PASSWORDS_EXCEPTIONS_TAB_TITLE), exceptions_page_view_);
-}
diff --git a/chrome/browser/views/options/passwords_exceptions_window_view.h b/chrome/browser/views/options/passwords_exceptions_window_view.h
index df98697..7adbd5f 100644
--- a/chrome/browser/views/options/passwords_exceptions_window_view.h
+++ b/chrome/browser/views/options/passwords_exceptions_window_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
@@ -6,62 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_PASSWORDS_EXCEPTIONS_WINDOW_VIEW_H_
#pragma once
-#include "views/view.h"
-#include "views/window/dialog_delegate.h"
-
-class Profile;
-class PasswordsPageView;
-class ExceptionsPageView;
-
-namespace views {
-class TabbedPane;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// PasswordsExceptionsWindowView
-//
-// The contents of the "Save passwords and exceptions" dialog window.
-//
-class PasswordsExceptionsWindowView : public views::View,
- public views::DialogDelegate {
- public:
- explicit PasswordsExceptionsWindowView(Profile* profile);
- virtual ~PasswordsExceptionsWindowView() {}
-
- // Show the PasswordManagerExceptionsView for the given profile.
- static void Show(Profile* profile);
-
- // views::View methods.
- virtual void Layout();
- virtual gfx::Size GetPreferredSize();
- virtual void ViewHierarchyChanged(bool is_add, views::View* parent,
- views::View* child);
-
- // views::DialogDelegate methods:
- virtual int GetDialogButtons() const;
- virtual bool CanResize() const { return true; }
- virtual bool CanMaximize() const { return false; }
- virtual bool IsAlwaysOnTop() const { return false; }
- virtual bool HasAlwaysOnTopMenu() const { return false; }
- virtual std::wstring GetWindowTitle() const;
- virtual void WindowClosing();
- virtual views::View* GetContentsView();
-
- private:
- void Init();
-
- // The Tab view that contains all of the options pages.
- views::TabbedPane* tabs_;
-
- PasswordsPageView* passwords_page_view_;
-
- ExceptionsPageView* exceptions_page_view_;
-
- Profile* profile_;
-
- static PasswordsExceptionsWindowView* instance_;
-
- DISALLOW_COPY_AND_ASSIGN(PasswordsExceptionsWindowView);
-};
+#include "chrome/browser/ui/views/options/passwords_exceptions_window_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_PASSWORDS_EXCEPTIONS_WINDOW_VIEW_H_
+
diff --git a/chrome/browser/views/options/passwords_page_view.cc b/chrome/browser/views/options/passwords_page_view.cc
deleted file mode 100644
index 6d22d5e..0000000
--- a/chrome/browser/views/options/passwords_page_view.cc
+++ /dev/null
@@ -1,367 +0,0 @@
-// 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/options/passwords_page_view.h"
-
-#include "app/l10n_util.h"
-#include "base/i18n/rtl.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/password_manager/password_store.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profile.h"
-#include "chrome/common/pref_names.h"
-#include "grit/generated_resources.h"
-#include "views/background.h"
-#include "views/controls/button/native_button.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-
-using views::ColumnSet;
-using views::GridLayout;
-using webkit_glue::PasswordForm;
-
-///////////////////////////////////////////////////////////////////////////////
-// MultiLabelButtons
-MultiLabelButtons::MultiLabelButtons(views::ButtonListener* listener,
- const std::wstring& label,
- const std::wstring& alt_label)
- : NativeButton(listener, label),
- label_(label),
- alt_label_(alt_label) {
-}
-
-gfx::Size MultiLabelButtons::GetPreferredSize() {
- if (!IsVisible())
- return gfx::Size();
-
- if (pref_size_.IsEmpty()) {
- // Let's compute our preferred size.
- std::wstring current_label = label();
- SetLabel(label_);
- pref_size_ = NativeButton::GetPreferredSize();
- SetLabel(alt_label_);
- gfx::Size alt_pref_size = NativeButton::GetPreferredSize();
- // Revert to the original label.
- SetLabel(current_label);
- pref_size_.SetSize(std::max(pref_size_.width(), alt_pref_size.width()),
- std::max(pref_size_.height(), alt_pref_size.height()));
- }
- return gfx::Size(pref_size_.width(), pref_size_.height());
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// PasswordsTableModel, public
-PasswordsTableModel::PasswordsTableModel(Profile* profile)
- : observer_(NULL),
- row_count_observer_(NULL),
- pending_login_query_(NULL),
- saved_signons_cleanup_(&saved_signons_),
- profile_(profile) {
- DCHECK(profile && profile->GetPasswordStore(Profile::EXPLICIT_ACCESS));
-}
-
-PasswordsTableModel::~PasswordsTableModel() {
- CancelLoginsQuery();
-}
-
-int PasswordsTableModel::RowCount() {
- return static_cast<int>(saved_signons_.size());
-}
-
-std::wstring PasswordsTableModel::GetText(int row,
- int col_id) {
- switch (col_id) {
- case IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN: { // Site.
- // Force URL to have LTR directionality.
- std::wstring url(saved_signons_[row]->display_url.display_url());
- url = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality(
- WideToUTF16(url)));
- return url;
- }
- case IDS_PASSWORDS_PAGE_VIEW_USERNAME_COLUMN: { // Username.
- std::wstring username = GetPasswordFormAt(row)->username_value;
- base::i18n::AdjustStringForLocaleDirection(username, &username);
- return username;
- }
- default:
- NOTREACHED() << "Invalid column.";
- return std::wstring();
- }
-}
-
-int PasswordsTableModel::CompareValues(int row1, int row2,
- int column_id) {
- if (column_id == IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN) {
- return saved_signons_[row1]->display_url.Compare(
- saved_signons_[row2]->display_url, GetCollator());
- }
- return TableModel::CompareValues(row1, row2, column_id);
-}
-
-void PasswordsTableModel::SetObserver(TableModelObserver* observer) {
- observer_ = observer;
-}
-
-void PasswordsTableModel::GetAllSavedLoginsForProfile() {
- DCHECK(!pending_login_query_);
- pending_login_query_ = password_store()->GetAutofillableLogins(this);
-}
-
-void PasswordsTableModel::OnPasswordStoreRequestDone(
- int handle, const std::vector<PasswordForm*>& result) {
- DCHECK_EQ(pending_login_query_, handle);
- pending_login_query_ = NULL;
-
- STLDeleteElements<PasswordRows>(&saved_signons_);
- saved_signons_.resize(result.size(), NULL);
- std::wstring languages =
- UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
- for (size_t i = 0; i < result.size(); ++i) {
- saved_signons_[i] = new PasswordRow(
- gfx::SortedDisplayURL(result[i]->origin, languages), result[i]);
- }
- if (observer_)
- observer_->OnModelChanged();
- if (row_count_observer_)
- row_count_observer_->OnRowCountChanged(RowCount());
-}
-
-PasswordForm* PasswordsTableModel::GetPasswordFormAt(int row) {
- DCHECK(row >= 0 && row < RowCount());
- return saved_signons_[row]->form.get();
-}
-
-void PasswordsTableModel::ForgetAndRemoveSignon(int row) {
- DCHECK(row >= 0 && row < RowCount());
- PasswordRows::iterator target_iter = saved_signons_.begin() + row;
- // Remove from DB, memory, and vector.
- PasswordRow* password_row = *target_iter;
- password_store()->RemoveLogin(*(password_row->form.get()));
- delete password_row;
- saved_signons_.erase(target_iter);
- if (observer_)
- observer_->OnItemsRemoved(row, 1);
- if (row_count_observer_)
- row_count_observer_->OnRowCountChanged(RowCount());
-}
-
-void PasswordsTableModel::ForgetAndRemoveAllSignons() {
- PasswordRows::iterator iter = saved_signons_.begin();
- while (iter != saved_signons_.end()) {
- // Remove from DB, memory, and vector.
- PasswordRow* row = *iter;
- password_store()->RemoveLogin(*(row->form.get()));
- delete row;
- iter = saved_signons_.erase(iter);
- }
- if (observer_)
- observer_->OnModelChanged();
- if (row_count_observer_)
- row_count_observer_->OnRowCountChanged(RowCount());
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// PasswordsTableModel, private
-void PasswordsTableModel::CancelLoginsQuery() {
- if (pending_login_query_) {
- password_store()->CancelLoginsQuery(pending_login_query_);
- pending_login_query_ = NULL;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// PasswordsPageView, public
-PasswordsPageView::PasswordsPageView(Profile* profile)
- : OptionsPageView(profile),
- ALLOW_THIS_IN_INITIALIZER_LIST(show_button_(
- this,
- l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON),
- l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON))),
- ALLOW_THIS_IN_INITIALIZER_LIST(remove_button_(
- this,
- l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_REMOVE_BUTTON))),
- ALLOW_THIS_IN_INITIALIZER_LIST(remove_all_button_(
- this,
- l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_REMOVE_ALL_BUTTON))),
- table_model_(profile),
- table_view_(NULL),
- current_selected_password_(NULL) {
- allow_show_passwords_.Init(prefs::kPasswordManagerAllowShowPasswords,
- profile->GetPrefs(),
- this);
-}
-
-PasswordsPageView::~PasswordsPageView() {
- // The model is going away, prevent the table from accessing it.
- if (table_view_)
- table_view_->SetModel(NULL);
-}
-
-void PasswordsPageView::OnSelectionChanged() {
- bool has_selection = table_view_->SelectedRowCount() > 0;
- remove_button_.SetEnabled(has_selection);
-
- PasswordForm* selected = NULL;
- if (has_selection) {
- views::TableSelectionIterator iter = table_view_->SelectionBegin();
- selected = table_model_.GetPasswordFormAt(*iter);
- DCHECK(++iter == table_view_->SelectionEnd());
- }
-
- if (selected != current_selected_password_) {
- // Reset the password related views.
- show_button_.SetLabel(
- l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON));
- show_button_.SetEnabled(has_selection);
- password_label_.SetText(std::wstring());
-
- current_selected_password_ = selected;
- }
-}
-
-void PasswordsPageView::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- // Close will result in our destruction.
- if (sender == &remove_all_button_) {
- ConfirmMessageBoxDialog::Run(
- GetWindow()->GetNativeWindow(),
- this,
- l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_TEXT_DELETE_ALL_PASSWORDS),
- l10n_util::GetString(
- IDS_PASSWORDS_PAGE_VIEW_CAPTION_DELETE_ALL_PASSWORDS));
- return;
- }
-
- // The following require a selection (and only one, since table is single-
- // select only).
- views::TableSelectionIterator iter = table_view_->SelectionBegin();
- int row = *iter;
- PasswordForm* selected = table_model_.GetPasswordFormAt(row);
- DCHECK(++iter == table_view_->SelectionEnd());
-
- if (sender == &remove_button_) {
- table_model_.ForgetAndRemoveSignon(row);
- } else if (sender == &show_button_) {
- if (password_label_.GetText().length() == 0 &&
- allow_show_passwords_.GetValue()) {
- password_label_.SetText(selected->password_value);
- show_button_.SetLabel(
- l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON));
- } else {
- HidePassword();
- }
- } else {
- NOTREACHED() << "Invalid button.";
- }
-}
-
-void PasswordsPageView::OnRowCountChanged(size_t rows) {
- remove_all_button_.SetEnabled(rows > 0);
-}
-
-void PasswordsPageView::OnConfirmMessageAccept() {
- table_model_.ForgetAndRemoveAllSignons();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// PasswordsPageView, protected
-void PasswordsPageView::InitControlLayout() {
- SetupButtonsAndLabels();
- SetupTable();
-
- // Do the layout thing.
- const int top_column_set_id = 0;
- GridLayout* layout = CreatePanelGridLayout(this);
- SetLayoutManager(layout);
-
- // Design the grid.
- ColumnSet* column_set = layout->AddColumnSet(top_column_set_id);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
-
- // Fill the grid.
- layout->StartRow(0, top_column_set_id);
- layout->AddView(table_view_, 1, 8, GridLayout::FILL,
- GridLayout::FILL);
- layout->AddView(&remove_button_);
- layout->StartRowWithPadding(0, top_column_set_id, 0,
- kRelatedControlVerticalSpacing);
- layout->SkipColumns(1);
- layout->AddView(&remove_all_button_);
- layout->StartRowWithPadding(0, top_column_set_id, 0,
- kRelatedControlVerticalSpacing);
- layout->SkipColumns(1);
- layout->AddView(&show_button_);
- layout->StartRowWithPadding(0, top_column_set_id, 0,
- kRelatedControlVerticalSpacing);
- layout->SkipColumns(1);
- layout->AddView(&password_label_);
- layout->AddPaddingRow(1, 0);
-
- // Ask the database for saved password data.
- table_model_.GetAllSavedLoginsForProfile();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// PasswordsPageView, private
-void PasswordsPageView::SetupButtonsAndLabels() {
- // Disable all buttons in the first place.
- show_button_.set_parent_owned(false);
- show_button_.SetEnabled(false);
-
- remove_button_.set_parent_owned(false);
- remove_button_.SetEnabled(false);
-
- remove_all_button_.set_parent_owned(false);
- remove_all_button_.SetEnabled(false);
-
- password_label_.set_parent_owned(false);
-}
-
-void PasswordsPageView::SetupTable() {
- // Tell the table model we are concern about how many rows it has.
- table_model_.set_row_count_observer(this);
-
- // Creates the different columns for the table.
- // The float resize values are the result of much tinkering.
- std::vector<TableColumn> columns;
- columns.push_back(TableColumn(IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN,
- TableColumn::LEFT, -1, 0.55f));
- columns.back().sortable = true;
- columns.push_back(TableColumn(
- IDS_PASSWORDS_PAGE_VIEW_USERNAME_COLUMN, TableColumn::LEFT,
- -1, 0.37f));
- columns.back().sortable = true;
- table_view_ = new views::TableView(&table_model_, columns, views::TEXT_ONLY,
- true, true, true);
- // Make the table initially sorted by host.
- views::TableView::SortDescriptors sort;
- sort.push_back(views::TableView::SortDescriptor(
- IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN, true));
- table_view_->SetSortDescriptors(sort);
- table_view_->SetObserver(this);
-}
-
-void PasswordsPageView::HidePassword() {
- password_label_.SetText(L"");
- show_button_.SetLabel(
- l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON));
-}
-
-void PasswordsPageView::NotifyPrefChanged(const std::string* pref_name) {
- if (!pref_name || *pref_name == prefs::kPasswordManagerAllowShowPasswords) {
- bool show = allow_show_passwords_.GetValue();
- if (!show)
- HidePassword();
- show_button_.SetVisible(show);
- password_label_.SetVisible(show);
- // Update the layout (it may depend on the button size).
- show_button_.InvalidateLayout();
- Layout();
- }
-}
diff --git a/chrome/browser/views/options/passwords_page_view.h b/chrome/browser/views/options/passwords_page_view.h
index 418fcbe..2c4612a 100644
--- a/chrome/browser/views/options/passwords_page_view.h
+++ b/chrome/browser/views/options/passwords_page_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
@@ -6,195 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_PASSWORDS_PAGE_VIEW_H_
#pragma once
-#include <vector>
-
-#include "app/table_model.h"
-#include "app/text_elider.h"
-#include "base/scoped_ptr.h"
-#include "base/stl_util-inl.h"
-#include "chrome/browser/password_manager/password_store.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/prefs/pref_member.h"
-#include "chrome/browser/views/confirm_message_box_dialog.h"
-#include "chrome/browser/views/options/options_page_view.h"
-#include "views/controls/button/native_button.h"
-#include "views/controls/label.h"
-#include "views/controls/table/table_view.h"
-#include "views/controls/table/table_view_observer.h"
-#include "views/window/dialog_delegate.h"
-#include "views/window/window.h"
-#include "webkit/glue/password_form.h"
-
-///////////////////////////////////////////////////////////////////////////////
-// PasswordTableModelObserver
-// An observer interface to notify change of row count in a table model. This
-// allow the container view of TableView(i.e. PasswordsPageView and
-// ExceptionsPageView), to be notified of row count changes directly
-// from the TableModel. We have two different observers in
-// PasswordsTableModel, namely TableModelObserver and
-// PasswordsTableModelObserver, rather than adding this event to
-// TableModelObserver because only container view of
-// PasswordsTableModel cares about this event.
-class PasswordsTableModelObserver {
- public:
- virtual void OnRowCountChanged(size_t rows) = 0;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// MultiLabelButtons
-// A button that can have 2 different labels set on it and for which the
-// preferred size is the size of the widest string.
-class MultiLabelButtons : public views::NativeButton {
- public:
- MultiLabelButtons(views::ButtonListener* listener,
- const std::wstring& label,
- const std::wstring& alt_label);
-
- virtual gfx::Size GetPreferredSize();
-
- private:
- std::wstring label_;
- std::wstring alt_label_;
- gfx::Size pref_size_;
-
- DISALLOW_COPY_AND_ASSIGN(MultiLabelButtons);
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// PasswordsTableModel
-class PasswordsTableModel : public TableModel,
- public PasswordStoreConsumer {
- public:
- explicit PasswordsTableModel(Profile* profile);
- virtual ~PasswordsTableModel();
-
- // TableModel methods.
- virtual int RowCount();
- virtual std::wstring GetText(int row, int column);
- virtual int CompareValues(int row1, int row2, int column_id);
- virtual void SetObserver(TableModelObserver* observer);
-
- // Delete the PasswordForm at specified row from the database (and remove
- // from view).
- void ForgetAndRemoveSignon(int row);
-
- // Delete all saved signons for the active profile (via web data service),
- // and clear the view.
- void ForgetAndRemoveAllSignons();
-
- // PasswordStoreConsumer implementation.
- virtual void OnPasswordStoreRequestDone(
- int handle, const std::vector<webkit_glue::PasswordForm*>& result);
-
- // Request saved logins data.
- void GetAllSavedLoginsForProfile();
-
- // Return the PasswordForm at the specified index.
- webkit_glue::PasswordForm* GetPasswordFormAt(int row);
-
- // Set the observer who concerns about how many rows are in the table.
- void set_row_count_observer(PasswordsTableModelObserver* observer) {
- row_count_observer_ = observer;
- }
-
- protected:
- // Wraps the PasswordForm from the database and caches the display URL for
- // quick sorting.
- struct PasswordRow {
- PasswordRow(const gfx::SortedDisplayURL& url,
- webkit_glue::PasswordForm* password_form)
- : display_url(url), form(password_form) {
- }
-
- // Contains the URL that is displayed along with the
- gfx::SortedDisplayURL display_url;
-
- // The underlying PasswordForm. We own this.
- scoped_ptr<webkit_glue::PasswordForm> form;
- };
-
- // The password store associated with the currently active profile.
- PasswordStore* password_store() {
- return profile_->GetPasswordStore(Profile::EXPLICIT_ACCESS);
- }
-
- // The TableView observing this model.
- TableModelObserver* observer_;
-
- // Dispatching row count events specific to this password manager table model
- // to this observer.
- PasswordsTableModelObserver* row_count_observer_;
-
- // Handle to any pending PasswordStore login lookup query.
- int pending_login_query_;
-
- // The set of passwords we're showing.
- typedef std::vector<PasswordRow*> PasswordRows;
- PasswordRows saved_signons_;
- STLElementDeleter<PasswordRows> saved_signons_cleanup_;
-
- Profile* profile_;
-
- private:
- // Cancel any pending login query involving a callback.
- void CancelLoginsQuery();
-
- DISALLOW_COPY_AND_ASSIGN(PasswordsTableModel);
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// PasswordsPageView
-class PasswordsPageView : public OptionsPageView,
- public views::TableViewObserver,
- public views::ButtonListener,
- public PasswordsTableModelObserver,
- public ConfirmMessageBoxObserver {
- public:
- explicit PasswordsPageView(Profile* profile);
- virtual ~PasswordsPageView();
-
- // views::TableViewObserverImplementation.
- virtual void OnSelectionChanged();
-
- // views::ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // PasswordsTableModelObserver implementation.
- virtual void OnRowCountChanged(size_t rows);
-
- // ConfirmMessageBoxObserver implementation.
- virtual void OnConfirmMessageAccept();
-
- protected:
- virtual void InitControlLayout();
-
- private:
- // Helper to configure our buttons and labels.
- void SetupButtonsAndLabels();
-
- // Helper to configure our table view.
- void SetupTable();
-
- // Helper that hides the password.
- void HidePassword();
-
- // Handles changes to the observed preferences and updates the UI.
- void NotifyPrefChanged(const std::string* pref_name);
-
- PasswordsTableModel table_model_;
- views::TableView* table_view_;
-
- // The buttons and labels.
- MultiLabelButtons show_button_;
- views::NativeButton remove_button_;
- views::NativeButton remove_all_button_;
- views::Label password_label_;
- webkit_glue::PasswordForm* current_selected_password_;
-
- // Tracks the preference that controls whether showing passwords is allowed.
- BooleanPrefMember allow_show_passwords_;
-
- DISALLOW_COPY_AND_ASSIGN(PasswordsPageView);
-};
+#include "chrome/browser/ui/views/options/passwords_page_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_PASSWORDS_PAGE_VIEW_H_
+
diff --git a/chrome/browser/views/options/plugin_filter_page_view.cc b/chrome/browser/views/options/plugin_filter_page_view.cc
deleted file mode 100644
index eeb5c6c..0000000
--- a/chrome/browser/views/options/plugin_filter_page_view.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-// 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/options/plugin_filter_page_view.h"
-
-#include "app/l10n_util.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/show_options_url.h"
-#include "chrome/common/url_constants.h"
-#include "grit/generated_resources.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-
-PluginFilterPageView::PluginFilterPageView(Profile* profile)
- : ContentFilterPageView(profile, CONTENT_SETTINGS_TYPE_PLUGINS) {
-}
-
-PluginFilterPageView::~PluginFilterPageView() {
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// PluginFilterPageView, ContentFilterPageView override:
-
-void PluginFilterPageView::InitControlLayout() {
- ContentFilterPageView::InitControlLayout();
-
- using views::GridLayout;
-
- GridLayout* layout = static_cast<GridLayout*>(GetLayoutManager());
- const int single_column_set_id = 0;
- layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
-
- views::Link* plugins_page_link = new views::Link(
- l10n_util::GetString(IDS_PLUGIN_SELECTIVE_DISABLE));
- plugins_page_link->SetController(this);
-
- layout->StartRow(0, single_column_set_id);
- layout->AddView(plugins_page_link, 1, 1, GridLayout::LEADING,
- GridLayout::FILL);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// PluginFilterPageView, views::LinkController implementation:
-
-void PluginFilterPageView::LinkActivated(views::Link* source,
- int event_flags) {
- browser::ShowOptionsURL(profile(), GURL(chrome::kChromeUIPluginsURL));
-}
diff --git a/chrome/browser/views/options/plugin_filter_page_view.h b/chrome/browser/views/options/plugin_filter_page_view.h
index 6dc6af9..d1d4086 100644
--- a/chrome/browser/views/options/plugin_filter_page_view.h
+++ b/chrome/browser/views/options/plugin_filter_page_view.h
@@ -6,27 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_PLUGIN_FILTER_PAGE_VIEW_H_
#pragma once
-#include "chrome/browser/views/options/content_filter_page_view.h"
-
-////////////////////////////////////////////////////////////////////////////////
-// PluginFilterPageView class is used to render the plugin content settings tab.
-
-class PluginFilterPageView : public ContentFilterPageView,
- public views::LinkController {
- public:
- explicit PluginFilterPageView(Profile* profile);
- virtual ~PluginFilterPageView();
-
- private:
- // Overridden from ContentFilterPageView:
- virtual void InitControlLayout();
-
- // Overridden from views::LinkController:
- virtual void LinkActivated(views::Link* source, int event_flags);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(PluginFilterPageView);
-};
+#include "chrome/browser/ui/views/options/plugin_filter_page_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_PLUGIN_FILTER_PAGE_VIEW_H_
diff --git a/chrome/browser/views/options/simple_content_exceptions_view.cc b/chrome/browser/views/options/simple_content_exceptions_view.cc
deleted file mode 100644
index 5df84aa..0000000
--- a/chrome/browser/views/options/simple_content_exceptions_view.cc
+++ /dev/null
@@ -1,185 +0,0 @@
-// 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/options/simple_content_exceptions_view.h"
-
-#include <algorithm>
-#include <vector>
-
-#include "app/l10n_util.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "gfx/rect.h"
-#include "views/controls/button/native_button.h"
-#include "views/controls/table/table_view.h"
-#include "views/grid_layout.h"
-#include "views/standard_layout.h"
-#include "views/window/window.h"
-
-static const int kExceptionsViewInsetSize = 5;
-static SimpleContentExceptionsView* instance = NULL;
-
-// static
-void SimpleContentExceptionsView::ShowExceptionsWindow(
- gfx::NativeWindow parent,
- RemoveRowsTableModel* model,
- int title_message_id) {
- scoped_ptr<RemoveRowsTableModel> owned_model(model);
- if (!instance) {
- instance = new SimpleContentExceptionsView(owned_model.release(),
- title_message_id);
- views::Window::CreateChromeWindow(parent, gfx::Rect(), instance);
- }
-
- // This will show invisible windows and bring visible windows to the front.
- instance->window()->Show();
-}
-
-SimpleContentExceptionsView::~SimpleContentExceptionsView() {
- instance = NULL;
- table_->SetModel(NULL);
-}
-
-void SimpleContentExceptionsView::OnSelectionChanged() {
- UpdateButtonState();
-}
-
-void SimpleContentExceptionsView::OnTableViewDelete(
- views::TableView* table_view) {
- Remove();
-}
-
-void SimpleContentExceptionsView::ButtonPressed(views::Button* sender,
- const views::Event& event) {
- switch (sender->tag()) {
- case IDS_EXCEPTIONS_REMOVEALL_BUTTON:
- RemoveAll();
- break;
- case IDS_EXCEPTIONS_REMOVE_BUTTON:
- Remove();
- break;
- default:
- NOTREACHED();
- }
-}
-
-void SimpleContentExceptionsView::Layout() {
- views::NativeButton* buttons[] = { remove_button_, remove_all_button_ };
-
- // The buttons are placed in the parent, but we need to lay them out.
- int max_y = GetParent()->GetLocalBounds(false).bottom() - kButtonVEdgeMargin;
- int x = kPanelHorizMargin;
-
- for (size_t i = 0; i < arraysize(buttons); ++i) {
- gfx::Size pref = buttons[i]->GetPreferredSize();
- buttons[i]->SetBounds(x, max_y - pref.height(), pref.width(),
- pref.height());
- x += pref.width() + kRelatedControlHorizontalSpacing;
- }
-
- // Lay out the rest of this view.
- View::Layout();
-}
-
-gfx::Size SimpleContentExceptionsView::GetPreferredSize() {
- return gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_SIMPLE_CONTENT_EXCEPTION_DIALOG_WIDTH_CHARS,
- IDS_SIMPLE_CONTENT_EXCEPTION_DIALOG_HEIGHT_LINES));
-}
-
-void SimpleContentExceptionsView::ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child) {
- if (is_add && child == this)
- Init();
-}
-
-std::wstring SimpleContentExceptionsView::GetWindowTitle() const {
- return l10n_util::GetString(title_message_id_);
-}
-
-SimpleContentExceptionsView::SimpleContentExceptionsView(
- RemoveRowsTableModel* model,
- int title_message_id)
- : model_(model),
- table_(NULL),
- remove_button_(NULL),
- remove_all_button_(NULL),
- title_message_id_(title_message_id) {
-}
-
-void SimpleContentExceptionsView::Init() {
- if (table_)
- return; // We've already Init'd.
-
- using views::GridLayout;
-
- std::vector<TableColumn> columns;
- columns.push_back(
- TableColumn(IDS_EXCEPTIONS_HOSTNAME_HEADER, TableColumn::LEFT, -1, .75));
- columns.back().sortable = true;
- columns.push_back(
- TableColumn(IDS_EXCEPTIONS_ACTION_HEADER, TableColumn::LEFT, -1, .25));
- columns.back().sortable = true;
- table_ = new views::TableView(model_.get(), columns, views::TEXT_ONLY,
- false, true, false);
- views::TableView::SortDescriptors sort;
- sort.push_back(
- views::TableView::SortDescriptor(IDS_EXCEPTIONS_HOSTNAME_HEADER, true));
- table_->SetSortDescriptors(sort);
- table_->SetObserver(this);
-
- remove_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_EXCEPTIONS_REMOVE_BUTTON));
- remove_button_->set_tag(IDS_EXCEPTIONS_REMOVE_BUTTON);
- remove_all_button_ = new views::NativeButton(
- this, l10n_util::GetString(IDS_EXCEPTIONS_REMOVEALL_BUTTON));
- remove_all_button_->set_tag(IDS_EXCEPTIONS_REMOVEALL_BUTTON);
-
- View* parent = GetParent();
- parent->AddChildView(remove_button_);
- parent->AddChildView(remove_all_button_);
-
- GridLayout* layout = new GridLayout(this);
- layout->SetInsets(kExceptionsViewInsetSize, kExceptionsViewInsetSize,
- kExceptionsViewInsetSize, kExceptionsViewInsetSize);
- SetLayoutManager(layout);
-
- const int single_column_layout_id = 0;
- views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
- column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- layout->StartRow(1, single_column_layout_id);
- layout->AddView(table_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- UpdateButtonState();
-}
-
-RemoveRowsTableModel::Rows
- SimpleContentExceptionsView::GetSelectedRows() const {
- RemoveRowsTableModel::Rows rows;
- for (views::TableView::iterator i(table_->SelectionBegin());
- i != table_->SelectionEnd(); ++i)
- rows.insert(*i);
- return rows;
-}
-
-void SimpleContentExceptionsView::UpdateButtonState() {
- remove_button_->SetEnabled(model_->CanRemoveRows(GetSelectedRows()));
- remove_all_button_->SetEnabled(model_->RowCount() > 0);
-}
-
-void SimpleContentExceptionsView::Remove() {
- model_->RemoveRows(GetSelectedRows());
- UpdateButtonState();
-}
-
-void SimpleContentExceptionsView::RemoveAll() {
- model_->RemoveAll();
- UpdateButtonState();
-}
diff --git a/chrome/browser/views/options/simple_content_exceptions_view.h b/chrome/browser/views/options/simple_content_exceptions_view.h
index b0ab00a..6b89cd9 100644
--- a/chrome/browser/views/options/simple_content_exceptions_view.h
+++ b/chrome/browser/views/options/simple_content_exceptions_view.h
@@ -6,90 +6,8 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_SIMPLE_CONTENT_EXCEPTIONS_VIEW_H_
#pragma once
-#include <string>
-
-#include "chrome/browser/remove_rows_table_model.h"
-#include "chrome/common/content_settings.h"
-#include "views/controls/button/button.h"
-#include "views/controls/table/table_view_observer.h"
-#include "views/window/dialog_delegate.h"
-
-namespace views {
-class NativeButton;
-class TableView;
-}
-
-// SimpleContentExceptionsView is responsible for showing the user the set of
-// site-specific permissions. The exceptions are shown in a table view by way
-// of a RemoveRowsTableModel. The user can remove exceptions.
-// Use the ShowExceptionsWindow method to create and show a
-// SimpleContentExceptionsView, which is deleted when the window closes.
-class SimpleContentExceptionsView : public views::View,
- public views::ButtonListener,
- public views::DialogDelegate,
- public views::TableViewObserver {
- public:
- // Shows the Exceptions window. Takes ownership of |model|.
- static void ShowExceptionsWindow(gfx::NativeWindow parent,
- RemoveRowsTableModel* model,
- int title_message_id);
-
- virtual ~SimpleContentExceptionsView();
-
- // TableViewObserver overrides:
- virtual void OnSelectionChanged();
- virtual void OnTableViewDelete(views::TableView* table_view);
-
- // views::ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // views::View overrides:
- virtual void Layout();
- virtual gfx::Size GetPreferredSize();
- virtual void ViewHierarchyChanged(bool is_add,
- views::View* parent,
- views::View* child);
-
- // views::WindowDelegate implementation.
- virtual int GetDialogButtons() const {
- return MessageBoxFlags::DIALOGBUTTON_CANCEL;
- }
- virtual bool CanResize() const { return true; }
- virtual std::wstring GetWindowTitle() const;
- virtual views::View* GetContentsView() { return this; }
-
- private:
- // Takes ownership of |model|.
- explicit SimpleContentExceptionsView(RemoveRowsTableModel* model,
- int title_message_id);
-
- void Init();
-
- // Resets the enabled state of the buttons from the model.
- void UpdateButtonState();
-
- // Returns the set of selected rows.
- RemoveRowsTableModel::Rows GetSelectedRows() const;
-
- // Removes the selected item.
- void Remove();
-
- // Removes all.
- void RemoveAll();
-
- // The model displayed in the table.
- scoped_ptr<RemoveRowsTableModel> model_;
-
- views::TableView* table_;
-
- views::NativeButton* remove_button_;
- views::NativeButton* remove_all_button_;
-
- // The message id of the window title.
- int title_message_id_;
-
- DISALLOW_COPY_AND_ASSIGN(SimpleContentExceptionsView);
-};
+#include "chrome/browser/ui/views/options/simple_content_exceptions_view.h"
+// TODO(beng): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_VIEWS_OPTIONS_SIMPLE_CONTENT_EXCEPTIONS_VIEW_H_