Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1611)

Unified Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 21696003: views/location_bar: Eliminate TouchableLocationBarView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix wrapping Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/location_bar/location_bar_view.cc
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index f8f1202975ecb284da418c1043d36d02dfc749cf..14f81b3c453dd122a62c3bdb19f69de894d98908 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -44,7 +44,6 @@
#include "chrome/browser/ui/views/location_bar/keyword_hint_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_layout.h"
#include "chrome/browser/ui/views/location_bar/location_icon_view.h"
-#include "chrome/browser/ui/views/location_bar/mic_search_view.h"
#include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h"
#include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
#include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
@@ -79,6 +78,7 @@
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/button_drag_utils.h"
+#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/widget/widget.h"
@@ -227,6 +227,15 @@ LocationBarView::~LocationBarView() {
browser_->search_model()->RemoveObserver(this);
}
+// static
+void LocationBarView::InitTouchableLocationBarChildView(views::View* view) {
+ int horizontal_padding = GetBuiltInHorizontalPaddingForChildViews();
+ if (horizontal_padding != 0) {
+ view->set_border(views::Border::CreateEmptyBorder(
+ 3, horizontal_padding, 3, horizontal_padding));
+ }
+}
+
void LocationBarView::Init() {
// We need to be in a Widget, otherwise GetNativeTheme() may change and we're
// not prepared for that.
@@ -314,8 +323,19 @@ void LocationBarView::Init() {
background_color);
AddChildView(keyword_hint_view_);
- mic_search_view_ = new MicSearchView(this);
+ mic_search_view_ = new views::ImageButton(this);
+ mic_search_view_->set_id(VIEW_ID_MIC_SEARCH_BUTTON);
+ mic_search_view_->set_accessibility_focusable(true);
+ mic_search_view_->SetTooltipText(
+ l10n_util::GetStringUTF16(IDS_TOOLTIP_MIC_SEARCH));
+ mic_search_view_->SetImage(
+ views::Button::STATE_NORMAL,
+ ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
+ IDR_OMNIBOX_MIC_SEARCH));
+ mic_search_view_->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
+ views::ImageButton::ALIGN_MIDDLE);
mic_search_view_->SetVisible(false);
+ InitTouchableLocationBarChildView(mic_search_view_);
AddChildView(mic_search_view_);
for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
@@ -716,25 +736,25 @@ void LocationBarView::Layout() {
} else {
leading_decorations.AddDecoration(
vertical_edge_thickness(), location_height,
- location_icon_view_->GetBuiltInHorizontalPadding(),
+ GetBuiltInHorizontalPaddingForChildViews(),
location_icon_view_);
}
if (star_view_ && star_view_->visible()) {
trailing_decorations.AddDecoration(
vertical_edge_thickness(), location_height,
- star_view_->GetBuiltInHorizontalPadding(), star_view_);
+ GetBuiltInHorizontalPaddingForChildViews(), star_view_);
}
if (script_bubble_icon_view_ && script_bubble_icon_view_->visible()) {
trailing_decorations.AddDecoration(
vertical_edge_thickness(), location_height,
- script_bubble_icon_view_->GetBuiltInHorizontalPadding(),
+ GetBuiltInHorizontalPaddingForChildViews(),
script_bubble_icon_view_);
}
if (open_pdf_in_reader_view_ && open_pdf_in_reader_view_->visible()) {
trailing_decorations.AddDecoration(
vertical_edge_thickness(), location_height,
- open_pdf_in_reader_view_->GetBuiltInHorizontalPadding(),
+ GetBuiltInHorizontalPaddingForChildViews(),
open_pdf_in_reader_view_);
}
for (PageActionViews::const_iterator i(page_action_views_.begin());
@@ -742,7 +762,7 @@ void LocationBarView::Layout() {
if ((*i)->visible()) {
trailing_decorations.AddDecoration(
vertical_edge_thickness(), location_height,
- (*i)->GetBuiltInHorizontalPadding(), (*i));
+ GetBuiltInHorizontalPaddingForChildViews(), (*i));
}
}
if (zoom_view_->visible()) {
@@ -755,7 +775,7 @@ void LocationBarView::Layout() {
if ((*i)->visible()) {
trailing_decorations.AddDecoration(
bubble_location_y, bubble_height, false, 0, item_padding,
- item_padding, (*i)->GetBuiltInHorizontalPadding(), (*i));
+ item_padding, GetBuiltInHorizontalPaddingForChildViews(), (*i));
}
}
if (autofill_credit_card_view_->visible()) {
@@ -1078,6 +1098,12 @@ WebContents* LocationBarView::GetWebContents() const {
return delegate_->GetWebContents();
}
+// static
+int LocationBarView::GetBuiltInHorizontalPaddingForChildViews() {
+ return (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) ?
+ GetItemPadding() / 2 : 0;
+}
+
int LocationBarView::GetHorizontalEdgeThickness() const {
// In maximized popup mode, there isn't any edge.
return (is_popup_mode_ && browser_ && browser_->window() &&
@@ -1233,8 +1259,8 @@ void LocationBarView::PaintPageActionBackgrounds(gfx::Canvas* canvas) {
page_action_view != page_action_views_.end();
++page_action_view) {
gfx::Rect bounds = (*page_action_view)->bounds();
- int horizontal_padding = GetItemPadding() -
- (*page_action_view)->GetBuiltInHorizontalPadding();
+ int horizontal_padding =
+ GetItemPadding() - GetBuiltInHorizontalPaddingForChildViews();
// Make the bounding rectangle include the whole vertical range of the
// location bar, and the mid-point pixels between adjacent page actions.
//
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | chrome/browser/ui/views/location_bar/location_icon_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698