| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 if (template_url_service_) | 231 if (template_url_service_) |
| 232 template_url_service_->RemoveObserver(this); | 232 template_url_service_->RemoveObserver(this); |
| 233 if (browser_) | 233 if (browser_) |
| 234 browser_->search_model()->RemoveObserver(this); | 234 browser_->search_model()->RemoveObserver(this); |
| 235 } | 235 } |
| 236 | 236 |
| 237 // static | 237 // static |
| 238 void LocationBarView::InitTouchableLocationBarChildView(views::View* view) { | 238 void LocationBarView::InitTouchableLocationBarChildView(views::View* view) { |
| 239 int horizontal_padding = GetBuiltInHorizontalPaddingForChildViews(); | 239 int horizontal_padding = GetBuiltInHorizontalPaddingForChildViews(); |
| 240 if (horizontal_padding != 0) { | 240 if (horizontal_padding != 0) { |
| 241 view->set_border(views::Border::CreateEmptyBorder( | 241 view->SetBorder(views::Border::CreateEmptyBorder( |
| 242 3, horizontal_padding, 3, horizontal_padding)); | 242 3, horizontal_padding, 3, horizontal_padding)); |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 void LocationBarView::Init() { | 246 void LocationBarView::Init() { |
| 247 // We need to be in a Widget, otherwise GetNativeTheme() may change and we're | 247 // We need to be in a Widget, otherwise GetNativeTheme() may change and we're |
| 248 // not prepared for that. | 248 // not prepared for that. |
| 249 DCHECK(GetWidget()); | 249 DCHECK(GetWidget()); |
| 250 | 250 |
| 251 const int kOmniboxPopupBorderImages[] = | 251 const int kOmniboxPopupBorderImages[] = |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 star_view_ = new StarView(command_updater()); | 382 star_view_ = new StarView(command_updater()); |
| 383 star_view_->SetVisible(false); | 383 star_view_->SetVisible(false); |
| 384 AddChildView(star_view_); | 384 AddChildView(star_view_); |
| 385 | 385 |
| 386 search_button_ = new views::LabelButton(this, base::string16()); | 386 search_button_ = new views::LabelButton(this, base::string16()); |
| 387 search_button_->set_triggerable_event_flags( | 387 search_button_->set_triggerable_event_flags( |
| 388 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON); | 388 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON); |
| 389 search_button_->SetStyle(views::Button::STYLE_BUTTON); | 389 search_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 390 search_button_->SetFocusable(false); | 390 search_button_->SetFocusable(false); |
| 391 search_button_->set_min_size(gfx::Size()); | 391 search_button_->set_min_size(gfx::Size()); |
| 392 views::LabelButtonBorder* search_button_border = | 392 scoped_ptr<views::LabelButtonBorder> search_button_border( |
| 393 new views::LabelButtonBorder(search_button_->style()); | 393 new views::LabelButtonBorder(search_button_->style())); |
| 394 search_button_border->set_insets(gfx::Insets()); | 394 search_button_border->set_insets(gfx::Insets()); |
| 395 const int kSearchButtonNormalImages[] = IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON); | 395 const int kSearchButtonNormalImages[] = IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON); |
| 396 search_button_border->SetPainter( | 396 search_button_border->SetPainter( |
| 397 false, views::Button::STATE_NORMAL, | 397 false, views::Button::STATE_NORMAL, |
| 398 views::Painter::CreateImageGridPainter(kSearchButtonNormalImages)); | 398 views::Painter::CreateImageGridPainter(kSearchButtonNormalImages)); |
| 399 const int kSearchButtonHoveredImages[] = | 399 const int kSearchButtonHoveredImages[] = |
| 400 IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_HOVER); | 400 IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_HOVER); |
| 401 search_button_border->SetPainter( | 401 search_button_border->SetPainter( |
| 402 false, views::Button::STATE_HOVERED, | 402 false, views::Button::STATE_HOVERED, |
| 403 views::Painter::CreateImageGridPainter(kSearchButtonHoveredImages)); | 403 views::Painter::CreateImageGridPainter(kSearchButtonHoveredImages)); |
| 404 const int kSearchButtonPressedImages[] = | 404 const int kSearchButtonPressedImages[] = |
| 405 IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_PRESSED); | 405 IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_PRESSED); |
| 406 search_button_border->SetPainter( | 406 search_button_border->SetPainter( |
| 407 false, views::Button::STATE_PRESSED, | 407 false, views::Button::STATE_PRESSED, |
| 408 views::Painter::CreateImageGridPainter(kSearchButtonPressedImages)); | 408 views::Painter::CreateImageGridPainter(kSearchButtonPressedImages)); |
| 409 search_button_border->SetPainter(false, views::Button::STATE_DISABLED, NULL); | 409 search_button_border->SetPainter(false, views::Button::STATE_DISABLED, NULL); |
| 410 search_button_border->SetPainter(true, views::Button::STATE_NORMAL, NULL); | 410 search_button_border->SetPainter(true, views::Button::STATE_NORMAL, NULL); |
| 411 search_button_border->SetPainter(true, views::Button::STATE_HOVERED, NULL); | 411 search_button_border->SetPainter(true, views::Button::STATE_HOVERED, NULL); |
| 412 search_button_border->SetPainter(true, views::Button::STATE_PRESSED, NULL); | 412 search_button_border->SetPainter(true, views::Button::STATE_PRESSED, NULL); |
| 413 search_button_border->SetPainter(true, views::Button::STATE_DISABLED, NULL); | 413 search_button_border->SetPainter(true, views::Button::STATE_DISABLED, NULL); |
| 414 search_button_->set_border(search_button_border); | 414 search_button_->SetBorder(search_button_border.PassAs<views::Border>()); |
| 415 const int kSearchButtonWidth = 56; | 415 const int kSearchButtonWidth = 56; |
| 416 search_button_->set_min_size(gfx::Size(kSearchButtonWidth, 0)); | 416 search_button_->set_min_size(gfx::Size(kSearchButtonWidth, 0)); |
| 417 search_button_->SetVisible(false); | 417 search_button_->SetVisible(false); |
| 418 AddChildView(search_button_); | 418 AddChildView(search_button_); |
| 419 | 419 |
| 420 content::Source<Profile> profile_source = content::Source<Profile>(profile()); | 420 content::Source<Profile> profile_source = content::Source<Profile>(profile()); |
| 421 registrar_.Add(this, | 421 registrar_.Add(this, |
| 422 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, | 422 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, |
| 423 profile_source); | 423 profile_source); |
| 424 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, profile_source); | 424 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, profile_source); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 // TODO(sky): Figure out why we need the +1. | 901 // TODO(sky): Figure out why we need the +1. |
| 902 suggested_text_bounds.set_x(location_bounds.x() + 1); | 902 suggested_text_bounds.set_x(location_bounds.x() + 1); |
| 903 // Use a margin to prevent omnibox text from overlapping suggest text. | 903 // Use a margin to prevent omnibox text from overlapping suggest text. |
| 904 omnibox_view_margin = suggested_text_bounds.width(); | 904 omnibox_view_margin = suggested_text_bounds.width(); |
| 905 } | 905 } |
| 906 suggested_text_view_->SetBoundsRect(suggested_text_bounds); | 906 suggested_text_view_->SetBoundsRect(suggested_text_bounds); |
| 907 } | 907 } |
| 908 } | 908 } |
| 909 | 909 |
| 910 const gfx::Insets insets = omnibox_view_->GetInsets(); | 910 const gfx::Insets insets = omnibox_view_->GetInsets(); |
| 911 omnibox_view_->set_border(views::Border::CreateEmptyBorder( | 911 omnibox_view_->SetBorder(views::Border::CreateEmptyBorder( |
| 912 insets.top(), insets.left(), insets.bottom(), omnibox_view_margin)); | 912 insets.top(), insets.left(), insets.bottom(), omnibox_view_margin)); |
| 913 | 913 |
| 914 // Layout |ime_inline_autocomplete_view_| next to the user input. | 914 // Layout |ime_inline_autocomplete_view_| next to the user input. |
| 915 if (ime_inline_autocomplete_view_->visible()) { | 915 if (ime_inline_autocomplete_view_->visible()) { |
| 916 int width = | 916 int width = |
| 917 gfx::GetStringWidth(ime_inline_autocomplete_view_->text(), | 917 gfx::GetStringWidth(ime_inline_autocomplete_view_->text(), |
| 918 ime_inline_autocomplete_view_->font_list()) + | 918 ime_inline_autocomplete_view_->font_list()) + |
| 919 ime_inline_autocomplete_view_->GetInsets().width(); | 919 ime_inline_autocomplete_view_->GetInsets().width(); |
| 920 // All the target languages (IMEs) are LTR, and we do not need to support | 920 // All the target languages (IMEs) are LTR, and we do not need to support |
| 921 // RTL so far. In other words, no testable RTL environment so far. | 921 // RTL so far. In other words, no testable RTL environment so far. |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 bounds.Inset(-(horizontal_padding + 1) / 2, 0); | 1589 bounds.Inset(-(horizontal_padding + 1) / 2, 0); |
| 1590 location_bar_util::PaintExtensionActionBackground( | 1590 location_bar_util::PaintExtensionActionBackground( |
| 1591 *(*page_action_view)->image_view()->page_action(), | 1591 *(*page_action_view)->image_view()->page_action(), |
| 1592 tab_id, canvas, bounds, text_color, background_color); | 1592 tab_id, canvas, bounds, text_color, background_color); |
| 1593 } | 1593 } |
| 1594 } | 1594 } |
| 1595 | 1595 |
| 1596 void LocationBarView::AccessibilitySetValue(const base::string16& new_value) { | 1596 void LocationBarView::AccessibilitySetValue(const base::string16& new_value) { |
| 1597 omnibox_view_->SetUserText(new_value, new_value, true); | 1597 omnibox_view_->SetUserText(new_value, new_value, true); |
| 1598 } | 1598 } |
| OLD | NEW |