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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 145033006: views: Make View::set_border() take a scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 if (template_url_service_) 228 if (template_url_service_)
229 template_url_service_->RemoveObserver(this); 229 template_url_service_->RemoveObserver(this);
230 if (browser_) 230 if (browser_)
231 browser_->search_model()->RemoveObserver(this); 231 browser_->search_model()->RemoveObserver(this);
232 } 232 }
233 233
234 // static 234 // static
235 void LocationBarView::InitTouchableLocationBarChildView(views::View* view) { 235 void LocationBarView::InitTouchableLocationBarChildView(views::View* view) {
236 int horizontal_padding = GetBuiltInHorizontalPaddingForChildViews(); 236 int horizontal_padding = GetBuiltInHorizontalPaddingForChildViews();
237 if (horizontal_padding != 0) { 237 if (horizontal_padding != 0) {
238 view->set_border(views::Border::CreateEmptyBorder( 238 view->SetBorder(views::Border::CreateEmptyBorder(
239 3, horizontal_padding, 3, horizontal_padding)); 239 3, horizontal_padding, 3, horizontal_padding));
240 } 240 }
241 } 241 }
242 242
243 void LocationBarView::Init() { 243 void LocationBarView::Init() {
244 // We need to be in a Widget, otherwise GetNativeTheme() may change and we're 244 // We need to be in a Widget, otherwise GetNativeTheme() may change and we're
245 // not prepared for that. 245 // not prepared for that.
246 DCHECK(GetWidget()); 246 DCHECK(GetWidget());
247 247
248 const int kOmniboxPopupBorderImages[] = 248 const int kOmniboxPopupBorderImages[] =
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 star_view_ = new StarView(command_updater()); 375 star_view_ = new StarView(command_updater());
376 star_view_->SetVisible(false); 376 star_view_->SetVisible(false);
377 AddChildView(star_view_); 377 AddChildView(star_view_);
378 378
379 search_button_ = new views::LabelButton(this, base::string16()); 379 search_button_ = new views::LabelButton(this, base::string16());
380 search_button_->set_triggerable_event_flags( 380 search_button_->set_triggerable_event_flags(
381 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON); 381 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON);
382 search_button_->SetStyle(views::Button::STYLE_BUTTON); 382 search_button_->SetStyle(views::Button::STYLE_BUTTON);
383 search_button_->SetFocusable(false); 383 search_button_->SetFocusable(false);
384 search_button_->set_min_size(gfx::Size()); 384 search_button_->set_min_size(gfx::Size());
385 views::LabelButtonBorder* search_button_border = 385 scoped_ptr<views::LabelButtonBorder> search_button_border(
386 new views::LabelButtonBorder(search_button_->style()); 386 new views::LabelButtonBorder(search_button_->style()));
387 search_button_border->set_insets(gfx::Insets()); 387 search_button_border->set_insets(gfx::Insets());
388 const int kSearchButtonNormalImages[] = IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON); 388 const int kSearchButtonNormalImages[] = IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON);
389 search_button_border->SetPainter( 389 search_button_border->SetPainter(
390 false, views::Button::STATE_NORMAL, 390 false, views::Button::STATE_NORMAL,
391 views::Painter::CreateImageGridPainter(kSearchButtonNormalImages)); 391 views::Painter::CreateImageGridPainter(kSearchButtonNormalImages));
392 const int kSearchButtonHoveredImages[] = 392 const int kSearchButtonHoveredImages[] =
393 IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_HOVER); 393 IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_HOVER);
394 search_button_border->SetPainter( 394 search_button_border->SetPainter(
395 false, views::Button::STATE_HOVERED, 395 false, views::Button::STATE_HOVERED,
396 views::Painter::CreateImageGridPainter(kSearchButtonHoveredImages)); 396 views::Painter::CreateImageGridPainter(kSearchButtonHoveredImages));
397 const int kSearchButtonPressedImages[] = 397 const int kSearchButtonPressedImages[] =
398 IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_PRESSED); 398 IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_PRESSED);
399 search_button_border->SetPainter( 399 search_button_border->SetPainter(
400 false, views::Button::STATE_PRESSED, 400 false, views::Button::STATE_PRESSED,
401 views::Painter::CreateImageGridPainter(kSearchButtonPressedImages)); 401 views::Painter::CreateImageGridPainter(kSearchButtonPressedImages));
402 search_button_border->SetPainter(false, views::Button::STATE_DISABLED, NULL); 402 search_button_border->SetPainter(false, views::Button::STATE_DISABLED, NULL);
403 search_button_border->SetPainter(true, views::Button::STATE_NORMAL, NULL); 403 search_button_border->SetPainter(true, views::Button::STATE_NORMAL, NULL);
404 search_button_border->SetPainter(true, views::Button::STATE_HOVERED, NULL); 404 search_button_border->SetPainter(true, views::Button::STATE_HOVERED, NULL);
405 search_button_border->SetPainter(true, views::Button::STATE_PRESSED, NULL); 405 search_button_border->SetPainter(true, views::Button::STATE_PRESSED, NULL);
406 search_button_border->SetPainter(true, views::Button::STATE_DISABLED, NULL); 406 search_button_border->SetPainter(true, views::Button::STATE_DISABLED, NULL);
407 search_button_->set_border(search_button_border); 407 search_button_->SetBorder(search_button_border.PassAs<views::Border>());
408 const int kSearchButtonWidth = 56; 408 const int kSearchButtonWidth = 56;
409 search_button_->set_min_size(gfx::Size(kSearchButtonWidth, 0)); 409 search_button_->set_min_size(gfx::Size(kSearchButtonWidth, 0));
410 search_button_->SetVisible(false); 410 search_button_->SetVisible(false);
411 AddChildView(search_button_); 411 AddChildView(search_button_);
412 412
413 content::Source<Profile> profile_source = content::Source<Profile>(profile()); 413 content::Source<Profile> profile_source = content::Source<Profile>(profile());
414 registrar_.Add(this, 414 registrar_.Add(this,
415 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, 415 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED,
416 profile_source); 416 profile_source);
417 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, profile_source); 417 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, profile_source);
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 // TODO(sky): Figure out why we need the +1. 885 // TODO(sky): Figure out why we need the +1.
886 suggested_text_bounds.set_x(location_bounds.x() + 1); 886 suggested_text_bounds.set_x(location_bounds.x() + 1);
887 // Use a margin to prevent omnibox text from overlapping suggest text. 887 // Use a margin to prevent omnibox text from overlapping suggest text.
888 omnibox_view_margin = suggested_text_bounds.width(); 888 omnibox_view_margin = suggested_text_bounds.width();
889 } 889 }
890 suggested_text_view_->SetBoundsRect(suggested_text_bounds); 890 suggested_text_view_->SetBoundsRect(suggested_text_bounds);
891 } 891 }
892 } 892 }
893 893
894 const gfx::Insets insets = omnibox_view_->GetInsets(); 894 const gfx::Insets insets = omnibox_view_->GetInsets();
895 omnibox_view_->set_border(views::Border::CreateEmptyBorder( 895 omnibox_view_->SetBorder(views::Border::CreateEmptyBorder(
896 insets.top(), insets.left(), insets.bottom(), omnibox_view_margin)); 896 insets.top(), insets.left(), insets.bottom(), omnibox_view_margin));
897 897
898 // Layout |ime_inline_autocomplete_view_| next to the user input. 898 // Layout |ime_inline_autocomplete_view_| next to the user input.
899 if (ime_inline_autocomplete_view_->visible()) { 899 if (ime_inline_autocomplete_view_->visible()) {
900 int width = 900 int width =
901 gfx::GetStringWidth(ime_inline_autocomplete_view_->text(), 901 gfx::GetStringWidth(ime_inline_autocomplete_view_->text(),
902 ime_inline_autocomplete_view_->font_list()) + 902 ime_inline_autocomplete_view_->font_list()) +
903 ime_inline_autocomplete_view_->GetInsets().width(); 903 ime_inline_autocomplete_view_->GetInsets().width();
904 // All the target languages (IMEs) are LTR, and we do not need to support 904 // All the target languages (IMEs) are LTR, and we do not need to support
905 // RTL so far. In other words, no testable RTL environment so far. 905 // RTL so far. In other words, no testable RTL environment so far.
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 bounds.Inset(-(horizontal_padding + 1) / 2, 0); 1542 bounds.Inset(-(horizontal_padding + 1) / 2, 0);
1543 location_bar_util::PaintExtensionActionBackground( 1543 location_bar_util::PaintExtensionActionBackground(
1544 *(*page_action_view)->image_view()->page_action(), 1544 *(*page_action_view)->image_view()->page_action(),
1545 tab_id, canvas, bounds, text_color, background_color); 1545 tab_id, canvas, bounds, text_color, background_color);
1546 } 1546 }
1547 } 1547 }
1548 1548
1549 void LocationBarView::AccessibilitySetValue(const base::string16& new_value) { 1549 void LocationBarView::AccessibilitySetValue(const base::string16& new_value) {
1550 omnibox_view_->SetUserText(new_value, new_value, true); 1550 omnibox_view_->SetUserText(new_value, new_value, true);
1551 } 1551 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/infobars/infobar_view.cc ('k') | chrome/browser/ui/views/message_center/message_center_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698