diff options
author | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-30 00:36:59 +0000 |
---|---|---|
committer | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-30 00:36:59 +0000 |
commit | efe3ddc3dde5349e50a96bd445a0d6569215a139 (patch) | |
tree | 156a7fc4a72e8a1d7ff087eed99652d3f0c2eb09 | |
parent | 7c7b711b565a4a8ec54ad1df76d1945dd451e2cd (diff) | |
download | chromium_src-efe3ddc3dde5349e50a96bd445a0d6569215a139.zip chromium_src-efe3ddc3dde5349e50a96bd445a0d6569215a139.tar.gz chromium_src-efe3ddc3dde5349e50a96bd445a0d6569215a139.tar.bz2 |
Fix for "New blocked popup UI" on Windows
Changes:
1. new sets of strings indicating animation in chrome/browser/content_setting_image_model.cc - non-NULL id indicated that the situation is animated.
2. TabSpecificContentSettings has indicator that the new blockage occured, and was/was not messaged to the user.
3. ContentSettingImageView on Windows/ChromeOs is descended from LinearAnimation to allow animation of the popup indicator to the user.
BUG=39260
TEST=Mocks
Review URL: http://codereview.chromium.org/3120034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67630 0039d316-1c4b-4281-b951-d872f2087c98
14 files changed, 254 insertions, 24 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 78d0daa..3e73738 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -2432,6 +2432,9 @@ each locale. --> <message name="IDS_BLOCKED_POPUPS_LINK" desc="Link to popups section of content blocking management dialog, displayed in bubble when a page tries to display popups."> Manage pop-up blocking... </message> + <message name="IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT" desc="Explanatory animated text that appears (and then disappears) in the address line when popup is blocked"> + Pop-up blocked + </message> <message name="IDS_BLOCKED_JAVASCRIPT_TITLE" desc="Tooltip and bubble info header text when a page is not allowed to run JavaScript."> JavaScript was blocked on this page. </message> diff --git a/chrome/browser/cocoa/location_bar/content_setting_decoration.h b/chrome/browser/cocoa/location_bar/content_setting_decoration.h index d54db31..7e8904b5 100644 --- a/chrome/browser/cocoa/location_bar/content_setting_decoration.h +++ b/chrome/browser/cocoa/location_bar/content_setting_decoration.h @@ -27,7 +27,7 @@ class ContentSettingDecoration : public ImageDecoration { // Updates the image and visibility state based on the supplied TabContents. // Returns true if the decoration's visible state changed. - bool UpdateFromTabContents(const TabContents* tab_contents); + bool UpdateFromTabContents(TabContents* tab_contents); // Overridden from |LocationBarDecoration| virtual bool AcceptsMousePress() { return true; } diff --git a/chrome/browser/cocoa/location_bar/content_setting_decoration.mm b/chrome/browser/cocoa/location_bar/content_setting_decoration.mm index cfce460..358669f 100644 --- a/chrome/browser/cocoa/location_bar/content_setting_decoration.mm +++ b/chrome/browser/cocoa/location_bar/content_setting_decoration.mm @@ -41,7 +41,7 @@ ContentSettingDecoration::~ContentSettingDecoration() { } bool ContentSettingDecoration::UpdateFromTabContents( - const TabContents* tab_contents) { + TabContents* tab_contents) { bool was_visible = IsVisible(); int old_icon = content_setting_image_model_->get_icon(); content_setting_image_model_->UpdateFromTabContents(tab_contents); diff --git a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm index 2f106ab..8c424ac 100644 --- a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm +++ b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm @@ -559,7 +559,7 @@ void LocationBarViewMac::PostNotification(NSString* notification) { bool LocationBarViewMac::RefreshContentSettingsDecorations() { const bool input_in_progress = toolbar_model_->input_in_progress(); - const TabContents* tab_contents = + TabContents* tab_contents = input_in_progress ? NULL : browser_->GetSelectedTabContents(); bool icons_updated = false; for (size_t i = 0; i < content_setting_decorations_.size(); ++i) { diff --git a/chrome/browser/content_setting_image_model.cc b/chrome/browser/content_setting_image_model.cc index 84d19cd..f392ec4 100644 --- a/chrome/browser/content_setting_image_model.cc +++ b/chrome/browser/content_setting_image_model.cc @@ -18,11 +18,13 @@ class ContentSettingBlockedImageModel : public ContentSettingImageModel { explicit ContentSettingBlockedImageModel( ContentSettingsType content_settings_type); - virtual void UpdateFromTabContents(const TabContents* tab_contents); + virtual void UpdateFromTabContents(TabContents* tab_contents); private: static const int kAccessedIconIDs[]; static const int kBlockedIconIDs[]; + static const int kBlockedExplanatoryTextIDs[]; + static const int kAccessedExplanatoryTextIDs[]; static const int kAccessedTooltipIDs[]; static const int kBlockedTooltipIDs[]; }; @@ -31,14 +33,14 @@ class ContentSettingGeolocationImageModel : public ContentSettingImageModel { public: ContentSettingGeolocationImageModel(); - virtual void UpdateFromTabContents(const TabContents* tab_contents); + virtual void UpdateFromTabContents(TabContents* tab_contents); }; class ContentSettingNotificationsImageModel : public ContentSettingImageModel { public: ContentSettingNotificationsImageModel(); - virtual void UpdateFromTabContents(const TabContents* tab_contents); + virtual void UpdateFromTabContents(TabContents* tab_contents); }; const int ContentSettingBlockedImageModel::kBlockedIconIDs[] = { @@ -57,6 +59,23 @@ const int ContentSettingBlockedImageModel::kAccessedIconIDs[] = { 0, }; +const int ContentSettingBlockedImageModel::kBlockedExplanatoryTextIDs[] = { + 0, + 0, + 0, + 0, + IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT, +}; + +const int ContentSettingBlockedImageModel::kAccessedExplanatoryTextIDs[] = { + 0, + 0, + 0, + 0, + 0, +}; + + const int ContentSettingBlockedImageModel::kBlockedTooltipIDs[] = { IDS_BLOCKED_COOKIES_TITLE, IDS_BLOCKED_IMAGES_TITLE, @@ -79,11 +98,12 @@ ContentSettingBlockedImageModel::ContentSettingBlockedImageModel( } void ContentSettingBlockedImageModel::UpdateFromTabContents( - const TabContents* tab_contents) { + TabContents* tab_contents) { TabSpecificContentSettings* content_settings = tab_contents ? tab_contents->GetTabSpecificContentSettings() : NULL; const int* icon_ids; const int* tooltip_ids; + const int* explanatory_string_ids; if (!content_settings) { set_visible(false); @@ -92,6 +112,7 @@ void ContentSettingBlockedImageModel::UpdateFromTabContents( if (content_settings->IsContentBlocked(get_content_settings_type())) { icon_ids = kBlockedIconIDs; tooltip_ids = kBlockedTooltipIDs; + explanatory_string_ids = kBlockedExplanatoryTextIDs; } else if (tab_contents->profile()->GetHostContentSettingsMap()-> GetDefaultContentSetting(get_content_settings_type()) == CONTENT_SETTING_BLOCK && @@ -100,11 +121,14 @@ void ContentSettingBlockedImageModel::UpdateFromTabContents( // accessed icon. icon_ids = kAccessedIconIDs; tooltip_ids = kAccessedTooltipIDs; + explanatory_string_ids = kAccessedExplanatoryTextIDs; } else { set_visible(false); return; } set_icon(icon_ids[get_content_settings_type()]); + set_explanatory_string_id( + explanatory_string_ids[get_content_settings_type()]); set_tooltip( l10n_util::GetStringUTF8(tooltip_ids[get_content_settings_type()])); set_visible(true); @@ -115,7 +139,7 @@ ContentSettingGeolocationImageModel::ContentSettingGeolocationImageModel() } void ContentSettingGeolocationImageModel::UpdateFromTabContents( - const TabContents* tab_contents) { + TabContents* tab_contents) { if (!tab_contents) { set_visible(false); return; @@ -147,7 +171,7 @@ ContentSettingNotificationsImageModel::ContentSettingNotificationsImageModel() } void ContentSettingNotificationsImageModel::UpdateFromTabContents( - const TabContents* tab_contents) { + TabContents* tab_contents) { // Notifications do not have a bubble. set_visible(false); } @@ -156,7 +180,8 @@ ContentSettingImageModel::ContentSettingImageModel( ContentSettingsType content_settings_type) : content_settings_type_(content_settings_type), is_visible_(false), - icon_(0) { + icon_(0), + explanatory_string_id_(0) { } // static diff --git a/chrome/browser/content_setting_image_model.h b/chrome/browser/content_setting_image_model.h index 2ea709a..3e6d5e8 100644 --- a/chrome/browser/content_setting_image_model.h +++ b/chrome/browser/content_setting_image_model.h @@ -24,25 +24,32 @@ class ContentSettingImageModel { // Notifies this model that its setting might have changed and it may need to // update its visibility, icon and tooltip. - virtual void UpdateFromTabContents(const TabContents* tab_contents) = 0; + virtual void UpdateFromTabContents(TabContents* tab_contents) = 0; ContentSettingsType get_content_settings_type() const { return content_settings_type_; } bool is_visible() const { return is_visible_; } int get_icon() const { return icon_; } + // Returns the resource ID of a string to show when the icon appears, or 0 if + // we don't wish to show anything. + int explanatory_string_id() const { return explanatory_string_id_; } std::string get_tooltip() const { return tooltip_; } protected: explicit ContentSettingImageModel(ContentSettingsType content_settings_type); void set_visible(bool visible) { is_visible_ = visible; } void set_icon(int icon) { icon_ = icon; } + void set_explanatory_string_id(int text_id) { + explanatory_string_id_ = text_id; + } void set_tooltip(const std::string& tooltip) { tooltip_ = tooltip; } private: const ContentSettingsType content_settings_type_; bool is_visible_; int icon_; + int explanatory_string_id_; std::string tooltip_; }; diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc index ac56c15..6447df6 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/gtk/location_bar_view_gtk.cc @@ -652,7 +652,7 @@ void LocationBarViewGtk::FocusSearch() { } void LocationBarViewGtk::UpdateContentSettingsIcons() { - const TabContents* tab_contents = GetTabContents(); + TabContents* tab_contents = GetTabContents(); bool any_visible = false; for (ScopedVector<ContentSettingImageViewGtk>::iterator i( content_setting_views_.begin()); @@ -1267,7 +1267,7 @@ LocationBarViewGtk::ContentSettingImageViewGtk::~ContentSettingImageViewGtk() { } void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromTabContents( - const TabContents* tab_contents) { + TabContents* tab_contents) { content_setting_image_model_->UpdateFromTabContents(tab_contents); if (content_setting_image_model_->is_visible()) { gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h index 77e4134..566886f 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.h +++ b/chrome/browser/gtk/location_bar_view_gtk.h @@ -156,7 +156,7 @@ class LocationBarViewGtk : public AutocompleteEditController, void set_profile(Profile* profile) { profile_ = profile; } bool IsVisible() { return GTK_WIDGET_VISIBLE(widget()); } - void UpdateFromTabContents(const TabContents* tab_contents); + void UpdateFromTabContents(TabContents* tab_contents); private: CHROMEGTK_CALLBACK_1(ContentSettingImageViewGtk, gboolean, OnButtonPressed, diff --git a/chrome/browser/tab_contents/tab_specific_content_settings.cc b/chrome/browser/tab_contents/tab_specific_content_settings.cc index 62f3646..22550ea 100644 --- a/chrome/browser/tab_contents/tab_specific_content_settings.cc +++ b/chrome/browser/tab_contents/tab_specific_content_settings.cc @@ -40,6 +40,16 @@ bool TabSpecificContentSettings::IsContentBlocked( return false; } +bool TabSpecificContentSettings::IsBlockageIndicated( + ContentSettingsType content_type) const { + return content_blockage_indicated_to_user_[content_type]; +} + +void TabSpecificContentSettings::SetBlockageHasBeenIndicated( + ContentSettingsType content_type) { + content_blockage_indicated_to_user_[content_type] = true; +} + bool TabSpecificContentSettings::IsContentAccessed( ContentSettingsType content_type) const { // This method currently only returns meaningful values for cookies. @@ -197,6 +207,7 @@ void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { blocked_resources_[i].reset(); content_blocked_[i] = false; content_accessed_[i] = false; + content_blockage_indicated_to_user_[i] = false; } load_plugins_link_enabled_ = true; if (delegate_) @@ -208,12 +219,14 @@ void TabSpecificContentSettings::ClearCookieSpecificContentSettings() { allowed_local_shared_objects_.Reset(); content_blocked_[CONTENT_SETTINGS_TYPE_COOKIES] = false; content_accessed_[CONTENT_SETTINGS_TYPE_COOKIES] = false; + content_blockage_indicated_to_user_[CONTENT_SETTINGS_TYPE_COOKIES] = false; if (delegate_) delegate_->OnContentSettingsAccessed(false); } void TabSpecificContentSettings::SetPopupsBlocked(bool blocked) { content_blocked_[CONTENT_SETTINGS_TYPE_POPUPS] = blocked; + content_blockage_indicated_to_user_[CONTENT_SETTINGS_TYPE_POPUPS] = false; if (delegate_) delegate_->OnContentSettingsAccessed(blocked); } diff --git a/chrome/browser/tab_contents/tab_specific_content_settings.h b/chrome/browser/tab_contents/tab_specific_content_settings.h index a5030ed..26685d1 100644 --- a/chrome/browser/tab_contents/tab_specific_content_settings.h +++ b/chrome/browser/tab_contents/tab_specific_content_settings.h @@ -64,6 +64,11 @@ class TabSpecificContentSettings // page. bool IsContentBlocked(ContentSettingsType content_type) const; + // Returns true if content blockage was indicated to the user. + bool IsBlockageIndicated(ContentSettingsType content_type) const; + + void SetBlockageHasBeenIndicated(ContentSettingsType content_type); + // Returns whether a particular kind of content has been accessed. Currently // only tracks cookies. bool IsContentAccessed(ContentSettingsType content_type) const; @@ -160,6 +165,9 @@ class TabSpecificContentSettings // Stores which content setting types actually have blocked content. bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; + // Stores if the blocked content was messaged to the user. + bool content_blockage_indicated_to_user_[CONTENT_SETTINGS_NUM_TYPES]; + // Stores which content setting types actually were accessed. bool content_accessed_[CONTENT_SETTINGS_NUM_TYPES]; diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc index 2ddb4b0..7115f15 100644 --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc @@ -2,9 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/views/location_bar/content_setting_image_view.h" +#include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" +#include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "base/command_line.h" #include "base/utf_string_conversions.h" #include "chrome/browser/content_setting_bubble_model.h" #include "chrome/browser/content_setting_image_model.h" @@ -12,17 +14,51 @@ #include "chrome/browser/tab_contents_wrapper.h" #include "chrome/browser/views/content_setting_bubble_contents.h" #include "chrome/browser/views/location_bar/location_bar_view.h" +#include "chrome/common/chrome_switches.h" +#include "gfx/canvas.h" +#include "gfx/canvas_skia.h" +#include "gfx/skia_util.h" +#include "third_party/skia/include/core/SkShader.h" +#include "views/border.h" + +namespace { +// Animation parameters. +const int kOpenTimeMs = 150; +const int kFullOpenedTimeMs = 3200; +const int kMoveTimeMs = kFullOpenedTimeMs + 2 * kOpenTimeMs; +const int kFrameRateHz = 60; +// Colors for the animated box. +const SkColor kTopBoxColor = SkColorSetRGB(0xff, 0xf8, 0xd4); +const SkColor kBottomBoxColor = SkColorSetRGB(0xff, 0xe6, 0xaf); +const SkColor kBorderColor = SkColorSetRGB(0xe9, 0xb9, 0x66); +// Corner radius of the animated box. +const SkScalar kBoxCornerRadius = 2; +// Margins for animated box. +const int kTextMarginPixels = 4; +const int kIconLeftMargin = 4; + + +// The fraction of the animation we'll spend animating the string into view, and +// then again animating it closed - total animation (slide out, show, then +// slide in) is 1.0. +const double kAnimatingFraction = kOpenTimeMs * 1.0 / kMoveTimeMs; +} ContentSettingImageView::ContentSettingImageView( ContentSettingsType content_type, - const LocationBarView* parent, + LocationBarView* parent, Profile* profile) - : content_setting_image_model_( + : LinearAnimation(kMoveTimeMs, kFrameRateHz, NULL), + content_setting_image_model_( ContentSettingImageModel::CreateContentSettingImageModel( content_type)), parent_(parent), profile_(profile), - info_bubble_(NULL) { + info_bubble_(NULL), + animation_in_progress_(false), + text_size_(0), + visible_text_size_(0) { + SetHorizontalAlignment(ImageView::LEADING); } ContentSettingImageView::~ContentSettingImageView() { @@ -30,8 +66,7 @@ ContentSettingImageView::~ContentSettingImageView() { info_bubble_->Close(); } -void ContentSettingImageView::UpdateFromTabContents( - const TabContents* tab_contents) { +void ContentSettingImageView::UpdateFromTabContents(TabContents* tab_contents) { int old_icon = content_setting_image_model_->get_icon(); content_setting_image_model_->UpdateFromTabContents(tab_contents); if (!content_setting_image_model_->is_visible()) { @@ -44,6 +79,46 @@ void ContentSettingImageView::UpdateFromTabContents( } SetTooltipText(UTF8ToWide(content_setting_image_model_->get_tooltip())); SetVisible(true); + + TabSpecificContentSettings* content_settings = tab_contents ? + tab_contents->GetTabSpecificContentSettings() : NULL; + if (!content_settings || content_settings->IsBlockageIndicated( + content_setting_image_model_->get_content_settings_type())) + return; + + // The content blockage was not yet indicated to the user. Start indication + // animation and clear "not yet shown" flag. + content_settings->SetBlockageHasBeenIndicated( + content_setting_image_model_->get_content_settings_type()); + + int animated_string_id = + content_setting_image_model_->explanatory_string_id(); + // Check if the animation is enabled and if the string for animation is + // available. + if (!CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableBlockContentAnimation) || !animated_string_id) + return; + + // Do not start animation if already in progress. + if (!animation_in_progress_) { + animation_in_progress_ = true; + // Initialize animated string. It will be cleared when animation is + // completed. + animated_text_ = l10n_util::GetString(animated_string_id); + text_size_ = ResourceBundle::GetSharedInstance().GetFont( + ResourceBundle::MediumFont).GetStringWidth(animated_text_); + text_size_ += 2 * kTextMarginPixels + kIconLeftMargin; + if (border()) + border()->GetInsets(&saved_insets_); + Start(); + } +} + +gfx::Size ContentSettingImageView::GetPreferredSize() { + gfx::Size preferred_size(views::ImageView::GetPreferredSize()); + // When view is animated visible_text_size_ > 0, it is 0 otherwise. + preferred_size.set_width(preferred_size.width() + visible_text_size_); + return preferred_size; } bool ContentSettingImageView::OnMousePressed(const views::MouseEvent& event) { @@ -82,6 +157,64 @@ void ContentSettingImageView::VisibilityChanged(View* starting_from, info_bubble_->Close(); } +void ContentSettingImageView::Paint(gfx::Canvas* canvas) { + gfx::Insets current_insets; + if (border()) + border()->GetInsets(¤t_insets); + // During the animation we draw a border, an icon and the text. The text area + // is changing in size during the animation, giving the appearance of the text + // sliding out and then back in. When the text completely slid out the yellow + // border is no longer painted around the icon. |visible_text_size_| is 0 when + // animation is stopped. + int necessary_left_margin = std::min(kIconLeftMargin, visible_text_size_); + if (necessary_left_margin != current_insets.left() - saved_insets_.left()) { + // In the non-animated state borders' left() is 0, in the animated state it + // is the kIconLeftMargin, so we need to animate border reduction when it + // starts to disappear. + views::Border* empty_border = views::Border::CreateEmptyBorder( + saved_insets_.top(), + saved_insets_.left() + necessary_left_margin, + saved_insets_.bottom(), + saved_insets_.right()); + set_border(empty_border); + } + // Paint an icon with possibly non-empty left border. + views::ImageView::Paint(canvas); + if (animation_in_progress_) { + // Paint text to the right of the icon. + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + canvas->DrawStringInt(animated_text_, + rb.GetFont(ResourceBundle::MediumFont), SK_ColorBLACK, + GetImageBounds().right() + kTextMarginPixels, y(), + width() - GetImageBounds().width(), height(), + gfx::Canvas::TEXT_ALIGN_LEFT | gfx::Canvas::TEXT_VALIGN_MIDDLE); + } +} + +void ContentSettingImageView::PaintBackground(gfx::Canvas* canvas) { + if (!animation_in_progress_) { + views::ImageView::PaintBackground(canvas); + return; + } + // Paint yellow gradient background if in animation mode. + const int kEdgeThickness = 1; + SkPaint paint; + paint.setShader(gfx::CreateGradientShader(kEdgeThickness, + height() - (2 * kEdgeThickness), + kTopBoxColor, kBottomBoxColor))->safeUnref(); + SkRect color_rect; + color_rect.iset(0, 0, width() - 1, height() - 1); + canvas->AsCanvasSkia()->drawRoundRect(color_rect, kBoxCornerRadius, + kBoxCornerRadius, paint); + SkPaint outer_paint; + outer_paint.setStyle(SkPaint::kStroke_Style); + outer_paint.setColor(kBorderColor); + color_rect.inset(SkIntToScalar(kEdgeThickness), + SkIntToScalar(kEdgeThickness)); + canvas->AsCanvasSkia()->drawRoundRect(color_rect, kBoxCornerRadius, + kBoxCornerRadius, outer_paint); +} + void ContentSettingImageView::InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape) { info_bubble_ = NULL; @@ -91,3 +224,21 @@ bool ContentSettingImageView::CloseOnEscape() { return true; } +void ContentSettingImageView::AnimateToState(double state) { + if (state >= 1.0) { + // Animaton is over, clear the variables. + animation_in_progress_ = false; + visible_text_size_ = 0; + } else if (state < kAnimatingFraction) { + visible_text_size_ = static_cast<int>(text_size_ * state / + kAnimatingFraction); + } else if (state > (1.0 - kAnimatingFraction)) { + visible_text_size_ = static_cast<int>(text_size_ * (1.0 - state) / + kAnimatingFraction); + } else { + visible_text_size_ = text_size_; + } + parent_->Layout(); + parent_->SchedulePaint(); +} + diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.h b/chrome/browser/ui/views/location_bar/content_setting_image_view.h index 8180c72..297aadb 100644 --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.h +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ #pragma once +#include "app/linear_animation.h" #include "base/scoped_ptr.h" #include "chrome/browser/views/info_bubble.h" #include "chrome/common/content_settings_types.h" @@ -22,21 +23,29 @@ class MouseEvent; } class ContentSettingImageView : public views::ImageView, - public InfoBubbleDelegate { + public InfoBubbleDelegate, + public LinearAnimation { public: ContentSettingImageView(ContentSettingsType content_type, - const LocationBarView* parent, + LocationBarView* parent, Profile* profile); virtual ~ContentSettingImageView(); void set_profile(Profile* profile) { profile_ = profile; } - void UpdateFromTabContents(const TabContents* tab_contents); + // |new_navigation| true if this is a new navigation, false if the tab was + // just switched to. + void UpdateFromTabContents(TabContents* tab_contents); + + // views::View overrides: + virtual gfx::Size GetPreferredSize(); private: // views::ImageView overrides: virtual bool OnMousePressed(const views::MouseEvent& event); virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); virtual void VisibilityChanged(View* starting_from, bool is_visible); + virtual void Paint(gfx::Canvas* canvas); + virtual void PaintBackground(gfx::Canvas* canvas); // InfoBubbleDelegate overrides: virtual void InfoBubbleClosing(InfoBubble* info_bubble, @@ -44,10 +53,13 @@ class ContentSettingImageView : public views::ImageView, virtual bool CloseOnEscape(); virtual bool FadeInOnShow() { return false; } + // LinearAnimation override: + virtual void AnimateToState(double state); + scoped_ptr<ContentSettingImageModel> content_setting_image_model_; // The owning LocationBarView. - const LocationBarView* parent_; + LocationBarView* parent_; // The currently active profile. Profile* profile_; @@ -55,6 +67,12 @@ class ContentSettingImageView : public views::ImageView, // The currently shown info bubble if any. InfoBubble* info_bubble_; + std::wstring animated_text_; + bool animation_in_progress_; + int text_size_; + int visible_text_size_; + gfx::Insets saved_insets_; + DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingImageView); }; diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 3e7ffc1..9606559 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -408,6 +408,10 @@ const char kEnableBackgroundMode[] = "enable-background-mode"; // Enables the benchmarking extensions. const char kEnableBenchmarking[] = "enable-benchmarking"; +// Enables blocked content warning animation. Currently shows animation for +// blocked pop-ups only. +const char kEnableBlockContentAnimation[] = "enable-blocked-content-animation"; + // Enable experimental client-side detection of phishing pages. const char kEnableClientSidePhishingDetection[] = "enable-client-side-phishing-detection"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 17c1d55..edfff8a 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -124,6 +124,7 @@ extern const char kEnableAppLauncher[]; extern const char kEnableAuthNegotiatePort[]; extern const char kEnableBackgroundMode[]; extern const char kEnableBenchmarking[]; +extern const char kEnableBlockContentAnimation[]; extern const char kEnableClientSidePhishingDetection[]; extern const char kEnableClearServerData[]; extern const char kEnableClickToPlay[]; |