Commit 39c462dd authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Init members in declaration where possible in various download classes.

Complies with
https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++-dos-and-donts.md#initialize-members-in-the-declaration-where-possible

Bug: none
Change-Id: Ie5d21f9bf83bb1dae3ddd9e85b1a0e332687e6ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2347200
Commit-Queue: Min Qin <qinmin@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797134}
parent 400fce48
...@@ -41,10 +41,7 @@ const int64_t kDownloadShowDelayInSeconds = 2; ...@@ -41,10 +41,7 @@ const int64_t kDownloadShowDelayInSeconds = 2;
} // namespace } // namespace
DownloadShelf::DownloadShelf(Browser* browser, Profile* profile) DownloadShelf::DownloadShelf(Browser* browser, Profile* profile)
: browser_(browser), : browser_(browser), profile_(profile) {}
profile_(profile),
should_show_on_unhide_(false),
is_hidden_(false) {}
DownloadShelf::~DownloadShelf() {} DownloadShelf::~DownloadShelf() {}
......
...@@ -97,8 +97,8 @@ class DownloadShelf { ...@@ -97,8 +97,8 @@ class DownloadShelf {
Browser* const browser_; Browser* const browser_;
Profile* const profile_; Profile* const profile_;
bool should_show_on_unhide_; bool should_show_on_unhide_ = false;
bool is_hidden_; bool is_hidden_ = false;
base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_{this}; base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_{this};
}; };
......
...@@ -7,9 +7,7 @@ ...@@ -7,9 +7,7 @@
#include "content/public/browser/download_manager.h" #include "content/public/browser/download_manager.h"
TestDownloadShelf::TestDownloadShelf(Profile* profile) TestDownloadShelf::TestDownloadShelf(Profile* profile)
: DownloadShelf(nullptr, profile), : DownloadShelf(nullptr, profile) {}
is_showing_(false),
did_add_download_(false) {}
TestDownloadShelf::~TestDownloadShelf() = default; TestDownloadShelf::~TestDownloadShelf() = default;
......
...@@ -36,8 +36,8 @@ class TestDownloadShelf : public DownloadShelf { ...@@ -36,8 +36,8 @@ class TestDownloadShelf : public DownloadShelf {
base::TimeDelta GetTransientDownloadShowDelay() const override; base::TimeDelta GetTransientDownloadShowDelay() const override;
private: private:
bool is_showing_; bool is_showing_ = false;
bool did_add_download_; bool did_add_download_ = false;
}; };
#endif // CHROME_BROWSER_DOWNLOAD_TEST_DOWNLOAD_SHELF_H_ #endif // CHROME_BROWSER_DOWNLOAD_TEST_DOWNLOAD_SHELF_H_
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "ui/views/controls/button/image_button_factory.h" #include "ui/views/controls/button/image_button_factory.h"
#include "ui/views/controls/button/md_text_button.h" #include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/link.h" #include "ui/views/controls/link.h"
#include "ui/views/mouse_watcher_view_host.h"
using download::DownloadItem; using download::DownloadItem;
...@@ -61,12 +60,7 @@ constexpr int kCloseAndLinkPadding = 6; ...@@ -61,12 +60,7 @@ constexpr int kCloseAndLinkPadding = 6;
DownloadShelfView::DownloadShelfView(Browser* browser, BrowserView* parent) DownloadShelfView::DownloadShelfView(Browser* browser, BrowserView* parent)
: DownloadShelf(browser, browser->profile()), : DownloadShelf(browser, browser->profile()),
AnimationDelegateViews(this), AnimationDelegateViews(this),
new_item_animation_(this), parent_(parent) {
shelf_animation_(this),
parent_(parent),
mouse_watcher_(
std::make_unique<views::MouseWatcherViewHost>(this, gfx::Insets()),
this) {
// Start out hidden: the shelf might be created but never shown in some // Start out hidden: the shelf might be created but never shown in some
// cases, like when installing a theme. See DownloadShelf::AddDownload(). // cases, like when installing a theme. See DownloadShelf::AddDownload().
SetVisible(false); SetVisible(false);
......
...@@ -5,14 +5,17 @@ ...@@ -5,14 +5,17 @@
#ifndef CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ #ifndef CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ #define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_
#include <memory>
#include <vector> #include <vector>
#include "chrome/browser/download/download_shelf.h" #include "chrome/browser/download/download_shelf.h"
#include "ui/gfx/animation/slide_animation.h" #include "ui/gfx/animation/slide_animation.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/accessible_pane_view.h" #include "ui/views/accessible_pane_view.h"
#include "ui/views/animation/animation_delegate_views.h" #include "ui/views/animation/animation_delegate_views.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
#include "ui/views/mouse_watcher.h" #include "ui/views/mouse_watcher.h"
#include "ui/views/mouse_watcher_view_host.h"
class Browser; class Browser;
class BrowserView; class BrowserView;
...@@ -85,17 +88,17 @@ class DownloadShelfView : public DownloadShelf, ...@@ -85,17 +88,17 @@ class DownloadShelfView : public DownloadShelf,
FRIEND_TEST_ALL_PREFIXES(DownloadShelfViewTest, ShowAllViewColors); FRIEND_TEST_ALL_PREFIXES(DownloadShelfViewTest, ShowAllViewColors);
// The animation for adding new items to the shelf. // The animation for adding new items to the shelf.
gfx::SlideAnimation new_item_animation_; gfx::SlideAnimation new_item_animation_{this};
// The show/hide animation for the shelf itself. // The show/hide animation for the shelf itself.
gfx::SlideAnimation shelf_animation_; gfx::SlideAnimation shelf_animation_{this};
// The download views. These are also child Views, and deleted when // The download views. These are also child Views, and deleted when
// the DownloadShelfView is deleted. // the DownloadShelfView is deleted.
std::vector<DownloadItemView*> download_views_; std::vector<DownloadItemView*> download_views_;
// Button for showing all downloads (chrome://downloads). // Button for showing all downloads (chrome://downloads).
views::MdTextButton* show_all_view_ = nullptr; views::MdTextButton* show_all_view_;
// Button for closing the downloads. This is contained as a child, and // Button for closing the downloads. This is contained as a child, and
// deleted by View. // deleted by View.
...@@ -108,7 +111,8 @@ class DownloadShelfView : public DownloadShelf, ...@@ -108,7 +111,8 @@ class DownloadShelfView : public DownloadShelf,
// The window this shelf belongs to. // The window this shelf belongs to.
BrowserView* parent_; BrowserView* parent_;
views::MouseWatcher mouse_watcher_; views::MouseWatcher mouse_watcher_{
std::make_unique<views::MouseWatcherViewHost>(this, gfx::Insets()), this};
}; };
#endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment