diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-17 20:21:04 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-17 20:21:04 +0000 |
commit | 5d9163e2136f0b4eef4aac3e650f1b6e655118fd (patch) | |
tree | ed86b9c0422989d8c4d90cf628ca9f6239bd5d8b /chrome/browser/views | |
parent | 87c23d51618a288127eed63419e4f26d770f74c5 (diff) | |
download | chromium_src-5d9163e2136f0b4eef4aac3e650f1b6e655118fd.zip chromium_src-5d9163e2136f0b4eef4aac3e650f1b6e655118fd.tar.gz chromium_src-5d9163e2136f0b4eef4aac3e650f1b6e655118fd.tar.bz2 |
Remove vestigial cookie/web app permissions prompting UI now that the async UI has been approved for M7.This allows me to more easily change the way the appmodal dialog system works.
http://crbug.com/55121
TEST=existing tests
Review URL: http://codereview.chromium.org/3299020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59838 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/cookie_prompt_view.cc | 297 | ||||
-rw-r--r-- | chrome/browser/views/cookie_prompt_view.h | 123 | ||||
-rw-r--r-- | chrome/browser/views/options/content_filter_page_view.cc | 4 |
3 files changed, 1 insertions, 423 deletions
diff --git a/chrome/browser/views/cookie_prompt_view.cc b/chrome/browser/views/cookie_prompt_view.cc deleted file mode 100644 index 92b80ca..0000000 --- a/chrome/browser/views/cookie_prompt_view.cc +++ /dev/null @@ -1,297 +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/cookie_prompt_view.h" - -#include <algorithm> - -#include "app/l10n_util.h" -#include "base/message_loop.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/cookie_modal_dialog.h" -#include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/profile.h" -#include "chrome/browser/views/browser_dialogs.h" -#include "chrome/browser/views/cookie_info_view.h" -#include "chrome/browser/views/database_open_info_view.h" -#include "chrome/browser/views/generic_info_view.h" -#include "chrome/browser/views/local_storage_set_item_info_view.h" -#include "chrome/browser/views/options/content_settings_window_view.h" -#include "chrome/common/pref_names.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/controls/label.h" -#include "views/controls/button/native_button.h" -#include "views/controls/button/radio_button.h" -#include "views/controls/textfield/textfield.h" -#include "views/grid_layout.h" -#include "views/standard_layout.h" -#include "views/window/non_client_view.h" - -static const int kCookiePromptViewInsetSize = 5; - -/////////////////////////////////////////////////////////////////////////////// -// CookiePromptView, public: - -CookiePromptView::CookiePromptView( - CookiePromptModalDialog* parent, - gfx::NativeWindow root_window, - Profile* profile) - : remember_radio_(NULL), - ask_radio_(NULL), - allow_button_(NULL), - block_button_(NULL), - show_cookie_link_(NULL), - info_view_(NULL), - session_expire_(false), - expanded_view_(false), - signaled_(false), - parent_(parent), - root_window_(root_window), - profile_(profile) { - InitializeViewResources(); - expanded_view_ = profile_->GetPrefs()-> - GetBoolean(prefs::kCookiePromptExpanded); -} - -CookiePromptView::~CookiePromptView() { -} - -/////////////////////////////////////////////////////////////////////////////// -// CookiePromptView, views::View overrides: - -gfx::Size CookiePromptView::GetPreferredSize() { - gfx::Size client_size = views::View::GetPreferredSize(); - return gfx::Size(client_size.width(), - client_size.height() + GetExtendedViewHeight()); -} - - -void CookiePromptView::ViewHierarchyChanged(bool is_add, - views::View* parent, - views::View* child) { - if (is_add && child == this) - Init(); -} - -/////////////////////////////////////////////////////////////////////////////// -// CookiePromptView, ModalDialogDelegate implementation: - -gfx::NativeWindow CookiePromptView::GetDialogRootWindow() { - return root_window_; -} - -/////////////////////////////////////////////////////////////////////////////// -// CookiePromptView, views::DialogDelegate implementation: - -std::wstring CookiePromptView::GetWindowTitle() const { - return title_; -} - -void CookiePromptView::WindowClosing() { - if (!signaled_) - parent_->BlockSiteData(false); - parent_->CompleteDialog(); -} - -views::View* CookiePromptView::GetContentsView() { - return this; -} - -bool CookiePromptView::Accept() { - parent_->AllowSiteData(remember_radio_->checked(), session_expire_); - signaled_ = true; - return true; -} - -// CookieInfoViewDelegate overrides: -void CookiePromptView::ModifyExpireDate(bool session_expire) { - session_expire_ = session_expire; -} - - -/////////////////////////////////////////////////////////////////////////////// -// CookiePromptView, views::ButtonListener implementation: - -void CookiePromptView::ButtonPressed(views::Button* sender, - const views::Event& event) { - if (sender == allow_button_) { - Accept(); - GetWindow()->Close(); - } else if (sender == block_button_) { - parent_->BlockSiteData(remember_radio_->checked()); - signaled_ = true; - GetWindow()->Close(); - } -} - -/////////////////////////////////////////////////////////////////////////////// -// CookiePromptView, views::LinkController implementation: -void CookiePromptView::LinkActivated(views::Link* source, int event_flags) { - DCHECK_EQ(source, show_cookie_link_); - ToggleDetailsViewExpand(); -} - -/////////////////////////////////////////////////////////////////////////////// -// CookiePromptView, private: - -void CookiePromptView::Init() { - CookiePromptModalDialog::DialogType type = parent_->dialog_type(); - std::wstring display_host = UTF8ToWide(parent_->origin().host()); - views::Label* description_label = new views::Label(l10n_util::GetStringF( - type == CookiePromptModalDialog::DIALOG_TYPE_COOKIE ? - IDS_COOKIE_ALERT_LABEL : IDS_DATA_ALERT_LABEL, - display_host)); - int radio_group_id = 0; - remember_radio_ = new views::RadioButton( - l10n_util::GetStringF(IDS_COOKIE_ALERT_REMEMBER_RADIO, display_host), - radio_group_id); - remember_radio_->set_listener(this); - ask_radio_ = new views::RadioButton( - l10n_util::GetString(IDS_COOKIE_ALERT_ASK_RADIO), radio_group_id); - ask_radio_->set_listener(this); - allow_button_ = new views::NativeButton( - this, l10n_util::GetString(IDS_COOKIE_ALERT_ALLOW_BUTTON)); - block_button_ = new views::NativeButton( - this, l10n_util::GetString(IDS_COOKIE_ALERT_BLOCK_BUTTON)); - show_cookie_link_ = new views::Link( - l10n_util::GetString(IDS_COOKIE_SHOW_DETAILS_LABEL)); - show_cookie_link_->SetController(this); - - using views::GridLayout; - - GridLayout* layout = CreatePanelGridLayout(this); - layout->SetInsets(kCookiePromptViewInsetSize, kCookiePromptViewInsetSize, - kCookiePromptViewInsetSize, kCookiePromptViewInsetSize); - SetLayoutManager(layout); - - const int one_column_layout_id = 0; - views::ColumnSet* one_column_set = layout->AddColumnSet(one_column_layout_id); - one_column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); - one_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, - GridLayout::USE_PREF, 0, 0); - one_column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); - layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - layout->StartRow(0, one_column_layout_id); - layout->AddView(description_label); - layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); - layout->StartRow(0, one_column_layout_id); - layout->AddView(remember_radio_); - layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - layout->StartRow(0, one_column_layout_id); - layout->AddView(ask_radio_); - layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - - View* button_container = new View(); - GridLayout* button_layout = new GridLayout(button_container); - button_container->SetLayoutManager(button_layout); - const int inner_column_layout_id = 1; - views::ColumnSet* inner_column_set = button_layout->AddColumnSet( - inner_column_layout_id); - inner_column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, - GridLayout::USE_PREF, 0, 0); - inner_column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); - inner_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, - GridLayout::USE_PREF, 0, 0); - inner_column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); - inner_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, - GridLayout::USE_PREF, 0, 0); - button_layout->StartRow(0, inner_column_layout_id); - button_layout->AddView(show_cookie_link_, 1, 1, - GridLayout::LEADING, GridLayout::TRAILING); - button_layout->AddView(allow_button_); - button_layout->AddView(block_button_); - - int button_column_layout_id = 2; - views::ColumnSet* button_column_set = - layout->AddColumnSet(button_column_layout_id); - button_column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); - button_column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, - GridLayout::USE_PREF, 0, 0); - button_column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); - layout->StartRow(0, one_column_layout_id); - layout->AddView(button_container, 1, 1, - GridLayout::FILL, GridLayout::CENTER); - layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - - layout->StartRow(0, one_column_layout_id); - - if (type == CookiePromptModalDialog::DIALOG_TYPE_COOKIE) { - CookieInfoView* cookie_info_view = new CookieInfoView(true); - cookie_info_view->set_delegate(this); - layout->AddView(cookie_info_view, 1, 1, GridLayout::FILL, - GridLayout::CENTER); - - cookie_info_view->SetCookieString(parent_->origin(), - parent_->cookie_line()); - info_view_ = cookie_info_view; - } else if (type == CookiePromptModalDialog::DIALOG_TYPE_LOCAL_STORAGE) { - LocalStorageSetItemInfoView* view = new LocalStorageSetItemInfoView(); - layout->AddView(view, 1, 1, GridLayout::FILL, GridLayout::CENTER); - view->SetFields(parent_->origin().host(), - parent_->local_storage_key(), - parent_->local_storage_value()); - info_view_ = view; - } else if (type == CookiePromptModalDialog::DIALOG_TYPE_DATABASE) { - DatabaseOpenInfoView* view = new DatabaseOpenInfoView(); - layout->AddView(view, 1, 1, GridLayout::FILL, GridLayout::CENTER); - view->SetFields(parent_->origin().host(), - parent_->database_name(), - parent_->display_name(), - parent_->estimated_size()); - info_view_ = view; - } else if (type == CookiePromptModalDialog::DIALOG_TYPE_APPCACHE) { - static const int kAppCacheInfoLabels[] = { - IDS_COOKIES_APPLICATION_CACHE_MANIFEST_LABEL - }; - GenericInfoView* view = new GenericInfoView(ARRAYSIZE(kAppCacheInfoLabels), - kAppCacheInfoLabels); - layout->AddView(view, 1, 1, GridLayout::FILL, GridLayout::CENTER); - view->SetValue(0, UTF8ToUTF16(parent_->appcache_manifest_url().spec())); - info_view_ = view; - } else { - NOTIMPLEMENTED(); - } - - info_view_->SetVisible(expanded_view_); - - // Set default values. - remember_radio_->SetChecked(true); -} - -int CookiePromptView::GetExtendedViewHeight() { - DCHECK(info_view_); - return expanded_view_ ? - 0 : -info_view_->GetPreferredSize().height(); -} - -void CookiePromptView::ToggleDetailsViewExpand() { - int old_extended_height = GetExtendedViewHeight(); - - expanded_view_ = !expanded_view_; - profile_->GetPrefs()->SetBoolean(prefs::kCookiePromptExpanded, - expanded_view_); - - // We have to set the visbility before asking for the extended view height - // again as there is a bug in combobox that results in preferred height - // changing when visible and not visible. - info_view_->SetVisible(expanded_view_); - int extended_height_delta = GetExtendedViewHeight() - old_extended_height; - views::Window* window = GetWindow(); - gfx::Rect bounds = window->GetBounds(); - bounds.set_height(bounds.height() + extended_height_delta); - window->SetBounds(bounds, NULL); -} - -void CookiePromptView::InitializeViewResources() { - CookiePromptModalDialog::DialogType type = parent_->dialog_type(); - title_ = l10n_util::GetStringF( - type == CookiePromptModalDialog::DIALOG_TYPE_COOKIE ? - IDS_COOKIE_ALERT_TITLE : IDS_DATA_ALERT_TITLE, - UTF8ToWide(parent_->origin().host())); -} diff --git a/chrome/browser/views/cookie_prompt_view.h b/chrome/browser/views/cookie_prompt_view.h deleted file mode 100644 index c94e700..0000000 --- a/chrome/browser/views/cookie_prompt_view.h +++ /dev/null @@ -1,123 +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. - -#ifndef CHROME_BROWSER_VIEWS_COOKIE_PROMPT_VIEW_H_ -#define CHROME_BROWSER_VIEWS_COOKIE_PROMPT_VIEW_H_ -#pragma once - -#include <string> - -#include "base/task.h" -#include "chrome/browser/browsing_data_local_storage_helper.h" -#include "chrome/browser/cookie_prompt_modal_dialog_delegate.h" -#include "chrome/browser/views/cookie_info_view.h" -#include "chrome/browser/views/modal_dialog_delegate.h" -#include "googleurl/src/gurl.h" -#include "views/controls/button/button.h" -#include "views/controls/link.h" -#include "views/view.h" -#include "views/window/dialog_delegate.h" -#include "views/window/window.h" - -namespace views { -class NativeButton; -class RadioButton; -} - -class CookieInfoView; -class CookiePromptModalDialog; -class LocalStorageInfoView; -class Profile; -class Timer; - -// Cookie alert dialog UI. -class CookiePromptView : public views::View, - public ModalDialogDelegate, - public views::ButtonListener, - public views::LinkController, - public CookieInfoViewDelegate { - public: - // Creates a new CookiePromptView. We take ownership of |parent|. - CookiePromptView( - CookiePromptModalDialog* parent, - gfx::NativeWindow root_window, - Profile* profile); - - virtual ~CookiePromptView(); - - protected: - // views::View overrides. - virtual gfx::Size GetPreferredSize(); - virtual void ViewHierarchyChanged(bool is_add, - views::View* parent, - views::View* child); - - // ModalDialogDelegate overrides. - virtual gfx::NativeWindow GetDialogRootWindow(); - - // views::DialogDelegate overrides. - virtual bool CanResize() const { return false; } - virtual std::wstring GetWindowTitle() const; - virtual void WindowClosing(); - virtual views::View* GetContentsView(); - virtual bool IsModal() const { return true; } - virtual bool Accept(); - - // views::ButtonListener overrides. - virtual void ButtonPressed(views::Button* sender, const views::Event& event); - - // views::LinkController overrides. - virtual void LinkActivated(views::Link* source, int event_flags); - - // views::WindowDelegate overrides. - virtual int GetDialogButtons() const { - return MessageBoxFlags::DIALOGBUTTON_NONE; - } - - // CookieInfoViewDelegate overrides: - virtual void ModifyExpireDate(bool session_expire); - - private: - // Initialize the dialog layout. - void Init(); - - // Shows or hides cooke info view and changes parent. - void ToggleDetailsViewExpand(); - - // Calculates view size offset depending on visibility of cookie details. - int GetExtendedViewHeight(); - - // Initializes text resources needed to display this view. - void InitializeViewResources(); - - views::RadioButton* remember_radio_; - views::RadioButton* ask_radio_; - views::NativeButton* allow_button_; - views::NativeButton* block_button_; - views::Link* show_cookie_link_; - views::View* info_view_; - - // True if cookie should expire with this session. - bool session_expire_; - - // True if cookie info view is currently shown and window expanded. - bool expanded_view_; - - // True if the outcome of this dialog has been signaled to the delegate. - bool signaled_; - - // Prompt window title. - std::wstring title_; - - // A pointer to the AppModalDialog that created us. We own this. - scoped_ptr<CookiePromptModalDialog> parent_; - - gfx::NativeWindow root_window_; - - Profile* profile_; - - DISALLOW_COPY_AND_ASSIGN(CookiePromptView); -}; - -#endif // CHROME_BROWSER_VIEWS_COOKIE_PROMPT_VIEW_H_ diff --git a/chrome/browser/views/options/content_filter_page_view.cc b/chrome/browser/views/options/content_filter_page_view.cc index ac2ab38..5ea47e5 100644 --- a/chrome/browser/views/options/content_filter_page_view.cc +++ b/chrome/browser/views/options/content_filter_page_view.cc @@ -103,9 +103,7 @@ void ContentFilterPageView::InitControlLayout() { 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 || - CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableCookiePrompt)) { + 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); |