diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-30 19:55:17 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-30 19:55:17 +0000 |
commit | 1aa9e6ad9426c7a2c9051d92c6104cd1d25ea0af (patch) | |
tree | 56875ca6d8ec60d085d53ec676ec2da592a991db | |
parent | bebf8ceee960f5d93b63b99c240f2adc25836c79 (diff) | |
download | chromium_src-1aa9e6ad9426c7a2c9051d92c6104cd1d25ea0af.zip chromium_src-1aa9e6ad9426c7a2c9051d92c6104cd1d25ea0af.tar.gz chromium_src-1aa9e6ad9426c7a2c9051d92c6104cd1d25ea0af.tar.bz2 |
Revert 57877 - Hide page actions and star, like we already do for content settings, when the user is editing the omnibox.
BUG=none
TEST=Typing in the omnibox should make all items on the right disappear, and make ctrl-d do nothing.
Review URL: http://codereview.chromium.org/3218002
TBR=pkasting@chromium.org
Review URL: http://codereview.chromium.org/3264005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57894 0039d316-1c4b-4281-b951-d872f2087c98
5 files changed, 70 insertions, 83 deletions
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 9bc4d1d..28f524b 100644 --- a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm +++ b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm @@ -33,7 +33,6 @@ #include "chrome/browser/command_updater.h" #include "chrome/browser/content_setting_image_model.h" #include "chrome/browser/content_setting_bubble_model.h" -#include "chrome/browser/defaults.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" @@ -184,10 +183,6 @@ void LocationBarViewMac::SaveStateToContents(TabContents* contents) { void LocationBarViewMac::Update(const TabContents* contents, bool should_restore_state) { - bool star_enabled = browser_defaults::bookmarks_enabled && - [field_ isEditable] && !toolbar_model_->input_in_progress(); - command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); - star_decoration_->SetVisible(star_enabled); RefreshPageActionDecorations(); RefreshContentSettingsDecorations(); // AutocompleteEditView restores state if the tab is non-NULL. @@ -376,8 +371,7 @@ void LocationBarViewMac::TestPageActionPressed(size_t index) { void LocationBarViewMac::SetEditable(bool editable) { [field_ setEditable:editable ? YES : NO]; - star_decoration_->SetVisible(browser_defaults::bookmarks_enabled && - editable && !toolbar_model_->input_in_progress()); + star_decoration_->SetVisible(editable); UpdatePageActions(); Layout(); } @@ -496,10 +490,8 @@ void LocationBarViewMac::RefreshPageActionDecorations() { return; GURL url = GURL(WideToUTF8(toolbar_model_->GetText())); - for (size_t i = 0; i < page_action_decorations_.size(); ++i) { - page_action_decorations_[i]->UpdateVisibility( - toolbar_model_->input_in_progress() ? NULL : contents, url); - } + for (size_t i = 0; i < page_action_decorations_.size(); ++i) + page_action_decorations_[i]->UpdateVisibility(contents, url); } // TODO(shess): This function should over time grow to closely match diff --git a/chrome/browser/cocoa/location_bar/page_action_decoration.mm b/chrome/browser/cocoa/location_bar/page_action_decoration.mm index 337cd2f..d306d87 100644 --- a/chrome/browser/cocoa/location_bar/page_action_decoration.mm +++ b/chrome/browser/cocoa/location_bar/page_action_decoration.mm @@ -121,15 +121,15 @@ void PageActionDecoration::OnImageLoaded( owner_->UpdatePageActions(); } -void PageActionDecoration::UpdateVisibility(TabContents* contents, - const GURL& url) { +void PageActionDecoration::UpdateVisibility( + TabContents* contents, const GURL& url) { // Save this off so we can pass it back to the extension when the action gets // executed. See PageActionDecoration::OnMousePressed. - current_tab_id_ = contents ? ExtensionTabUtil::GetTabId(contents) : -1; + current_tab_id_ = ExtensionTabUtil::GetTabId(contents); current_url_ = url; - bool visible = contents && - (preview_enabled_ || page_action_->GetIsVisible(current_tab_id_)); + bool visible = preview_enabled_ || + page_action_->GetIsVisible(current_tab_id_); if (visible) { SetToolTip(page_action_->GetTitle(current_tab_id_)); @@ -146,15 +146,19 @@ void PageActionDecoration::UpdateVisibility(TabContents* contents, SkBitmap skia_icon = page_action_->GetIcon(current_tab_id_); if (skia_icon.isNull()) { int icon_index = page_action_->GetIconIndex(current_tab_id_); - std::string icon_path = (icon_index < 0) ? - page_action_->default_icon_path() : - page_action_->icon_paths()->at(icon_index); + std::string icon_path; + if (icon_index >= 0) + icon_path = page_action_->icon_paths()->at(icon_index); + else + icon_path = page_action_->default_icon_path(); + if (!icon_path.empty()) { PageActionMap::iterator iter = page_action_icons_.find(icon_path); if (iter != page_action_icons_.end()) skia_icon = iter->second; } } + if (!skia_icon.isNull()) { SetImage(gfx::SkBitmapToNSImage(skia_icon)); } else if (!GetImage()) { @@ -167,7 +171,6 @@ void PageActionDecoration::UpdateVisibility(TabContents* contents, SetImage([[NSImage alloc] initWithSize:default_size]); } } - if (IsVisible() != visible) { SetVisible(visible); NotificationService::current()->Notify( diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc index 6dd0795..95b1bbb 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/gtk/location_bar_view_gtk.cc @@ -257,7 +257,7 @@ void LocationBarViewGtk::Init(bool popup_window_mode) { gtk_box_pack_end(GTK_BOX(entry_box_), tab_to_search_hint_, FALSE, FALSE, 0); // We don't show the star in popups, app windows, etc. - if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { + if (!ShouldOnlyShowLocation()) { CreateStarButton(); gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0); } @@ -407,12 +407,6 @@ GtkWidget* LocationBarViewGtk::GetPageActionWidget( } void LocationBarViewGtk::Update(const TabContents* contents) { - bool star_enabled = star_.get() && !toolbar_model_->input_in_progress(); - command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); - if (star_.get()) - gtk_widget_hide_all(star_.get()); - else - gtk_widget_show_all(star_.get()); UpdateSiteTypeArea(); UpdateContentSettingsIcons(); UpdatePageActions(); @@ -621,10 +615,8 @@ void LocationBarViewGtk::UpdatePageActions() { if (!page_action_views_.empty() && contents) { GURL url = GURL(WideToUTF8(toolbar_model_->GetText())); - for (size_t i = 0; i < page_action_views_.size(); i++) { - page_action_views_[i]->UpdateVisibility( - toolbar_model_->input_in_progress() ? NULL : contents, url); - } + for (size_t i = 0; i < page_action_views_.size(); i++) + page_action_views_[i]->UpdateVisibility(contents, url); } // If there are no visible page actions, hide the hbox too, so that it does @@ -1276,14 +1268,15 @@ void LocationBarViewGtk::PageActionViewGtk::UpdateVisibility( TabContents* contents, GURL url) { // Save this off so we can pass it back to the extension when the action gets // executed. See PageActionImageView::OnMousePressed. - current_tab_id_ = contents ? ExtensionTabUtil::GetTabId(contents) : -1; + current_tab_id_ = ExtensionTabUtil::GetTabId(contents); current_url_ = url; - bool visible = contents && - (preview_enabled_ || page_action_->GetIsVisible(current_tab_id_)); + bool visible = preview_enabled_ || + page_action_->GetIsVisible(current_tab_id_); if (visible) { // Set the tooltip. - gtk_widget_set_tooltip_text(event_box_.get(), + gtk_widget_set_tooltip_text( + event_box_.get(), page_action_->GetTitle(current_tab_id_).c_str()); // Set the image. @@ -1311,15 +1304,19 @@ void LocationBarViewGtk::PageActionViewGtk::UpdateVisibility( // Otherwise look for a dynamically set index, or fall back to the // default path. int icon_index = page_action_->GetIconIndex(current_tab_id_); - std::string icon_path = (icon_index < 0) ? - page_action_->default_icon_path() : - page_action_->icon_paths()->at(icon_index); + std::string icon_path; + if (icon_index >= 0) + icon_path = page_action_->icon_paths()->at(icon_index); + else + icon_path = page_action_->default_icon_path(); + if (!icon_path.empty()) { PixbufMap::iterator iter = pixbufs_.find(icon_path); if (iter != pixbufs_.end()) pixbuf = iter->second; } } + // The pixbuf might not be loaded yet. if (pixbuf) gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), pixbuf); diff --git a/chrome/browser/views/location_bar/location_bar_view.cc b/chrome/browser/views/location_bar/location_bar_view.cc index fdfdacc..057e23e 100644 --- a/chrome/browser/views/location_bar/location_bar_view.cc +++ b/chrome/browser/views/location_bar/location_bar_view.cc @@ -15,7 +15,6 @@ #include "base/utf_string_conversions.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/alternate_nav_url_fetcher.h" -#include "chrome/browser/defaults.h" #include "chrome/browser/extensions/extension_browser_event_router.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/profile.h" @@ -190,7 +189,7 @@ void LocationBarView::Init() { } // The star is not visible in popups and in the app launcher. - if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { + if (mode_ == NORMAL) { star_view_ = new StarView(command_updater_); AddChildView(star_view_); star_view_->SetVisible(true); @@ -261,10 +260,6 @@ SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, } void LocationBarView::Update(const TabContents* tab_for_state_restoring) { - bool star_enabled = star_view_ && !model_->input_in_progress(); - command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); - if (star_view_) - star_view_->SetVisible(star_enabled); RefreshContentSettingViews(); RefreshPageActionViews(); // Don't Update in app launcher mode so that the location entry does not show @@ -434,7 +429,7 @@ void LocationBarView::Layout() { kItemEditPadding); } - if (star_view_ && star_view_->IsVisible()) + if (star_view_) entry_width -= star_view_->GetPreferredSize().width() + kItemPadding; for (PageActionViews::const_iterator i(page_action_views_.begin()); i != page_action_views_.end(); ++i) { @@ -502,7 +497,7 @@ void LocationBarView::Layout() { // Lay out items to the right of the edit field. int offset = width() - kEdgeThickness - kEdgeItemPadding; - if (star_view_ && star_view_->IsVisible()) { + if (star_view_) { int star_width = star_view_->GetPreferredSize().width(); offset -= star_width; star_view_->SetBounds(offset, location_y, star_width, location_height); @@ -846,8 +841,7 @@ void LocationBarView::RefreshPageActionViews() { for (PageActionViews::const_iterator i(page_action_views_.begin()); i != page_action_views_.end(); ++i) { - (*i)->UpdateVisibility(model_->input_in_progress() ? NULL : contents, - url); + (*i)->UpdateVisibility(contents, url); // Check if the visibility of the action changed and notify if it did. ExtensionAction* action = (*i)->image_view()->page_action(); diff --git a/chrome/browser/views/location_bar/page_action_image_view.cc b/chrome/browser/views/location_bar/page_action_image_view.cc index c2d72e3..0f6358b 100644 --- a/chrome/browser/views/location_bar/page_action_image_view.cc +++ b/chrome/browser/views/location_bar/page_action_image_view.cc @@ -182,45 +182,46 @@ void PageActionImageView::UpdateVisibility(TabContents* contents, const GURL& url) { // Save this off so we can pass it back to the extension when the action gets // executed. See PageActionImageView::OnMousePressed. - current_tab_id_ = contents ? ExtensionTabUtil::GetTabId(contents) : -1; + current_tab_id_ = ExtensionTabUtil::GetTabId(contents); current_url_ = url; - if (!contents || - (!preview_enabled_ && !page_action_->GetIsVisible(current_tab_id_))) { - SetVisible(false); - return; - } - - // Set the tooltip. - tooltip_ = page_action_->GetTitle(current_tab_id_); - SetTooltipText(UTF8ToWide(tooltip_)); - - // Set the image. - // It can come from three places. In descending order of priority: - // - The developer can set it dynamically by path or bitmap. It will be in - // page_action_->GetIcon(). - // - The developer can set it dynamically by index. It will be in - // page_action_->GetIconIndex(). - // - It can be set in the manifest by path. It will be in - // page_action_->default_icon_path(). - - // First look for a dynamically set bitmap. - SkBitmap icon = page_action_->GetIcon(current_tab_id_); - if (icon.isNull()) { - int icon_index = page_action_->GetIconIndex(current_tab_id_); - std::string icon_path = (icon_index < 0) ? - page_action_->default_icon_path() : - page_action_->icon_paths()->at(icon_index); - if (!icon_path.empty()) { - PageActionMap::iterator iter = page_action_icons_.find(icon_path); - if (iter != page_action_icons_.end()) - icon = iter->second; + bool visible = + preview_enabled_ || page_action_->GetIsVisible(current_tab_id_); + if (visible) { + // Set the tooltip. + tooltip_ = page_action_->GetTitle(current_tab_id_); + SetTooltipText(UTF8ToWide(tooltip_)); + + // Set the image. + // It can come from three places. In descending order of priority: + // - The developer can set it dynamically by path or bitmap. It will be in + // page_action_->GetIcon(). + // - The developer can set it dynamically by index. It will be in + // page_action_->GetIconIndex(). + // - It can be set in the manifest by path. It will be in page_action_-> + // default_icon_path(). + + // First look for a dynamically set bitmap. + SkBitmap icon = page_action_->GetIcon(current_tab_id_); + if (icon.isNull()) { + int icon_index = page_action_->GetIconIndex(current_tab_id_); + std::string icon_path; + if (icon_index >= 0) + icon_path = page_action_->icon_paths()->at(icon_index); + else + icon_path = page_action_->default_icon_path(); + + if (!icon_path.empty()) { + PageActionMap::iterator iter = page_action_icons_.find(icon_path); + if (iter != page_action_icons_.end()) + icon = iter->second; + } } - } - if (!icon.isNull()) - SetImage(&icon); - SetVisible(true); + if (!icon.isNull()) + SetImage(&icon); + } + SetVisible(visible); } void PageActionImageView::InspectPopup(ExtensionAction* action) { |