diff options
author | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 11:40:08 +0000 |
---|---|---|
committer | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 11:40:08 +0000 |
commit | 352104ee28f47810b5d2dc5fd6193c60d2cd2e95 (patch) | |
tree | 1d4d26928b9951a3d5f54688c550835740849837 /chrome | |
parent | ff039f0833a278d7ca80aeb8987e73b6c258f305 (diff) | |
download | chromium_src-352104ee28f47810b5d2dc5fd6193c60d2cd2e95.zip chromium_src-352104ee28f47810b5d2dc5fd6193c60d2cd2e95.tar.gz chromium_src-352104ee28f47810b5d2dc5fd6193c60d2cd2e95.tar.bz2 |
Renames ContentBlockedImageView to ContentSettingImageView.
Adds ContentSettingImageModel to provide icon and tooltips for platform-specific ContentBlockedImageView.
(in preparation for:
http://codereview.chromium.org/650180/show
)
TEST=chrome/browser/content_setting_image_model_unittest.cc
Review URL: http://codereview.chromium.org/660279
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40732 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser.cc | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/autocomplete_text_field_cell.h | 6 | ||||
-rw-r--r-- | chrome/browser/cocoa/autocomplete_text_field_cell.mm | 16 | ||||
-rw-r--r-- | chrome/browser/cocoa/location_bar_view_mac.h | 30 | ||||
-rw-r--r-- | chrome/browser/cocoa/location_bar_view_mac.mm | 103 | ||||
-rw-r--r-- | chrome/browser/content_setting_image_model.cc | 64 | ||||
-rw-r--r-- | chrome/browser/content_setting_image_model.h | 46 | ||||
-rw-r--r-- | chrome/browser/content_setting_image_model_unittest.cc | 31 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_toolbar_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/location_bar_view_gtk.cc | 108 | ||||
-rw-r--r-- | chrome/browser/gtk/location_bar_view_gtk.h | 33 | ||||
-rw-r--r-- | chrome/browser/location_bar.h | 4 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.cc | 103 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.h | 26 | ||||
-rwxr-xr-x | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 | ||||
-rw-r--r-- | chrome/test/test_location_bar.h | 2 |
17 files changed, 348 insertions, 231 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 0399a49..40d1072 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -2191,7 +2191,7 @@ void Browser::ContentsZoomChange(bool zoom_in) { void Browser::OnBlockedContentChange(TabContents* source) { if (source == GetSelectedTabContents()) - window_->GetLocationBar()->UpdateContentBlockedIcons(); + window_->GetLocationBar()->UpdateContentSettingsIcons(); } void Browser::SetTabContentBlocked(TabContents* contents, bool blocked) { diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.h b/chrome/browser/cocoa/autocomplete_text_field_cell.h index 3763e2c..1da806f 100644 --- a/chrome/browser/cocoa/autocomplete_text_field_cell.h +++ b/chrome/browser/cocoa/autocomplete_text_field_cell.h @@ -55,7 +55,7 @@ class ExtensionAction; LocationBarViewMac::PageActionViewList* page_action_views_; // List of content blocked icons. This may be NULL during testing. - LocationBarViewMac::ContentBlockedViews* content_blocked_views_; + LocationBarViewMac::ContentSettingViews* content_setting_views_; } // Chooses |partialString| if |width| won't fit |fullString|. Strings @@ -79,8 +79,8 @@ class ExtensionAction; - (void)setSecurityImageView:(LocationBarViewMac::SecurityImageView*)view; - (void)setPageActionViewList:(LocationBarViewMac::PageActionViewList*)list; -- (void)setContentBlockedViewList: - (LocationBarViewMac::ContentBlockedViews*)views; +- (void)setContentSettingViewsList: + (LocationBarViewMac::ContentSettingViews*)views; // Returns an array of the visible AutocompleteTextFieldIcon objects. Returns // only visible icons. diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.mm b/chrome/browser/cocoa/autocomplete_text_field_cell.mm index 89b5f99..2b5600a 100644 --- a/chrome/browser/cocoa/autocomplete_text_field_cell.mm +++ b/chrome/browser/cocoa/autocomplete_text_field_cell.mm @@ -217,9 +217,9 @@ CGFloat WidthForKeyword(NSAttributedString* keywordString) { security_image_view_ = view; } -- (void)setContentBlockedViewList: - (LocationBarViewMac::ContentBlockedViews*)views { - content_blocked_views_ = views; +- (void)setContentSettingViewsList: + (LocationBarViewMac::ContentSettingViews*)views { + content_setting_views_ = views; } // Overriden to account for the hint strings and hint icons. @@ -430,13 +430,13 @@ CGFloat WidthForKeyword(NSAttributedString* keywordString) { } } - if (content_blocked_views_) { + if (content_setting_views_) { // We use a reverse_iterator here because we're laying out the views from // right to left but in the vector they're ordered left to right. - for (LocationBarViewMac::ContentBlockedViews::const_reverse_iterator - it(content_blocked_views_->rbegin()); - it != const_cast<const LocationBarViewMac::ContentBlockedViews*>( - content_blocked_views_)->rend(); + for (LocationBarViewMac::ContentSettingViews::const_reverse_iterator + it(content_setting_views_->rbegin()); + it != const_cast<const LocationBarViewMac::ContentSettingViews*>( + content_setting_views_)->rend(); ++it) { if ((*it)->IsVisible()) { NSImage* image = (*it)->GetImage(); diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h index 75241f8..9f376e6 100644 --- a/chrome/browser/cocoa/location_bar_view_mac.h +++ b/chrome/browser/cocoa/location_bar_view_mac.h @@ -25,6 +25,7 @@ @class AutocompleteTextField; class BubblePositioner; class CommandUpdater; +class ContentSettingImageModel; @class ExtensionPopupController; class Profile; class ToolbarModel; @@ -55,7 +56,7 @@ class LocationBarViewMac : public AutocompleteEditController, virtual void AcceptInputWithDisposition(WindowOpenDisposition disposition); virtual void FocusLocation(); virtual void FocusSearch(); - virtual void UpdateContentBlockedIcons(); + virtual void UpdateContentSettingsIcons(); virtual void UpdatePageActions(); virtual void InvalidatePageActions(); virtual void SaveStateToContents(TabContents* contents); @@ -306,20 +307,20 @@ class LocationBarViewMac : public AutocompleteEditController, DISALLOW_COPY_AND_ASSIGN(PageActionImageView); }; - // ContentBlockedImageView is used to display the content settings images - // when types of contents are blocked on the current page. - class ContentBlockedImageView : public LocationBarImageView { + // ContentSettingImageView is used to display the content settings images + // on the current page. + class ContentSettingImageView : public LocationBarImageView { public: - ContentBlockedImageView(ContentSettingsType settings_type, + ContentSettingImageView(ContentSettingsType settings_type, LocationBarViewMac* owner, Profile* profile); - virtual ~ContentBlockedImageView(); + virtual ~ContentSettingImageView(); // Shows a content settings bubble. void OnMousePressed(NSRect bounds); - // Returns the settings type this shows up for. - ContentSettingsType settings_type() { return settings_type_; } + // Updates the image and visibility state based on the supplied TabContents. + void UpdateFromTabContents(const TabContents* tab_contents); // Returns the tooltip for this Page Action image or |nil| if there is none. virtual const NSString* GetToolTip(); @@ -327,16 +328,15 @@ class LocationBarViewMac : public AutocompleteEditController, private: void SetToolTip(NSString* tooltip); - // The type of content handled by this view. - ContentSettingsType settings_type_; + scoped_ptr<ContentSettingImageModel> content_setting_image_model_; LocationBarViewMac* owner_; Profile* profile_; scoped_nsobject<NSString> tooltip_; - DISALLOW_COPY_AND_ASSIGN(ContentBlockedImageView); + DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView); }; - typedef ScopedVector<ContentBlockedImageView> ContentBlockedViews; + typedef ScopedVector<ContentSettingImageView> ContentSettingViews; class PageActionViewList { public: @@ -386,9 +386,9 @@ class LocationBarViewMac : public AutocompleteEditController, // Posts |notification| to the default notification center. void PostNotification(const NSString* notification); - // Updates visibility of the content blocked icons based on the current + // Updates visibility of the content settings icons based on the current // tab contents state. - void RefreshContentBlockedViews(); + void RefreshContentSettingsViews(); scoped_ptr<AutocompleteEditViewMac> edit_view_; @@ -411,7 +411,7 @@ class LocationBarViewMac : public AutocompleteEditController, PageActionViewList page_action_views_; // The content blocked views. - ContentBlockedViews content_blocked_views_; + ContentSettingViews content_setting_views_; Profile* profile_; diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm index 854fd45..3229f45 100644 --- a/chrome/browser/cocoa/location_bar_view_mac.mm +++ b/chrome/browser/cocoa/location_bar_view_mac.mm @@ -22,6 +22,7 @@ #import "chrome/browser/cocoa/extensions/extension_action_context_menu.h" #import "chrome/browser/cocoa/extensions/extension_popup_controller.h" #include "chrome/browser/command_updater.h" +#include "chrome/browser/content_setting_image_model.h" #include "chrome/browser/extensions/extension_browser_event_router.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/extensions/extension_tabs_module.h" @@ -105,17 +106,17 @@ LocationBarViewMac::LocationBarViewMac( toolbar_model_(toolbar_model), transition_(PageTransition::TYPED) { for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { - ContentBlockedImageView* content_blocked_view = - new ContentBlockedImageView(static_cast<ContentSettingsType>(i), this, + ContentSettingImageView* content_setting_view = + new ContentSettingImageView(static_cast<ContentSettingsType>(i), this, profile_); - content_blocked_views_.push_back(content_blocked_view); - content_blocked_view->SetVisible(false); + content_setting_views_.push_back(content_setting_view); + content_setting_view->SetVisible(false); } AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; [cell setSecurityImageView:&security_image_view_]; [cell setPageActionViewList:&page_action_views_]; - [cell setContentBlockedViewList:&content_blocked_views_]; + [cell setContentSettingViewsList:&content_setting_views_]; registrar_.Add(this, NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, @@ -166,8 +167,8 @@ void LocationBarViewMac::FocusSearch() { edit_view_->SetForcedQuery(); } -void LocationBarViewMac::UpdateContentBlockedIcons() { - RefreshContentBlockedViews(); +void LocationBarViewMac::UpdateContentSettingsIcons() { + RefreshContentSettingsViews(); [field_ updateCursorAndToolTipRects]; [field_ setNeedsDisplay:YES]; } @@ -204,7 +205,7 @@ void LocationBarViewMac::Update(const TabContents* contents, bool should_restore_state) { SetSecurityIcon(toolbar_model_->GetIcon()); page_action_views_.RefreshViews(); - RefreshContentBlockedViews(); + RefreshContentSettingsViews(); // AutocompleteEditView restores state if the tab is non-NULL. edit_view_->Update(should_restore_state ? contents : NULL); } @@ -515,13 +516,13 @@ void LocationBarViewMac::PostNotification(const NSString* notification) { object:[NSValue valueWithPointer:this]]; } -void LocationBarViewMac::RefreshContentBlockedViews() { +void LocationBarViewMac::RefreshContentSettingsViews() { const TabContents* tab_contents = browser_->GetSelectedTabContents(); - for (ContentBlockedViews::iterator it(content_blocked_views_.begin()); - it != content_blocked_views_.end(); + for (ContentSettingViews::iterator it(content_setting_views_.begin()); + it != content_setting_views_.end(); ++it) { - (*it)->SetVisible((!toolbar_model_->input_in_progress() && tab_contents) ? - tab_contents->IsContentBlocked((*it)->settings_type()) : false); + (*it)->UpdateFromTabContents( + toolbar_model_->input_in_progress() ? NULL : tab_contents); } } @@ -823,43 +824,20 @@ void LocationBarViewMac::PageActionImageView::Observe( } // ContentSettingsImageView----------------------------------------------------- - -LocationBarViewMac::ContentBlockedImageView::ContentBlockedImageView( +LocationBarViewMac::ContentSettingImageView::ContentSettingImageView( ContentSettingsType settings_type, LocationBarViewMac* owner, Profile* profile) - : settings_type_(settings_type), + : content_setting_image_model_( + ContentSettingImageModel::CreateContentSettingImageModel( + settings_type)), owner_(owner), profile_(profile) { - // TODO(thakis): We should use pdfs for these icons on OSX. - // http://crbug.com/35847 - static const int kIconIDs[] = { - IDR_BLOCKED_COOKIES, - IDR_BLOCKED_IMAGES, - IDR_BLOCKED_JAVASCRIPT, - IDR_BLOCKED_PLUGINS, - IDR_BLOCKED_POPUPS, - }; - DCHECK_EQ(arraysize(kIconIDs), - static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES)); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - SetImage(rb.GetNSImageNamed(kIconIDs[settings_type])); - - static const int kTooltipIDs[] = { - IDS_BLOCKED_COOKIES_TITLE, - IDS_BLOCKED_IMAGES_TITLE, - IDS_BLOCKED_JAVASCRIPT_TITLE, - IDS_BLOCKED_PLUGINS_TITLE, - IDS_BLOCKED_POPUPS_TOOLTIP, - }; - DCHECK_EQ(arraysize(kTooltipIDs), - static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES)); - SetToolTip(l10n_util::GetNSStringWithFixup(kTooltipIDs[settings_type])); -} - -LocationBarViewMac::ContentBlockedImageView::~ContentBlockedImageView() {} - -void LocationBarViewMac::ContentBlockedImageView::OnMousePressed(NSRect bounds) +} + +LocationBarViewMac::ContentSettingImageView::~ContentSettingImageView() {} + +void LocationBarViewMac::ContentSettingImageView::OnMousePressed(NSRect bounds) { // Get host. This should be shared shared on linux/win/osx medium-term. TabContents* tabContents = @@ -880,20 +858,37 @@ void LocationBarViewMac::ContentBlockedImageView::OnMousePressed(NSRect bounds) // Open bubble. NSPoint anchor = NSMakePoint(NSMidX(bounds) + 1, NSMinY(bounds)); - [[ContentBlockedBubbleController showForType:settings_type_ - parentWindow:window - anchoredAt:anchor - host:url.host() - displayHost:base::SysWideToNSString(displayHost) - tabContents:tabContents - profile:profile_] showWindow:nil]; + [[ContentBlockedBubbleController + showForType:content_setting_image_model_->get_content_settings_type() + parentWindow:window + anchoredAt:anchor + host:url.host() + displayHost:base::SysWideToNSString(displayHost) + tabContents:tabContents + profile:profile_] showWindow:nil]; } -const NSString* LocationBarViewMac::ContentBlockedImageView::GetToolTip() { +const NSString* LocationBarViewMac::ContentSettingImageView::GetToolTip() { return tooltip_.get(); } -void LocationBarViewMac::ContentBlockedImageView::SetToolTip(NSString* tooltip) +void LocationBarViewMac::ContentSettingImageView::UpdateFromTabContents( + const TabContents* tab_contents) { + content_setting_image_model_->UpdateFromTabContents(tab_contents); + if (content_setting_image_model_->is_visible()) { + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + // TODO(thakis): We should use pdfs for these icons on OSX. + // http://crbug.com/35847 + SetImage(rb.GetNSImageNamed(content_setting_image_model_->get_icon())); + SetToolTip(base::SysUTF8ToNSString( + content_setting_image_model_->get_tooltip())); + SetVisible(true); + } else { + SetVisible(false); + } +} + +void LocationBarViewMac::ContentSettingImageView::SetToolTip(NSString* tooltip) { tooltip_.reset([tooltip retain]); } diff --git a/chrome/browser/content_setting_image_model.cc b/chrome/browser/content_setting_image_model.cc new file mode 100644 index 0000000..96430f7 --- /dev/null +++ b/chrome/browser/content_setting_image_model.cc @@ -0,0 +1,64 @@ +// 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/content_setting_image_model.h" + +#include "app/l10n_util.h" +#include "chrome/browser/tab_contents/tab_contents.h" +#include "grit/generated_resources.h" +#include "grit/theme_resources.h" + +class ContentSettingBlockedImageModel : public ContentSettingImageModel { + public: + explicit ContentSettingBlockedImageModel( + ContentSettingsType content_settings_type) + : ContentSettingImageModel(content_settings_type) { + } + + virtual void UpdateFromTabContents(const TabContents* tab_contents) { + if (tab_contents && + tab_contents->IsContentBlocked(get_content_settings_type())) { + set_icon(kBlockedIconIDs[get_content_settings_type()]); + set_tooltip( + l10n_util::GetStringUTF8(kTooltipIDs[get_content_settings_type()])); + set_visible(true); + } else { + set_visible(false); + } + } + + private: + static const int kBlockedIconIDs[]; + static const int kTooltipIDs[]; + +}; + +ContentSettingImageModel::ContentSettingImageModel( + ContentSettingsType content_settings_type) + : content_settings_type_(content_settings_type), + is_visible_(false), + icon_(0) { +} + +// static +ContentSettingImageModel* ContentSettingImageModel:: + CreateContentSettingImageModel(ContentSettingsType content_settings_type) { + return new ContentSettingBlockedImageModel(content_settings_type); +} + +const int ContentSettingBlockedImageModel::kBlockedIconIDs[] = { + IDR_BLOCKED_COOKIES, + IDR_BLOCKED_IMAGES, + IDR_BLOCKED_JAVASCRIPT, + IDR_BLOCKED_PLUGINS, + IDR_BLOCKED_POPUPS, +}; + +const int ContentSettingBlockedImageModel::kTooltipIDs[] = { + IDS_BLOCKED_COOKIES_TITLE, + IDS_BLOCKED_IMAGES_TITLE, + IDS_BLOCKED_JAVASCRIPT_TITLE, + IDS_BLOCKED_PLUGINS_TITLE, + IDS_BLOCKED_POPUPS_TOOLTIP, +}; diff --git a/chrome/browser/content_setting_image_model.h b/chrome/browser/content_setting_image_model.h new file mode 100644 index 0000000..f5d5a66 --- /dev/null +++ b/chrome/browser/content_setting_image_model.h @@ -0,0 +1,46 @@ +// 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_CONTENT_SETTING_IMAGE_MODEL_H_ +#define CHROME_BROWSER_CONTENT_SETTING_IMAGE_MODEL_H_ + +#include <string> + +#include "chrome/common/content_settings_types.h" + +class TabContents; + +// This model provides data (icon ids and tooltip) for the content setting icons +// that are displayed in the location bar. +class ContentSettingImageModel { + public: + // Factory function. + static ContentSettingImageModel* CreateContentSettingImageModel( + ContentSettingsType content_settings_type); + + // 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; + + ContentSettingsType get_content_settings_type() const { + return content_settings_type_; + } + bool is_visible() const { return is_visible_; } + int get_icon() const { return icon_; } + 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_tooltip(const std::string& tooltip) { tooltip_ = tooltip; } + + private: + const ContentSettingsType content_settings_type_; + bool is_visible_; + int icon_; + std::string tooltip_; +}; + +#endif // CHROME_BROWSER_CONTENT_SETTING_IMAGE_MODEL_H_ diff --git a/chrome/browser/content_setting_image_model_unittest.cc b/chrome/browser/content_setting_image_model_unittest.cc new file mode 100644 index 0000000..e399617 --- /dev/null +++ b/chrome/browser/content_setting_image_model_unittest.cc @@ -0,0 +1,31 @@ +// 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/content_setting_image_model.h" + +#include "chrome/browser/profile.h" +#include "chrome/browser/renderer_host/test/test_render_view_host.h" +#include "chrome/browser/tab_contents/test_tab_contents.h" +#include "chrome/test/testing_profile.h" +#include "testing/gtest/include/gtest/gtest.h" + +typedef RenderViewHostTestHarness ContentSettingImageModelTest; + +TEST_F(ContentSettingImageModelTest, UpdateFromTabContents) { + TestTabContents tab_contents(profile_.get(), NULL); + RenderViewHostDelegate::Resource* render_view_host_delegate = &tab_contents; + scoped_ptr<ContentSettingImageModel> content_setting_image_model( + ContentSettingImageModel::CreateContentSettingImageModel( + CONTENT_SETTINGS_TYPE_IMAGES)); + EXPECT_FALSE(content_setting_image_model->is_visible()); + EXPECT_EQ(0, content_setting_image_model->get_icon()); + EXPECT_EQ("", content_setting_image_model->get_tooltip()); + + render_view_host_delegate->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES); + content_setting_image_model->UpdateFromTabContents(&tab_contents); + + EXPECT_TRUE(content_setting_image_model->is_visible()); + EXPECT_NE(0, content_setting_image_model->get_icon()); + EXPECT_NE("", content_setting_image_model->get_tooltip()); +} diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc index 9df751f..08ef507 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_toolbar_gtk.cc @@ -248,7 +248,7 @@ void BrowserToolbarGtk::Init(Profile* profile, // Because the above does a recursive show all on all widgets we need to // update the icon visibility to hide them. - location_bar_->UpdateContentBlockedIcons(); + location_bar_->UpdateContentSettingsIcons(); SetViewIDs(); } diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc index b622115..ed0cda4 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/gtk/location_bar_view_gtk.cc @@ -20,6 +20,7 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/command_updater.h" +#include "chrome/browser/content_setting_image_model.h" #include "chrome/browser/extensions/extension_accessibility_api_constants.h" #include "chrome/browser/extensions/extension_action_context_menu_model.h" #include "chrome/browser/extensions/extension_browser_event_router.h" @@ -170,7 +171,7 @@ LocationBarViewGtk::LocationBarViewGtk( LocationBarViewGtk::~LocationBarViewGtk() { // All of our widgets should have be children of / owned by the alignment. hbox_.Destroy(); - content_blocking_hbox_.Destroy(); + content_setting_hbox_.Destroy(); page_action_hbox_.Destroy(); } @@ -327,20 +328,19 @@ void LocationBarViewGtk::Init(bool popup_window_mode) { gtk_box_pack_end(GTK_BOX(hbox_.get()), security_icon_event_box_, FALSE, FALSE, 0); - content_blocking_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); - gtk_widget_set_name(content_blocking_hbox_.get(), - "chrome-content-blocking-hbox"); - gtk_box_pack_end(GTK_BOX(hbox_.get()), content_blocking_hbox_.get(), + content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); + gtk_widget_set_name(content_setting_hbox_.get(), + "chrome-content-setting-hbox"); + gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), FALSE, FALSE, 0); for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { - ContentBlockedViewGtk* content_blocked_view = - new ContentBlockedViewGtk(static_cast<ContentSettingsType>(i), this, - profile_); - content_blocked_views_.push_back(content_blocked_view); - gtk_box_pack_end(GTK_BOX(content_blocking_hbox_.get()), - content_blocked_view->widget(), FALSE, FALSE, 0); - content_blocked_view->SetVisible(false); + ContentSettingImageViewGtk* content_setting_view = + new ContentSettingImageViewGtk( + static_cast<ContentSettingsType>(i), this, profile_); + content_setting_views_.push_back(content_setting_view); + gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()), + content_setting_view->widget(), FALSE, FALSE, 0); } page_action_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); @@ -395,7 +395,7 @@ GtkWidget* LocationBarViewGtk::GetPageActionWidget( void LocationBarViewGtk::Update(const TabContents* contents) { SetSecurityIcon(toolbar_model_->GetIcon()); - UpdateContentBlockedIcons(); + UpdateContentSettingsIcons(); UpdatePageActions(); SetInfoText(); location_entry_->Update(contents); @@ -537,24 +537,23 @@ void LocationBarViewGtk::FocusSearch() { location_entry_->SetForcedQuery(); } -void LocationBarViewGtk::UpdateContentBlockedIcons() { +void LocationBarViewGtk::UpdateContentSettingsIcons() { const TabContents* tab_contents = GetTabContents(); bool any_visible = false; - for (ScopedVector<ContentBlockedViewGtk>::iterator i( - content_blocked_views_.begin()); - i != content_blocked_views_.end(); ++i) { - bool is_visible = (!toolbar_model_->input_in_progress() && tab_contents) ? - tab_contents->IsContentBlocked((*i)->content_type()) : false; - any_visible = is_visible || any_visible; - (*i)->SetVisible(is_visible); + for (ScopedVector<ContentSettingImageViewGtk>::iterator i( + content_setting_views_.begin()); + i != content_setting_views_.end(); ++i) { + (*i)->UpdateFromTabContents( + toolbar_model_->input_in_progress() ? NULL : tab_contents); + any_visible = (*i)->IsVisible() || any_visible; } // If there are no visible content things, hide the top level box so it // doesn't mess with padding. if (any_visible) - gtk_widget_show(content_blocking_hbox_.get()); + gtk_widget_show(content_setting_hbox_.get()); else - gtk_widget_hide(content_blocking_hbox_.get()); + gtk_widget_hide(content_setting_hbox_.get()); } void LocationBarViewGtk::UpdatePageActions() { @@ -952,12 +951,14 @@ void LocationBarViewGtk::AdjustChildrenVisibility() { } //////////////////////////////////////////////////////////////////////////////// -// LocationBarViewGtk::ContentBlockedViewGtk -LocationBarViewGtk::ContentBlockedViewGtk::ContentBlockedViewGtk( +// LocationBarViewGtk::ContentSettingImageViewGtk +LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk( ContentSettingsType content_type, const LocationBarViewGtk* parent, Profile* profile) - : content_type_(content_type), + : content_setting_image_model_( + ContentSettingImageModel::CreateContentSettingImageModel( + content_type)), parent_(parent), profile_(profile), info_bubble_(NULL) { @@ -970,35 +971,10 @@ LocationBarViewGtk::ContentBlockedViewGtk::ContentBlockedViewGtk( image_.Own(gtk_image_new()); gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get()); - - static const int kIconIDs[CONTENT_SETTINGS_NUM_TYPES] = { - IDR_BLOCKED_COOKIES, - IDR_BLOCKED_IMAGES, - IDR_BLOCKED_JAVASCRIPT, - IDR_BLOCKED_PLUGINS, - IDR_BLOCKED_POPUPS, - }; - DCHECK_EQ(arraysize(kIconIDs), - static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES)); - gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), - ResourceBundle::GetSharedInstance().GetPixbufNamed( - kIconIDs[content_type])); - - static const int kTooltipIDs[CONTENT_SETTINGS_NUM_TYPES] = { - IDS_BLOCKED_COOKIES_TITLE, - IDS_BLOCKED_IMAGES_TITLE, - IDS_BLOCKED_JAVASCRIPT_TITLE, - IDS_BLOCKED_PLUGINS_TITLE, - IDS_BLOCKED_POPUPS_TOOLTIP, - }; - DCHECK_EQ(arraysize(kTooltipIDs), - static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES)); - gtk_widget_set_tooltip_text( - widget(), - l10n_util::GetStringUTF8(kTooltipIDs[content_type_]).c_str()); + gtk_widget_hide(widget()); } -LocationBarViewGtk::ContentBlockedViewGtk::~ContentBlockedViewGtk() { +LocationBarViewGtk::ContentSettingImageViewGtk::~ContentSettingImageViewGtk() { image_.Destroy(); event_box_.Destroy(); @@ -1006,14 +982,25 @@ LocationBarViewGtk::ContentBlockedViewGtk::~ContentBlockedViewGtk() { info_bubble_->Close(); } -void LocationBarViewGtk::ContentBlockedViewGtk::SetVisible(bool visible) { - if (visible) +void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromTabContents( + const 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()) { + if (old_icon != content_setting_image_model_->get_icon()) { + gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), + ResourceBundle::GetSharedInstance().GetPixbufNamed( + content_setting_image_model_->get_icon())); + } + gtk_widget_set_tooltip_text(widget(), + content_setting_image_model_->get_tooltip().c_str()); gtk_widget_show(widget()); - else + } else { gtk_widget_hide(widget()); + } } -gboolean LocationBarViewGtk::ContentBlockedViewGtk::OnButtonPressed( +gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnButtonPressed( GtkWidget* sender, GdkEvent* event) { gfx::Rect bounds = gtk_util::GetWidgetRectRelativeToToplevel(sender); @@ -1030,12 +1017,13 @@ gboolean LocationBarViewGtk::ContentBlockedViewGtk::OnButtonPressed( GtkWindow* toplevel = GTK_WINDOW(gtk_widget_get_toplevel(sender)); info_bubble_ = new ContentBlockedBubbleGtk( - toplevel, bounds, this, content_type_, url.host(), display_host, profile_, - tab_contents); + toplevel, bounds, this, + content_setting_image_model_->get_content_settings_type(), url.host(), + display_host, profile_, tab_contents); return TRUE; } -void LocationBarViewGtk::ContentBlockedViewGtk::InfoBubbleClosing( +void LocationBarViewGtk::ContentSettingImageViewGtk::InfoBubbleClosing( InfoBubbleGtk* info_bubble, bool closed_by_escape) { info_bubble_ = NULL; diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h index dcd6a26..c0da0c7 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.h +++ b/chrome/browser/gtk/location_bar_view_gtk.h @@ -32,6 +32,7 @@ class BubblePositioner; class Browser; class CommandUpdater; class ContentBlockedBubbleGtk; +class ContentSettingImageModel; class ExtensionAction; class ExtensionActionContextMenuModel; class GtkThemeProvider; @@ -99,7 +100,7 @@ class LocationBarViewGtk : public AutocompleteEditController, virtual void AcceptInputWithDisposition(WindowOpenDisposition); virtual void FocusLocation(); virtual void FocusSearch(); - virtual void UpdateContentBlockedIcons(); + virtual void UpdateContentSettingsIcons(); virtual void UpdatePageActions(); virtual void InvalidatePageActions(); virtual void SaveStateToContents(TabContents* contents); @@ -126,25 +127,24 @@ class LocationBarViewGtk : public AutocompleteEditController, static const GdkColor kBackgroundColorByLevel[3]; private: - class ContentBlockedViewGtk : public InfoBubbleGtkDelegate { + class ContentSettingImageViewGtk : public InfoBubbleGtkDelegate { public: - ContentBlockedViewGtk(ContentSettingsType content_type, - const LocationBarViewGtk* parent, - Profile* profile); - virtual ~ContentBlockedViewGtk(); + ContentSettingImageViewGtk(ContentSettingsType content_type, + const LocationBarViewGtk* parent, + Profile* profile); + virtual ~ContentSettingImageViewGtk(); GtkWidget* widget() { return event_box_.get(); } - ContentSettingsType content_type() const { return content_type_; } void set_profile(Profile* profile) { profile_ = profile; } bool IsVisible() { return GTK_WIDGET_VISIBLE(widget()); } - void SetVisible(bool visible); + void UpdateFromTabContents(const TabContents* tab_contents); private: static gboolean OnButtonPressedThunk(GtkWidget* sender, GdkEvent* event, - ContentBlockedViewGtk* view) { + ContentSettingImageViewGtk* view) { return view->OnButtonPressed(sender, event); } gboolean OnButtonPressed(GtkWidget* sender, GdkEvent* event); @@ -153,13 +153,12 @@ class LocationBarViewGtk : public AutocompleteEditController, virtual void InfoBubbleClosing(InfoBubbleGtk* info_bubble, bool closed_by_escape); - // The widgets for this content blocked view. + scoped_ptr<ContentSettingImageModel> content_setting_image_model_; + + // The widgets for this content settings view. OwnedWidgetGtk event_box_; OwnedWidgetGtk image_; - // The type of content handled by this view. - ContentSettingsType content_type_; - // The owning LocationBarViewGtk. const LocationBarViewGtk* parent_; @@ -169,7 +168,7 @@ class LocationBarViewGtk : public AutocompleteEditController, // The currently shown info bubble if any. ContentBlockedBubbleGtk* info_bubble_; - DISALLOW_COPY_AND_ASSIGN(ContentBlockedViewGtk); + DISALLOW_COPY_AND_ASSIGN(ContentSettingImageViewGtk); }; class PageActionViewGtk : public ImageLoadingTracker::Observer { @@ -313,9 +312,9 @@ class LocationBarViewGtk : public AutocompleteEditController, // Toolbar info text (EV cert info). GtkWidget* info_label_; - // Content blocking icons. - OwnedWidgetGtk content_blocking_hbox_; - ScopedVector<ContentBlockedViewGtk> content_blocked_views_; + // Content setting icons. + OwnedWidgetGtk content_setting_hbox_; + ScopedVector<ContentSettingImageViewGtk> content_setting_views_; // Extension page action icons. OwnedWidgetGtk page_action_hbox_; diff --git a/chrome/browser/location_bar.h b/chrome/browser/location_bar.h index 9d0a49c..29bfddc 100644 --- a/chrome/browser/location_bar.h +++ b/chrome/browser/location_bar.h @@ -50,8 +50,8 @@ class LocationBar { // focus to it. virtual void FocusSearch() = 0; - // Updates the state of the images showing what content was blocked. - virtual void UpdateContentBlockedIcons() = 0; + // Updates the state of the images showing the content settings status. + virtual void UpdateContentSettingsIcons() = 0; // Updates the state of the page actions. virtual void UpdatePageActions() = 0; diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index 29ebabe..23c439b 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -20,6 +20,7 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/bubble_positioner.h" #include "chrome/browser/command_updater.h" +#include "chrome/browser/content_setting_image_model.h" #include "chrome/browser/extensions/extension_browser_event_router.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/profile.h" @@ -27,6 +28,7 @@ #include "chrome/browser/view_ids.h" #include "chrome/browser/views/extensions/extension_popup.h" #include "chrome/browser/views/content_blocked_bubble_contents.h" +#include "chrome/common/content_settings.h" #include "chrome/common/pref_names.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -222,10 +224,10 @@ void LocationBarView::Init() { security_image_view_.set_parent_owned(false); for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { - ContentBlockedImageView* content_blocked_view = - new ContentBlockedImageView(static_cast<ContentSettingsType>(i), this, + ContentSettingImageView* content_blocked_view = + new ContentSettingImageView(static_cast<ContentSettingsType>(i), this, profile_, bubble_positioner_); - content_blocked_views_.push_back(content_blocked_view); + content_setting_views_.push_back(content_blocked_view); AddChildView(content_blocked_view); content_blocked_view->SetVisible(false); } @@ -298,7 +300,7 @@ SkColor LocationBarView::GetColor(bool is_secure, ColorKind kind) { void LocationBarView::Update(const TabContents* tab_for_state_restoring) { SetSecurityIcon(model_->GetIcon()); - RefreshContentBlockedViews(); + RefreshContentSettingViews(); RefreshPageActionViews(); std::wstring info_text, info_tooltip; ToolbarModel::InfoTextType info_text_type = @@ -309,8 +311,8 @@ void LocationBarView::Update(const TabContents* tab_for_state_restoring) { SchedulePaint(); } -void LocationBarView::UpdateContentBlockedIcons() { - RefreshContentBlockedViews(); +void LocationBarView::UpdateContentSettingsIcons() { + RefreshContentSettingViews(); Layout(); SchedulePaint(); @@ -353,8 +355,8 @@ void LocationBarView::SetProfile(Profile* profile) { location_entry_->model()->SetProfile(profile); selected_keyword_view_.set_profile(profile); keyword_hint_view_.set_profile(profile); - for (ContentBlockedViews::const_iterator i(content_blocked_views_.begin()); - i != content_blocked_views_.end(); ++i) + for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); + i != content_setting_views_.end(); ++i) (*i)->set_profile(profile); security_image_view_.set_profile(profile); } @@ -545,8 +547,8 @@ void LocationBarView::DoLayout(const bool force_layout) { if ((*i)->IsVisible()) entry_width -= (*i)->GetPreferredSize().width() + kInnerPadding; } - for (ContentBlockedViews::const_iterator i(content_blocked_views_.begin()); - i != content_blocked_views_.end(); ++i) { + for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); + i != content_setting_views_.end(); ++i) { if ((*i)->IsVisible()) entry_width -= (*i)->GetPreferredSize().width() + kInnerPadding; } @@ -613,8 +615,8 @@ void LocationBarView::DoLayout(const bool force_layout) { } // We use a reverse_iterator here because we're laying out the views from // right to left but in the vector they're ordered left to right. - for (ContentBlockedViews::const_reverse_iterator - i(content_blocked_views_.rbegin()); i != content_blocked_views_.rend(); + for (ContentSettingViews::const_reverse_iterator + i(content_setting_views_.rbegin()); i != content_setting_views_.rend(); ++i) { if ((*i)->IsVisible()) { int content_blocked_width = (*i)->GetPreferredSize().width(); @@ -755,12 +757,12 @@ void LocationBarView::SetSecurityIcon(ToolbarModel::Icon icon) { } } -void LocationBarView::RefreshContentBlockedViews() { +void LocationBarView::RefreshContentSettingViews() { const TabContents* tab_contents = delegate_->GetTabContents(); - for (ContentBlockedViews::const_iterator i(content_blocked_views_.begin()); - i != content_blocked_views_.end(); ++i) { - (*i)->SetVisible((!model_->input_in_progress() && tab_contents) ? - tab_contents->IsContentBlocked((*i)->content_type()) : false); + for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); + i != content_setting_views_.end(); ++i) { + (*i)->UpdateFromTabContents( + model_->input_in_progress() ? NULL : tab_contents); } } @@ -1278,8 +1280,6 @@ void LocationBarView::LocationBarImageView::ShowInfoBubbleImpl( // static SkBitmap* LocationBarView::SecurityImageView::lock_icon_ = NULL; SkBitmap* LocationBarView::SecurityImageView::warning_icon_ = NULL; -SkBitmap* LocationBarView:: - ContentBlockedImageView::icons_[CONTENT_SETTINGS_NUM_TYPES] = { NULL }; LocationBarView::SecurityImageView::SecurityImageView( const LocationBarView* parent, @@ -1335,52 +1335,44 @@ void LocationBarView::SecurityImageView::ShowInfoBubble() { SECURITY_INFO_BUBBLE_TEXT)); } -// ContentBlockedImageView------------------------------------------------------ +// ContentSettingImageView------------------------------------------------------ -LocationBarView::ContentBlockedImageView::ContentBlockedImageView( +LocationBarView::ContentSettingImageView::ContentSettingImageView( ContentSettingsType content_type, const LocationBarView* parent, Profile* profile, const BubblePositioner* bubble_positioner) - : content_type_(content_type), + : content_setting_image_model_( + ContentSettingImageModel::CreateContentSettingImageModel( + content_type)), parent_(parent), profile_(profile), info_bubble_(NULL), bubble_positioner_(bubble_positioner) { - if (!icons_[CONTENT_SETTINGS_TYPE_COOKIES]) { - static const int kIconIDs[CONTENT_SETTINGS_NUM_TYPES] = { - IDR_BLOCKED_COOKIES, - IDR_BLOCKED_IMAGES, - IDR_BLOCKED_JAVASCRIPT, - IDR_BLOCKED_PLUGINS, - IDR_BLOCKED_POPUPS, - }; - DCHECK_EQ(arraysize(kIconIDs), - static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES)); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) - icons_[i] = rb.GetBitmapNamed(kIconIDs[i]); - } - SetImage(icons_[content_type_]); - - static const int kTooltipIDs[CONTENT_SETTINGS_NUM_TYPES] = { - IDS_BLOCKED_COOKIES_TITLE, - IDS_BLOCKED_IMAGES_TITLE, - IDS_BLOCKED_JAVASCRIPT_TITLE, - IDS_BLOCKED_PLUGINS_TITLE, - IDS_BLOCKED_POPUPS_TOOLTIP, - }; - DCHECK_EQ(arraysize(kTooltipIDs), - static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES)); - SetTooltipText(l10n_util::GetString(kTooltipIDs[content_type_])); } -LocationBarView::ContentBlockedImageView::~ContentBlockedImageView() { +LocationBarView::ContentSettingImageView::~ContentSettingImageView() { if (info_bubble_) info_bubble_->Close(); } -bool LocationBarView::ContentBlockedImageView::OnMousePressed( +void LocationBarView::ContentSettingImageView::UpdateFromTabContents( + const 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()) { + if (old_icon != content_setting_image_model_->get_icon()) { + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + SetImage(rb.GetBitmapNamed(content_setting_image_model_->get_icon())); + } + SetTooltipText(UTF8ToWide(content_setting_image_model_->get_tooltip())); + SetVisible(true); + } else { + SetVisible(false); + } +} + +bool LocationBarView::ContentSettingImageView::OnMousePressed( const views::MouseEvent& event) { gfx::Rect bounds(bubble_positioner_->GetLocationStackBounds()); gfx::Point location; @@ -1397,28 +1389,29 @@ bool LocationBarView::ContentBlockedImageView::OnMousePressed( profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), &display_host, NULL, NULL); ContentBlockedBubbleContents* bubble_contents = - new ContentBlockedBubbleContents(content_type_, url.host(), display_host, - profile_, tab_contents); + new ContentBlockedBubbleContents( + content_setting_image_model_->get_content_settings_type(), url.host(), + display_host, profile_, tab_contents); DCHECK(!info_bubble_); info_bubble_ = InfoBubble::Show(GetWindow(), bounds, bubble_contents, this); bubble_contents->set_info_bubble(info_bubble_); return true; } -void LocationBarView::ContentBlockedImageView::VisibilityChanged( +void LocationBarView::ContentSettingImageView::VisibilityChanged( View* starting_from, bool is_visible) { if (!is_visible && info_bubble_) info_bubble_->Close(); } -void LocationBarView::ContentBlockedImageView::InfoBubbleClosing( +void LocationBarView::ContentSettingImageView::InfoBubbleClosing( InfoBubble* info_bubble, bool closed_by_escape) { info_bubble_ = NULL; } -bool LocationBarView::ContentBlockedImageView::CloseOnEscape() { +bool LocationBarView::ContentSettingImageView::CloseOnEscape() { return true; } diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h index a48bb8e..6a3a383 100644 --- a/chrome/browser/views/location_bar_view.h +++ b/chrome/browser/views/location_bar_view.h @@ -36,6 +36,7 @@ class BubblePositioner; class CommandUpdater; +class ContentSettingImageModel; class ExtensionAction; class ExtensionPopup; class GURL; @@ -164,7 +165,7 @@ class LocationBarView : public LocationBar, virtual void AcceptInputWithDisposition(WindowOpenDisposition); virtual void FocusLocation(); virtual void FocusSearch(); - virtual void UpdateContentBlockedIcons(); + virtual void UpdateContentSettingsIcons(); virtual void UpdatePageActions(); virtual void InvalidatePageActions(); virtual void SaveStateToContents(TabContents* contents); @@ -364,17 +365,17 @@ class LocationBarView : public LocationBar, DISALLOW_COPY_AND_ASSIGN(SecurityImageView); }; - class ContentBlockedImageView : public views::ImageView, + class ContentSettingImageView : public views::ImageView, public InfoBubbleDelegate { public: - ContentBlockedImageView(ContentSettingsType content_type, + ContentSettingImageView(ContentSettingsType content_type, const LocationBarView* parent, Profile* profile, const BubblePositioner* bubble_positioner); - virtual ~ContentBlockedImageView(); + virtual ~ContentSettingImageView(); - ContentSettingsType content_type() const { return content_type_; } void set_profile(Profile* profile) { profile_ = profile; } + void UpdateFromTabContents(const TabContents* tab_contents); private: // views::ImageView overrides: @@ -386,10 +387,7 @@ class LocationBarView : public LocationBar, bool closed_by_escape); virtual bool CloseOnEscape(); - static SkBitmap* icons_[CONTENT_SETTINGS_NUM_TYPES]; - - // The type of content handled by this view. - ContentSettingsType content_type_; + scoped_ptr<ContentSettingImageModel> content_setting_image_model_; // The owning LocationBarView. const LocationBarView* parent_; @@ -404,9 +402,9 @@ class LocationBarView : public LocationBar, // caller maintains ownership of this and must ensure it's kept alive. const BubblePositioner* bubble_positioner_; - DISALLOW_IMPLICIT_CONSTRUCTORS(ContentBlockedImageView); + DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingImageView); }; - typedef std::vector<ContentBlockedImageView*> ContentBlockedViews; + typedef std::vector<ContentSettingImageView*> ContentSettingViews; // PageActionImageView is used to display the icon for a given PageAction // and notify the extension when the icon is clicked. @@ -552,7 +550,7 @@ class LocationBarView : public LocationBar, // Update the visibility state of the Content Blocked icons to reflect what is // actually blocked on the current page. - void RefreshContentBlockedViews(); + void RefreshContentSettingViews(); // Delete all page action views that we have created. void DeletePageActionViews(); @@ -632,8 +630,8 @@ class LocationBarView : public LocationBar, // The view that shows the lock/warning when in HTTPS mode. SecurityImageView security_image_view_; - // The content blocked views. - ContentBlockedViews content_blocked_views_; + // The content setting views. + ContentSettingViews content_setting_views_; // The page action icon views. PageActionViews page_action_views_; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index b80e0e7..310a9d8 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -743,6 +743,8 @@ 'browser/content_exceptions_table_model.h', 'browser/content_setting_combo_model.cc', 'browser/content_setting_combo_model.h', + 'browser/content_setting_image_model.cc', + 'browser/content_setting_image_model.h', 'browser/cookie_modal_dialog.cc', 'browser/cookie_modal_dialog.h', 'browser/cookie_modal_dialog_mac.mm', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 24a7a8b..b1da02d 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -565,6 +565,7 @@ 'browser/browser_theme_pack_unittest.cc', 'browser/browser_theme_provider_unittest.cc', 'browser/browser_unittest.cc', + 'browser/content_setting_image_model_unittest.cc', 'browser/chrome_browser_application_mac_unittest.mm', 'browser/debugger/devtools_remote_message_unittest.cc', 'browser/debugger/devtools_remote_listen_socket_unittest.cc', diff --git a/chrome/test/test_location_bar.h b/chrome/test/test_location_bar.h index e501dfb..f257d1ee 100644 --- a/chrome/test/test_location_bar.h +++ b/chrome/test/test_location_bar.h @@ -37,7 +37,7 @@ class TestLocationBar : public LocationBar { virtual void AcceptInputWithDisposition(WindowOpenDisposition) {} virtual void FocusLocation() {} virtual void FocusSearch() {} - virtual void UpdateContentBlockedIcons() {} + virtual void UpdateContentSettingsIcons() {} virtual void UpdatePageActions() {} virtual void InvalidatePageActions() {} virtual void SaveStateToContents(TabContents* contents) {} |