blob: 40d859c2dd232654188b126d5422e8ab8b6b1d47 [file] [log] [blame]
// Copyright 2018 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 "base/macros.h"
#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
#include "content/public/browser/web_contents_user_data.h"
using ImageType = ContentSettingImageModel::ImageType;
// Class that keeps track of the tab-specific state associated with each
// ContentSettingImageModel. Each tab will have one instance of this class,
// which keeps track of states for each ImageType.
class ContentSettingImageModelStates
: public content::WebContentsUserData<ContentSettingImageModelStates> {
~ContentSettingImageModelStates() override;
static ContentSettingImageModelStates* Get(content::WebContents* contents);
void SetAnimationHasRun(ImageType type, bool animation_has_run);
bool AnimationHasRun(ImageType type) const;
friend class content::WebContentsUserData<ContentSettingImageModelStates>;
explicit ContentSettingImageModelStates(content::WebContents* contents);
// ImageTypes are used for direct access into a raw array, use this method to
// CHECK that everything is in-bounds.
void VerifyType(ImageType type) const;
// Array of bool for whether an animation has run for a given image model.
// This bit is reset to false when the image is hidden.
bool animations_[static_cast<int>(ImageType::NUM_IMAGE_TYPES)] = {};