diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 18:20:43 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 18:20:43 +0000 |
commit | 4b65d2833244db6625daf107e30b75bbd60a4a7b (patch) | |
tree | 665de672ded92eb15f7aa7fb50866ddb93a0301d /chrome/browser/views/location_bar | |
parent | 032f25252fbb1d74e2a6ba553f6b87c6ef6e5192 (diff) | |
download | chromium_src-4b65d2833244db6625daf107e30b75bbd60a4a7b.zip chromium_src-4b65d2833244db6625daf107e30b75bbd60a4a7b.tar.gz chromium_src-4b65d2833244db6625daf107e30b75bbd60a4a7b.tar.bz2 |
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.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58028 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/location_bar')
-rw-r--r-- | chrome/browser/views/location_bar/location_bar_view.cc | 14 | ||||
-rw-r--r-- | chrome/browser/views/location_bar/page_action_image_view.cc | 71 |
2 files changed, 45 insertions, 40 deletions
diff --git a/chrome/browser/views/location_bar/location_bar_view.cc b/chrome/browser/views/location_bar/location_bar_view.cc index 057e23e..fdfdacc 100644 --- a/chrome/browser/views/location_bar/location_bar_view.cc +++ b/chrome/browser/views/location_bar/location_bar_view.cc @@ -15,6 +15,7 @@ #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" @@ -189,7 +190,7 @@ void LocationBarView::Init() { } // The star is not visible in popups and in the app launcher. - if (mode_ == NORMAL) { + if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { star_view_ = new StarView(command_updater_); AddChildView(star_view_); star_view_->SetVisible(true); @@ -260,6 +261,10 @@ 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 @@ -429,7 +434,7 @@ void LocationBarView::Layout() { kItemEditPadding); } - if (star_view_) + if (star_view_ && star_view_->IsVisible()) entry_width -= star_view_->GetPreferredSize().width() + kItemPadding; for (PageActionViews::const_iterator i(page_action_views_.begin()); i != page_action_views_.end(); ++i) { @@ -497,7 +502,7 @@ void LocationBarView::Layout() { // Lay out items to the right of the edit field. int offset = width() - kEdgeThickness - kEdgeItemPadding; - if (star_view_) { + if (star_view_ && star_view_->IsVisible()) { int star_width = star_view_->GetPreferredSize().width(); offset -= star_width; star_view_->SetBounds(offset, location_y, star_width, location_height); @@ -841,7 +846,8 @@ void LocationBarView::RefreshPageActionViews() { for (PageActionViews::const_iterator i(page_action_views_.begin()); i != page_action_views_.end(); ++i) { - (*i)->UpdateVisibility(contents, url); + (*i)->UpdateVisibility(model_->input_in_progress() ? NULL : 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 0f6358b..c2d72e3 100644 --- a/chrome/browser/views/location_bar/page_action_image_view.cc +++ b/chrome/browser/views/location_bar/page_action_image_view.cc @@ -182,46 +182,45 @@ 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_ = ExtensionTabUtil::GetTabId(contents); + current_tab_id_ = contents ? ExtensionTabUtil::GetTabId(contents) : -1; current_url_ = url; - 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 (!contents || + (!preview_enabled_ && !page_action_->GetIsVisible(current_tab_id_))) { + SetVisible(false); + return; + } - if (!icon.isNull()) - SetImage(&icon); + // 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; + } } - SetVisible(visible); + if (!icon.isNull()) + SetImage(&icon); + + SetVisible(true); } void PageActionImageView::InspectPopup(ExtensionAction* action) { |