Commit 3c058026 authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Add intermediary step for cookie controls UI

Show a page explaining the effect of third-party cookie blocking.

https://screenshot.googleplex.com/pWGgd3OzxK8.png

Bug: 967668
Change-Id: I3f2167c455ac4ef3a4600f0d4483783bae95a763
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1835365
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704116}
parent 741bbcc2
...@@ -2509,6 +2509,12 @@ are declared in tools/grit/grit_rule.gni. ...@@ -2509,6 +2509,12 @@ are declared in tools/grit/grit_rule.gni.
<message name="IDS_COOKIE_CONTROLS_TURN_OFF_BUTTON" desc="Label shown on a button that turns off cookie blocking for a specific site."> <message name="IDS_COOKIE_CONTROLS_TURN_OFF_BUTTON" desc="Label shown on a button that turns off cookie blocking for a specific site.">
Turn off for this site Turn off for this site
</message> </message>
<message name="IDS_COOKIE_CONTROLS_NOT_WORKING_TITLE" desc="Label shown on a dialog that allows users to turn off third-party cookie blocking for a specific site.">
Site not working?
</message>
<message name="IDS_COOKIE_CONTROLS_NOT_WORKING_DESCRIPTION" desc="Label shown on a dialog that allows users to turn off third-party cookie blocking for a specific site.">
Some sites use third-party cookies to load their pages. If a site isn't working, you can try turning off cookie blocking.
</message>
<message name="IDS_COOKIE_CONTROLS_BLOCKED_MESSAGE" desc="Text shown in the dialog that allows users to control cookie blocking. Shows the number of sites for which cookies have been blocked."> <message name="IDS_COOKIE_CONTROLS_BLOCKED_MESSAGE" desc="Text shown in the dialog that allows users to control cookie blocking. Shows the number of sites for which cookies have been blocked.">
{COUNT, plural, {COUNT, plural,
=0 {This site doesn't use cookies for cross-site tracking} =0 {This site doesn't use cookies for cross-site tracking}
......
55ec4ca6ba6aab18bf86f0b48b708e781a507e28
\ No newline at end of file
55ec4ca6ba6aab18bf86f0b48b708e781a507e28
\ No newline at end of file
...@@ -26,8 +26,11 @@ class CookieControlsController { ...@@ -26,8 +26,11 @@ class CookieControlsController {
public: public:
enum class Status { enum class Status {
kUninitialized, kUninitialized,
// Cookie blocking is enabled.
kEnabled, kEnabled,
// Cookie blocking is disabled.
kDisabled, kDisabled,
// Cookie blocking is enabled in general but was disabled for this site.
kDisabledForSite, kDisabledForSite,
}; };
......
...@@ -6,11 +6,13 @@ ...@@ -6,11 +6,13 @@
#define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_COOKIE_CONTROLS_BUBBLE_VIEW_H_ #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_COOKIE_CONTROLS_BUBBLE_VIEW_H_
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h"
#include "chrome/browser/ui/cookie_controls/cookie_controls_controller.h" #include "chrome/browser/ui/cookie_controls/cookie_controls_controller.h"
#include "chrome/browser/ui/cookie_controls/cookie_controls_view.h" #include "chrome/browser/ui/cookie_controls/cookie_controls_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.h" #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.h"
#include "components/content_settings/core/browser/cookie_settings.h" #include "components/content_settings/core/browser/cookie_settings.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
#include "ui/views/controls/link_listener.h"
namespace content { namespace content {
class WebContents; class WebContents;
...@@ -19,11 +21,12 @@ class WebContents; ...@@ -19,11 +21,12 @@ class WebContents;
namespace views { namespace views {
class ImageView; class ImageView;
class Label; class Label;
class Link;
} // namespace views } // namespace views
// View used to display the cookie controls ui. // View used to display the cookie controls ui.
class CookieControlsBubbleView : public LocationBarBubbleDelegateView, class CookieControlsBubbleView : public LocationBarBubbleDelegateView,
public views::ButtonListener, public views::LinkListener,
public CookieControlsView { public CookieControlsView {
public: public:
static void ShowBubble(views::View* anchor_view, static void ShowBubble(views::View* anchor_view,
...@@ -44,38 +47,40 @@ class CookieControlsBubbleView : public LocationBarBubbleDelegateView, ...@@ -44,38 +47,40 @@ class CookieControlsBubbleView : public LocationBarBubbleDelegateView,
CookieControlsController* cookie_contols); CookieControlsController* cookie_contols);
~CookieControlsBubbleView() override; ~CookieControlsBubbleView() override;
void UpdateUi(CookieControlsController::Status status, void UpdateUi();
bool has_blocked_cookies);
// LocationBarBubbleDelegateView: // LocationBarBubbleDelegateView:
void CloseBubble() override; void CloseBubble() override;
int GetDialogButtons() const override; int GetDialogButtons() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
void Init() override; void Init() override;
base::string16 GetWindowTitle() const override;
std::unique_ptr<views::View> CreateExtraView() override;
bool ShouldShowWindowTitle() const override; bool ShouldShowWindowTitle() const override;
bool ShouldShowCloseButton() const override; bool ShouldShowCloseButton() const override;
void WindowClosing() override; void WindowClosing() override;
bool Accept() override;
bool Close() override;
gfx::Size CalculatePreferredSize() const override;
void AddedToWidget() override;
// views::ButtonListener: // views::LinkListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void LinkClicked(views::Link* source, int event_flags) override;
// Singleton instance of the cookie bubble. The cookie bubble can only be
// shown on the active browser window, so there is no case in which it will be
// shown twice at the same time.
static CookieControlsBubbleView* cookie_bubble_;
CookieControlsController* controller_ = nullptr; CookieControlsController* controller_ = nullptr;
CookieControlsController::Status status_ = CookieControlsController::Status status_ =
CookieControlsController::Status::kUninitialized; CookieControlsController::Status::kUninitialized;
int blocked_cookies_ = -1; // If true, display an intermediate step with a button to disable cookie
// blocking on the current site.
bool show_disable_cookie_blocking_ui_ = false;
base::Optional<int> blocked_cookies_;
views::ImageView* header_image_ = nullptr; views::ImageView* header_view_ = nullptr;
views::Button* turn_on_button_ = nullptr; views::Label* text_ = nullptr;
views::Button* turn_off_button_ = nullptr; views::Link* not_working_link_ = nullptr;
views::Label* title_ = nullptr;
views::Label* sub_title_ = nullptr;
views::View* spacer_ = nullptr;
ScopedObserver<CookieControlsController, CookieControlsView> observer_{this}; ScopedObserver<CookieControlsController, CookieControlsView> observer_{this};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment