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

Side by Side Diff: chrome/browser/download/download_danger_prompt.cc

Issue 18786005: Cleanup: remove redundant tab close observation from TabModalConfirmDialogDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/plugins/plugin_observer.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 "chrome/browser/download/download_danger_prompt.h" 5 #include "chrome/browser/download/download_danger_prompt.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/download/chrome_download_manager_delegate.h" 8 #include "chrome/browser/download/chrome_download_manager_delegate.h"
9 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" 9 #include "chrome/browser/ui/tab_modal_confirm_dialog.h"
10 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" 10 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
11 #include "content/public/browser/download_danger_type.h" 11 #include "content/public/browser/download_danger_type.h"
12 #include "content/public/browser/download_item.h" 12 #include "content/public/browser/download_item.h"
13 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 15
16 namespace { 16 namespace {
17 17
18 // Implements DownloadDangerPrompt using a TabModalConfirmDialog. 18 // Implements DownloadDangerPrompt using a TabModalConfirmDialog.
19 class DownloadDangerPromptImpl 19 class DownloadDangerPromptImpl
20 : public DownloadDangerPrompt, 20 : public DownloadDangerPrompt,
21 public content::DownloadItem::Observer, 21 public content::DownloadItem::Observer,
22 public TabModalConfirmDialogDelegate { 22 public TabModalConfirmDialogDelegate {
23 public: 23 public:
24 DownloadDangerPromptImpl(content::DownloadItem* item, 24 DownloadDangerPromptImpl(content::DownloadItem* item,
25 content::WebContents* web_contents,
26 bool show_context, 25 bool show_context,
27 const base::Closure& accepted, 26 const base::Closure& accepted,
28 const base::Closure& canceled); 27 const base::Closure& canceled);
29 virtual ~DownloadDangerPromptImpl(); 28 virtual ~DownloadDangerPromptImpl();
30 29
31 // DownloadDangerPrompt 30 // DownloadDangerPrompt
32 virtual void InvokeActionForTesting(Action action) OVERRIDE; 31 virtual void InvokeActionForTesting(Action action) OVERRIDE;
33 32
34 private: 33 private:
35 // content::DownloadItem::Observer 34 // content::DownloadItem::Observer
(...skipping 20 matching lines...) Expand all
56 content::DownloadItem* download_; 55 content::DownloadItem* download_;
57 bool show_context_; 56 bool show_context_;
58 base::Closure accepted_; 57 base::Closure accepted_;
59 base::Closure canceled_; 58 base::Closure canceled_;
60 59
61 DISALLOW_COPY_AND_ASSIGN(DownloadDangerPromptImpl); 60 DISALLOW_COPY_AND_ASSIGN(DownloadDangerPromptImpl);
62 }; 61 };
63 62
64 DownloadDangerPromptImpl::DownloadDangerPromptImpl( 63 DownloadDangerPromptImpl::DownloadDangerPromptImpl(
65 content::DownloadItem* download, 64 content::DownloadItem* download,
66 content::WebContents* web_contents,
67 bool show_context, 65 bool show_context,
68 const base::Closure& accepted, 66 const base::Closure& accepted,
69 const base::Closure& canceled) 67 const base::Closure& canceled)
70 : TabModalConfirmDialogDelegate(web_contents), 68 : download_(download),
71 download_(download),
72 show_context_(show_context), 69 show_context_(show_context),
73 accepted_(accepted), 70 accepted_(accepted),
74 canceled_(canceled) { 71 canceled_(canceled) {
75 DCHECK(!accepted_.is_null()); 72 DCHECK(!accepted_.is_null());
76 // canceled_ is allowed to be null. 73 // canceled_ is allowed to be null.
77 DCHECK(download_); 74 DCHECK(download_);
78 download_->AddObserver(this); 75 download_->AddObserver(this);
79 } 76 }
80 77
81 DownloadDangerPromptImpl::~DownloadDangerPromptImpl() { 78 DownloadDangerPromptImpl::~DownloadDangerPromptImpl() {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } // namespace 165 } // namespace
169 166
170 // static 167 // static
171 DownloadDangerPrompt* DownloadDangerPrompt::Create( 168 DownloadDangerPrompt* DownloadDangerPrompt::Create(
172 content::DownloadItem* item, 169 content::DownloadItem* item,
173 content::WebContents* web_contents, 170 content::WebContents* web_contents,
174 bool show_context, 171 bool show_context,
175 const base::Closure& accepted, 172 const base::Closure& accepted,
176 const base::Closure& canceled) { 173 const base::Closure& canceled) {
177 DownloadDangerPromptImpl* prompt = new DownloadDangerPromptImpl( 174 DownloadDangerPromptImpl* prompt = new DownloadDangerPromptImpl(
178 item, web_contents, show_context, accepted, canceled); 175 item, show_context, accepted, canceled);
179 // |prompt| will be deleted when the dialog is done. 176 // |prompt| will be deleted when the dialog is done.
180 TabModalConfirmDialog::Create(prompt, web_contents); 177 TabModalConfirmDialog::Create(prompt, web_contents);
181 return prompt; 178 return prompt;
182 } 179 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/plugins/plugin_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698