Commit 094453bd authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Try to improve comments and temp/param names.

Also makes one or two functions const.

Bug: none
Change-Id: I9a67f5f5839aef92468342c0dfcba36da864d4b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2348195
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797488}
parent 76cb81a0
...@@ -60,17 +60,15 @@ class DownloadShelf { ...@@ -60,17 +60,15 @@ class DownloadShelf {
// Closes the shelf. // Closes the shelf.
void Close(); void Close();
// Hides the shelf. This closes the shelf if it is currently showing. // Closes the shelf and prevents it from reopening until Unhide() is called.
void Hide(); void Hide();
// Unhides the shelf. This will cause the shelf to be opened if it was open // Allows the shelf to open after a previous call to Hide(). Opens the shelf
// when it was hidden, or was shown while it was hidden. // if, had Hide() not been called, it would currently be open.
void Unhide(); void Unhide();
Browser* browser() { return browser_; } Browser* browser() { return browser_; }
bool is_hidden() const { return is_hidden_; }
// Returns whether the download shelf is hidden.
bool is_hidden() { return is_hidden_; }
protected: protected:
virtual void DoShowDownload(DownloadUIModel::DownloadUIModelPtr download) = 0; virtual void DoShowDownload(DownloadUIModel::DownloadUIModelPtr download) = 0;
...@@ -86,7 +84,7 @@ class DownloadShelf { ...@@ -86,7 +84,7 @@ class DownloadShelf {
Profile* profile() { return profile_; } Profile* profile() { return profile_; }
private: private:
// Show the download on the shelf immediately. Also displayes the download // Shows the download on the shelf immediately. Also displays the download
// started animation if necessary. // started animation if necessary.
void ShowDownload(DownloadUIModel::DownloadUIModelPtr download); void ShowDownload(DownloadUIModel::DownloadUIModelPtr download);
......
...@@ -21,7 +21,6 @@ class TestDownloadShelf : public DownloadShelf { ...@@ -21,7 +21,6 @@ class TestDownloadShelf : public DownloadShelf {
bool IsShowing() const override; bool IsShowing() const override;
bool IsClosing() const override; bool IsClosing() const override;
// Return |true| if a download was added to this shelf.
bool did_add_download() const { return did_add_download_; } bool did_add_download() const { return did_add_download_; }
protected: protected:
......
...@@ -461,9 +461,9 @@ void DownloadItemView::OnDownloadUpdated() { ...@@ -461,9 +461,9 @@ void DownloadItemView::OnDownloadUpdated() {
return; return;
} }
base::string16 new_tip = model_->GetTooltipText(); const base::string16 new_tooltip_text = model_->GetTooltipText();
if (new_tip != tooltip_text_) { if (new_tooltip_text != tooltip_text_) {
tooltip_text_ = new_tip; tooltip_text_ = new_tooltip_text;
TooltipTextChanged(); TooltipTextChanged();
} }
} }
...@@ -508,10 +508,10 @@ void DownloadItemView::AnimationEnded(const gfx::Animation* animation) { ...@@ -508,10 +508,10 @@ void DownloadItemView::AnimationEnded(const gfx::Animation* animation) {
} }
void DownloadItemView::MaybeSubmitDownloadToFeedbackService( void DownloadItemView::MaybeSubmitDownloadToFeedbackService(
DownloadCommands::Command download_command) { DownloadCommands::Command command) {
if (!model_->ShouldAllowDownloadFeedback() || if (!model_->ShouldAllowDownloadFeedback() ||
!SubmitDownloadToFeedbackService(download_command)) !SubmitDownloadToFeedbackService(command))
ExecuteCommand(download_command); ExecuteCommand(command);
} }
gfx::Size DownloadItemView::CalculatePreferredSize() const { gfx::Size DownloadItemView::CalculatePreferredSize() const {
...@@ -1183,22 +1183,21 @@ void DownloadItemView::OpenDownloadDuringAsyncScanning() { ...@@ -1183,22 +1183,21 @@ void DownloadItemView::OpenDownloadDuringAsyncScanning() {
} }
bool DownloadItemView::SubmitDownloadToFeedbackService( bool DownloadItemView::SubmitDownloadToFeedbackService(
DownloadCommands::Command download_command) { DownloadCommands::Command command) const {
#if BUILDFLAG(FULL_SAFE_BROWSING) #if BUILDFLAG(FULL_SAFE_BROWSING)
safe_browsing::SafeBrowsingService* sb_service = safe_browsing::SafeBrowsingService* sb_service =
g_browser_process->safe_browsing_service(); g_browser_process->safe_browsing_service();
if (!sb_service) if (!sb_service)
return false; return false;
safe_browsing::DownloadProtectionService* download_protection_service = safe_browsing::DownloadProtectionService* dp_service =
sb_service->download_protection_service(); sb_service->download_protection_service();
if (!download_protection_service) if (!dp_service)
return false; return false;
// TODO(shaktisahu): Enable feedback service for offline item. // TODO(shaktisahu): Enable feedback service for offline item.
if (model_->download()) { if (model_->download()) {
return download_protection_service->MaybeBeginFeedbackForDownload( return dp_service->MaybeBeginFeedbackForDownload(
shelf_->browser()->profile(), model_->download(), download_command); shelf_->browser()->profile(), model_->download(), command);
} }
// WARNING: |this| has been deleted!
return true; return true;
#else #else
NOTREACHED(); NOTREACHED();
......
...@@ -105,10 +105,9 @@ class DownloadItemView : public views::View, ...@@ -105,10 +105,9 @@ class DownloadItemView : public views::View,
const DownloadUIModel* model() const { return model_.get(); } const DownloadUIModel* model() const { return model_.get(); }
// Submits download to download feedback service if the user has approved and // Submits download to download feedback service if the user has approved and
// the download is suitable for submission, then applies |download_command|. // the download is suitable for submission, then applies |command|.
// If user hasn't seen SBER opt-in text before, show SBER opt-in dialog first. // If user hasn't seen SBER opt-in text before, show SBER opt-in dialog first.
void MaybeSubmitDownloadToFeedbackService( void MaybeSubmitDownloadToFeedbackService(DownloadCommands::Command command);
DownloadCommands::Command download_command);
protected: protected:
// views::View: // views::View:
...@@ -170,7 +169,7 @@ class DownloadItemView : public views::View, ...@@ -170,7 +169,7 @@ class DownloadItemView : public views::View,
// buttons are given the same size). // buttons are given the same size).
gfx::Size GetButtonSize() const; gfx::Size GetButtonSize() const;
// Returns the file name to report to user. It might be elided to fit into // Returns the file name to report to the user. It might be elided to fit into
// the text width. |label| dictates the default text style. // the text width. |label| dictates the default text style.
base::string16 ElidedFilename(const views::StyledLabel& label) const; base::string16 ElidedFilename(const views::StyledLabel& label) const;
...@@ -202,10 +201,9 @@ class DownloadItemView : public views::View, ...@@ -202,10 +201,9 @@ class DownloadItemView : public views::View,
void OpenDownloadDuringAsyncScanning(); void OpenDownloadDuringAsyncScanning();
// Submits the downloaded file to the safebrowsing download feedback service. // Submits the downloaded file to the safebrowsing download feedback service.
// Applies |download_command| if submission succeeds. Returns whether // Applies |command| if submission succeeds. Returns whether submission was
// submission was successful. // successful.
bool SubmitDownloadToFeedbackService( bool SubmitDownloadToFeedbackService(DownloadCommands::Command command) const;
DownloadCommands::Command download_command);
// Forwards |command| to |commands_|; useful for callbacks. // Forwards |command| to |commands_|; useful for callbacks.
void ExecuteCommand(DownloadCommands::Command command); void ExecuteCommand(DownloadCommands::Command command);
......
...@@ -242,15 +242,15 @@ void DownloadShelfView::AnimationEnded(const gfx::Animation* animation) { ...@@ -242,15 +242,15 @@ void DownloadShelfView::AnimationEnded(const gfx::Animation* animation) {
} }
} }
// If we had keyboard focus, calling SetVisible(false) causes keyboard focus // Make the shelf non-visible.
// to be completely lost. To prevent this, we focus another view: the web //
// contents. TODO(collinbaker): https://crbug.com/846466 Fix // If we had keyboard focus, calling SetVisible(false) will cause keyboard
// AccessiblePaneView::SetVisible or FocusManager to make this unnecessary. // focus to be completely lost. To prevent this, focus the web contents.
// TODO(crbug.com/846466): Fix AccessiblePaneView::SetVisible() or
// FocusManager to make this unnecessary.
auto* focus_manager = GetFocusManager(); auto* focus_manager = GetFocusManager();
if (focus_manager && Contains(focus_manager->GetFocusedView())) { if (focus_manager && Contains(focus_manager->GetFocusedView()))
parent_->contents_web_view()->RequestFocus(); parent_->contents_web_view()->RequestFocus();
}
SetVisible(false); SetVisible(false);
} }
......
...@@ -95,6 +95,8 @@ class DownloadShelfView : public DownloadShelf, ...@@ -95,6 +95,8 @@ class DownloadShelfView : public DownloadShelf,
// 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.
// TODO(pkasting): Remove this in favor of making these the children of a
// nested view, so they can easily be laid out and iterated.
std::vector<DownloadItemView*> download_views_; std::vector<DownloadItemView*> download_views_;
// Button for showing all downloads (chrome://downloads). // Button for showing all downloads (chrome://downloads).
......
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