Commit 567984c5 authored by Patrick Monette's avatar Patrick Monette Committed by Commit Bot

Fix formatting/lint issues in content setting model files.

Fixes include:
- Include what you use
- Running "git cl format"
- Reordering classes to be consistent

Change-Id: I197eb04cb84babe0f91aa47a7f4792c6289d92ee
Reviewed-on: https://chromium-review.googlesource.com/780019
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521145}
parent fa26960a
......@@ -41,8 +41,7 @@ class RapporServiceImpl;
// The hierarchy of bubble models:
//
// ContentSettingsBubbleModel - base class
// ContentSettingMediaStreamBubbleModel - media (camera and mic)
// ContentSettingBubbleModel - base class
// ContentSettingSimpleBubbleModel - single content setting
// ContentSettingMixedScriptBubbleModel - mixed script
// ContentSettingRPHBubbleModel - protocol handlers
......@@ -52,13 +51,14 @@ class RapporServiceImpl;
// ContentSettingSingleRadioGroup - radio group
// ContentSettingCookiesBubbleModel - cookies
// ContentSettingPopupBubbleModel - popups
// ContentSettingMediaStreamBubbleModel - media (camera and mic)
// ContentSettingSubresourceFilterBubbleModel - filtered subresources
// ContentSettingDownloadsBubbleModel - automatic downloads
// ContentSettingFramebustBlockBubbleModel - blocked framebusts
// Forward declaration necessary for downcasts.
class ContentSettingMediaStreamBubbleModel;
class ContentSettingSimpleBubbleModel;
class ContentSettingMediaStreamBubbleModel;
class ContentSettingSubresourceFilterBubbleModel;
class ContentSettingDownloadsBubbleModel;
class ContentSettingFramebustBlockBubbleModel;
......@@ -155,6 +155,8 @@ class ContentSettingBubbleModel : public content::NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(BubbleContent);
};
static const int kAllowButtonIndex;
// Creates a bubble model for a particular |content_type|. Note that not all
// bubbles fit this description.
// TODO(msramek): Move this to ContentSettingSimpleBubbleModel or remove
......@@ -217,8 +219,6 @@ class ContentSettingBubbleModel : public content::NotificationObserver {
rappor_service_ = rappor_service;
}
static const int kAllowButtonIndex;
protected:
ContentSettingBubbleModel(
Delegate* delegate,
......@@ -340,33 +340,6 @@ class ContentSettingRPHBubbleModel : public ContentSettingSimpleBubbleModel {
DISALLOW_COPY_AND_ASSIGN(ContentSettingRPHBubbleModel);
};
// The model for the deceptive content bubble.
class ContentSettingSubresourceFilterBubbleModel
: public ContentSettingBubbleModel {
public:
ContentSettingSubresourceFilterBubbleModel(Delegate* delegate,
content::WebContents* web_contents,
Profile* profile);
~ContentSettingSubresourceFilterBubbleModel() override;
private:
void SetMessage();
void SetTitle();
void SetManageText();
// ContentSettingBubbleModel:
void OnManageCheckboxChecked(bool is_checked) override;
ContentSettingSubresourceFilterBubbleModel* AsSubresourceFilterBubbleModel()
override;
void OnLearnMoreClicked() override;
void OnDoneClicked() override;
bool is_checked_ = false;
DISALLOW_COPY_AND_ASSIGN(ContentSettingSubresourceFilterBubbleModel);
};
// The model of the content settings bubble for media settings.
class ContentSettingMediaStreamBubbleModel : public ContentSettingBubbleModel {
public:
......@@ -426,6 +399,33 @@ class ContentSettingMediaStreamBubbleModel : public ContentSettingBubbleModel {
DISALLOW_COPY_AND_ASSIGN(ContentSettingMediaStreamBubbleModel);
};
// The model for the deceptive content bubble.
class ContentSettingSubresourceFilterBubbleModel
: public ContentSettingBubbleModel {
public:
ContentSettingSubresourceFilterBubbleModel(Delegate* delegate,
content::WebContents* web_contents,
Profile* profile);
~ContentSettingSubresourceFilterBubbleModel() override;
private:
void SetMessage();
void SetTitle();
void SetManageText();
// ContentSettingBubbleModel:
void OnManageCheckboxChecked(bool is_checked) override;
ContentSettingSubresourceFilterBubbleModel* AsSubresourceFilterBubbleModel()
override;
void OnLearnMoreClicked() override;
void OnDoneClicked() override;
bool is_checked_ = false;
DISALLOW_COPY_AND_ASSIGN(ContentSettingSubresourceFilterBubbleModel);
};
// The model for automatic downloads setting.
class ContentSettingDownloadsBubbleModel : public ContentSettingBubbleModel {
public:
......
......@@ -4,6 +4,9 @@
#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
#include <string>
#include <utility>
#include "base/feature_list.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
......@@ -65,30 +68,14 @@ class ContentSettingGeolocationImageModel
DISALLOW_COPY_AND_ASSIGN(ContentSettingGeolocationImageModel);
};
// Image model for displaying media icons in the location bar.
class ContentSettingMediaImageModel : public ContentSettingImageModel {
public:
ContentSettingMediaImageModel();
void UpdateFromWebContents(WebContents* web_contents) override;
ContentSettingBubbleModel* CreateBubbleModel(
ContentSettingBubbleModel::Delegate* delegate,
WebContents* web_contents,
Profile* profile) override;
bool ShouldRunAnimation(WebContents* web_contents) override;
void SetAnimationHasRun(WebContents* web_contents) override;
private:
DISALLOW_COPY_AND_ASSIGN(ContentSettingMediaImageModel);
};
class ContentSettingRPHImageModel : public ContentSettingSimpleImageModel {
public:
ContentSettingRPHImageModel();
void UpdateFromWebContents(WebContents* web_contents) override;
private:
DISALLOW_COPY_AND_ASSIGN(ContentSettingRPHImageModel);
};
class ContentSettingMIDISysExImageModel
......@@ -112,6 +99,25 @@ class ContentSettingDownloadsImageModel
DISALLOW_COPY_AND_ASSIGN(ContentSettingDownloadsImageModel);
};
// Image model for displaying media icons in the location bar.
class ContentSettingMediaImageModel : public ContentSettingImageModel {
public:
ContentSettingMediaImageModel();
void UpdateFromWebContents(WebContents* web_contents) override;
ContentSettingBubbleModel* CreateBubbleModel(
ContentSettingBubbleModel::Delegate* delegate,
WebContents* web_contents,
Profile* profile) override;
bool ShouldRunAnimation(WebContents* web_contents) override;
void SetAnimationHasRun(WebContents* web_contents) override;
private:
DISALLOW_COPY_AND_ASSIGN(ContentSettingMediaImageModel);
};
namespace {
struct ContentSettingsImageDetails {
......@@ -335,6 +341,101 @@ void ContentSettingGeolocationImageModel::UpdateFromWebContents(
: IDS_GEOLOCATION_BLOCKED_TOOLTIP));
}
// Protocol handlers -----------------------------------------------------------
ContentSettingRPHImageModel::ContentSettingRPHImageModel()
: ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) {
set_icon(vector_icons::kProtocolHandlerIcon, gfx::kNoneIcon);
set_tooltip(l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP));
}
void ContentSettingRPHImageModel::UpdateFromWebContents(
WebContents* web_contents) {
set_visible(false);
if (!web_contents)
return;
TabSpecificContentSettings* content_settings =
TabSpecificContentSettings::FromWebContents(web_contents);
if (!content_settings)
return;
if (content_settings->pending_protocol_handler().IsEmpty())
return;
set_visible(true);
}
// MIDI SysEx ------------------------------------------------------------------
ContentSettingMIDISysExImageModel::ContentSettingMIDISysExImageModel()
: ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {}
void ContentSettingMIDISysExImageModel::UpdateFromWebContents(
WebContents* web_contents) {
set_visible(false);
if (!web_contents)
return;
TabSpecificContentSettings* content_settings =
TabSpecificContentSettings::FromWebContents(web_contents);
if (!content_settings)
return;
const ContentSettingsUsagesState& usages_state =
content_settings->midi_usages_state();
if (usages_state.state_map().empty())
return;
set_visible(true);
// If any embedded site has access the allowed icon takes priority over the
// blocked icon.
unsigned int state_flags = 0;
usages_state.GetDetailedInfo(nullptr, &state_flags);
bool allowed =
!!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED);
set_icon(vector_icons::kMidiIcon,
allowed ? gfx::kNoneIcon : kBlockedBadgeIcon);
set_tooltip(l10n_util::GetStringUTF16(allowed
? IDS_MIDI_SYSEX_ALLOWED_TOOLTIP
: IDS_MIDI_SYSEX_BLOCKED_TOOLTIP));
}
// Automatic downloads ---------------------------------------------------------
ContentSettingDownloadsImageModel::ContentSettingDownloadsImageModel()
: ContentSettingSimpleImageModel(
CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) {}
void ContentSettingDownloadsImageModel::UpdateFromWebContents(
WebContents* web_contents) {
set_visible(false);
if (!web_contents)
return;
DownloadRequestLimiter* download_request_limiter =
g_browser_process->download_request_limiter();
// DownloadRequestLimiter can be absent in unit_tests.
if (!download_request_limiter)
return;
switch (download_request_limiter->GetDownloadUiStatus(web_contents)) {
case DownloadRequestLimiter::DOWNLOAD_UI_ALLOWED:
set_visible(true);
set_icon(kFileDownloadIcon, gfx::kNoneIcon);
set_explanatory_string_id(0);
set_tooltip(l10n_util::GetStringUTF16(IDS_ALLOWED_DOWNLOAD_TITLE));
return;
case DownloadRequestLimiter::DOWNLOAD_UI_BLOCKED:
set_visible(true);
set_icon(kFileDownloadIcon, kBlockedBadgeIcon);
set_explanatory_string_id(IDS_BLOCKED_DOWNLOADS_EXPLANATION);
set_tooltip(l10n_util::GetStringUTF16(IDS_BLOCKED_DOWNLOAD_TITLE));
return;
case DownloadRequestLimiter::DOWNLOAD_UI_DEFAULT:
// No need to show icon otherwise.
return;
}
}
// Media -----------------------------------------------------------------------
ContentSettingMediaImageModel::ContentSettingMediaImageModel()
......@@ -474,7 +575,6 @@ void ContentSettingSubresourceFilterImageModel::SetAnimationHasRun(
}
// Blocked Framebust -----------------------------------------------------------
ContentSettingFramebustBlockImageModel::ContentSettingFramebustBlockImageModel()
: ContentSettingImageModel() {}
......@@ -518,102 +618,6 @@ void ContentSettingFramebustBlockImageModel::SetAnimationHasRun(
->set_animation_has_run();
}
// Protocol handlers -----------------------------------------------------------
ContentSettingRPHImageModel::ContentSettingRPHImageModel()
: ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) {
set_icon(vector_icons::kProtocolHandlerIcon, gfx::kNoneIcon);
set_tooltip(l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_TOOLTIP));
}
void ContentSettingRPHImageModel::UpdateFromWebContents(
WebContents* web_contents) {
set_visible(false);
if (!web_contents)
return;
TabSpecificContentSettings* content_settings =
TabSpecificContentSettings::FromWebContents(web_contents);
if (!content_settings)
return;
if (content_settings->pending_protocol_handler().IsEmpty())
return;
set_visible(true);
}
// MIDI SysEx ------------------------------------------------------------------
ContentSettingMIDISysExImageModel::ContentSettingMIDISysExImageModel()
: ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
}
void ContentSettingMIDISysExImageModel::UpdateFromWebContents(
WebContents* web_contents) {
set_visible(false);
if (!web_contents)
return;
TabSpecificContentSettings* content_settings =
TabSpecificContentSettings::FromWebContents(web_contents);
if (!content_settings)
return;
const ContentSettingsUsagesState& usages_state =
content_settings->midi_usages_state();
if (usages_state.state_map().empty())
return;
set_visible(true);
// If any embedded site has access the allowed icon takes priority over the
// blocked icon.
unsigned int state_flags = 0;
usages_state.GetDetailedInfo(nullptr, &state_flags);
bool allowed =
!!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED);
set_icon(vector_icons::kMidiIcon,
allowed ? gfx::kNoneIcon : kBlockedBadgeIcon);
set_tooltip(l10n_util::GetStringUTF16(allowed
? IDS_MIDI_SYSEX_ALLOWED_TOOLTIP
: IDS_MIDI_SYSEX_BLOCKED_TOOLTIP));
}
// Automatic downloads ---------------------------------------------------------
ContentSettingDownloadsImageModel::ContentSettingDownloadsImageModel()
: ContentSettingSimpleImageModel(
CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) {}
void ContentSettingDownloadsImageModel::UpdateFromWebContents(
WebContents* web_contents) {
set_visible(false);
if (!web_contents)
return;
DownloadRequestLimiter* download_request_limiter =
g_browser_process->download_request_limiter();
// DownloadRequestLimiter can be absent in unit_tests.
if (!download_request_limiter)
return;
switch (download_request_limiter->GetDownloadUiStatus(web_contents)) {
case DownloadRequestLimiter::DOWNLOAD_UI_ALLOWED:
set_visible(true);
set_icon(kFileDownloadIcon, gfx::kNoneIcon);
set_explanatory_string_id(0);
set_tooltip(l10n_util::GetStringUTF16(IDS_ALLOWED_DOWNLOAD_TITLE));
return;
case DownloadRequestLimiter::DOWNLOAD_UI_BLOCKED:
set_visible(true);
set_icon(kFileDownloadIcon, kBlockedBadgeIcon);
set_explanatory_string_id(IDS_BLOCKED_DOWNLOADS_EXPLANATION);
set_tooltip(l10n_util::GetStringUTF16(IDS_BLOCKED_DOWNLOAD_TITLE));
return;
case DownloadRequestLimiter::DOWNLOAD_UI_DEFAULT:
// No need to show icon otherwise.
return;
}
}
// Base class ------------------------------------------------------------------
gfx::Image ContentSettingImageModel::GetIcon(SkColor icon_color) const {
......
......@@ -5,6 +5,9 @@
#ifndef CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_
#define CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_
#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
......
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