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

Side by Side Diff: ui/views/controls/combobox/combobox.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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
« no previous file with comments | « ui/views/controls/combobox/combobox.h ('k') | ui/views/controls/combobox/combobox_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/views/controls/combobox/combobox.h" 5 #include "ui/views/controls/combobox/combobox.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 selected_index_(model_->GetDefaultIndex()), 349 selected_index_(model_->GetDefaultIndex()),
350 invalid_(false), 350 invalid_(false),
351 menu_model_adapter_(new ComboboxMenuModelAdapter(this, model)), 351 menu_model_adapter_(new ComboboxMenuModelAdapter(this, model)),
352 text_button_(new TransparentButton(this)), 352 text_button_(new TransparentButton(this)),
353 arrow_button_(new TransparentButton(this)), 353 arrow_button_(new TransparentButton(this)),
354 weak_ptr_factory_(this) { 354 weak_ptr_factory_(this) {
355 ModelChanged(); 355 ModelChanged();
356 SetFocusable(true); 356 SetFocusable(true);
357 UpdateBorder(); 357 UpdateBorder();
358 // set_background() takes ownership but takes a raw pointer. 358 // set_background() takes ownership but takes a raw pointer.
359 scoped_ptr<Background> b = PlatformStyle::CreateComboboxBackground(); 359 std::unique_ptr<Background> b = PlatformStyle::CreateComboboxBackground();
360 set_background(b.release()); 360 set_background(b.release());
361 361
362 // Initialize the button images. 362 // Initialize the button images.
363 Button::ButtonState button_states[] = { 363 Button::ButtonState button_states[] = {
364 Button::STATE_DISABLED, 364 Button::STATE_DISABLED,
365 Button::STATE_NORMAL, 365 Button::STATE_NORMAL,
366 Button::STATE_HOVERED, 366 Button::STATE_HOVERED,
367 Button::STATE_PRESSED, 367 Button::STATE_PRESSED,
368 }; 368 };
369 for (int i = 0; i < 2; i++) { 369 for (int i = 0; i < 2; i++) {
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE; 693 ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE;
694 if (event.IsKeyEvent()) 694 if (event.IsKeyEvent())
695 source_type = ui::MENU_SOURCE_KEYBOARD; 695 source_type = ui::MENU_SOURCE_KEYBOARD;
696 else if (event.IsGestureEvent() || event.IsTouchEvent()) 696 else if (event.IsGestureEvent() || event.IsTouchEvent())
697 source_type = ui::MENU_SOURCE_TOUCH; 697 source_type = ui::MENU_SOURCE_TOUCH;
698 ShowDropDownMenu(source_type); 698 ShowDropDownMenu(source_type);
699 } 699 }
700 } 700 }
701 701
702 void Combobox::UpdateBorder() { 702 void Combobox::UpdateBorder() {
703 scoped_ptr<FocusableBorder> border(PlatformStyle::CreateComboboxBorder()); 703 std::unique_ptr<FocusableBorder> border(
704 PlatformStyle::CreateComboboxBorder());
704 if (style_ == STYLE_ACTION) 705 if (style_ == STYLE_ACTION)
705 border->SetInsets(5, 10, 5, 10); 706 border->SetInsets(5, 10, 5, 10);
706 if (invalid_) 707 if (invalid_)
707 border->SetColor(gfx::kGoogleRed700); 708 border->SetColor(gfx::kGoogleRed700);
708 SetBorder(std::move(border)); 709 SetBorder(std::move(border));
709 } 710 }
710 711
711 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const { 712 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const {
712 rect->set_x(GetMirroredXForRect(*rect)); 713 rect->set_x(GetMirroredXForRect(*rect));
713 } 714 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 return gfx::Size(width, font_list.GetHeight()); 916 return gfx::Size(width, font_list.GetHeight());
916 } 917 }
917 918
918 PrefixSelector* Combobox::GetPrefixSelector() { 919 PrefixSelector* Combobox::GetPrefixSelector() {
919 if (!selector_) 920 if (!selector_)
920 selector_.reset(new PrefixSelector(this)); 921 selector_.reset(new PrefixSelector(this));
921 return selector_.get(); 922 return selector_.get();
922 } 923 }
923 924
924 } // namespace views 925 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/combobox/combobox.h ('k') | ui/views/controls/combobox/combobox_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698