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

Side by Side Diff: chrome/browser/ui/libgtkui/gtk_ui.cc

Issue 2637383003: Change Painter factory functions to unique_ptr (Closed)
Patch Set: update more stuff Created 3 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
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/libgtkui/gtk_ui.h" 5 #include "chrome/browser/ui/libgtkui/gtk_ui.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <pango/pango.h> 8 #include <pango/pango.h>
9 #include <X11/Xcursor/Xcursor.h> 9 #include <X11/Xcursor/Xcursor.h>
10 10
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 { 680 {
681 "IDR_BUTTON_DISABLED", "IDR_BLUE_BUTTON_DISABLED", true, 681 "IDR_BUTTON_DISABLED", "IDR_BLUE_BUTTON_DISABLED", true,
682 views::Button::STATE_DISABLED, 682 views::Button::STATE_DISABLED,
683 }, 683 },
684 }; 684 };
685 685
686 bool is_blue = 686 bool is_blue =
687 owning_button->GetClassName() == views::BlueButton::kViewClassName; 687 owning_button->GetClassName() == views::BlueButton::kViewClassName;
688 688
689 for (unsigned i = 0; i < arraysize(paintstate); i++) { 689 for (unsigned i = 0; i < arraysize(paintstate); i++) {
690 views::Painter* painter = nullptr; 690 std::unique_ptr<views::Painter> painter = nullptr;
msw 2017/01/19 09:46:53 nit: |= nullptr| no longer needed.
Evan Stade 2017/01/19 16:26:29 Done.
691 691
692 if (border->PaintsButtonState(paintstate[i].focus, paintstate[i].state)) { 692 if (border->PaintsButtonState(paintstate[i].focus, paintstate[i].state)) {
693 std::string idr = is_blue ? paintstate[i].idr_blue : paintstate[i].idr; 693 std::string idr = is_blue ? paintstate[i].idr_blue : paintstate[i].idr;
694 painter = new GtkButtonPainter(idr); 694 painter = base::MakeUnique<GtkButtonPainter>(idr);
695 } 695 }
696 696
697 gtk_border->SetPainter(paintstate[i].focus, paintstate[i].state, painter); 697 gtk_border->SetPainter(paintstate[i].focus, paintstate[i].state,
msw 2017/01/19 09:46:53 optional nit/q: i wonder if we can just skip SetPa
Evan Stade 2017/01/19 16:26:29 I think you're right, done.
698 std::move(painter));
698 } 699 }
699 700
700 return std::move(gtk_border); 701 return gtk_border;
701 } 702 }
702 703
703 void GtkUi::AddWindowButtonOrderObserver( 704 void GtkUi::AddWindowButtonOrderObserver(
704 views::WindowButtonOrderObserver* observer) { 705 views::WindowButtonOrderObserver* observer) {
705 if (!leading_buttons_.empty() || !trailing_buttons_.empty()) { 706 if (!leading_buttons_.empty() || !trailing_buttons_.empty()) {
706 observer->OnWindowButtonOrderingChange(leading_buttons_, trailing_buttons_); 707 observer->OnWindowButtonOrderingChange(leading_buttons_, trailing_buttons_);
707 } 708 }
708 709
709 observer_list_.AddObserver(observer); 710 observer_list_.AddObserver(observer);
710 } 711 }
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 1054
1054 float GtkUi::GetDeviceScaleFactor() const { 1055 float GtkUi::GetDeviceScaleFactor() const {
1055 return device_scale_factor_; 1056 return device_scale_factor_;
1056 } 1057 }
1057 1058
1058 } // namespace libgtkui 1059 } // namespace libgtkui
1059 1060
1060 views::LinuxUI* BuildGtkUi() { 1061 views::LinuxUI* BuildGtkUi() {
1061 return new libgtkui::GtkUi; 1062 return new libgtkui::GtkUi;
1062 } 1063 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698