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

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

Issue 10545064: TabContentsWrapper -> TabContents, part 11. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
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/browser_dialogs.h" 9 #include "chrome/browser/ui/browser_dialogs.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents.h"
11 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" 11 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/download_danger_type.h" 13 #include "content/public/browser/download_danger_type.h"
14 #include "content/public/browser/download_item.h" 14 #include "content/public/browser/download_item.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 17
18 namespace { 18 namespace {
19 19
20 // Implements DownloadDangerPrompt using a TabModalConfirmDialog. 20 // Implements DownloadDangerPrompt using a TabModalConfirmDialog.
21 class DownloadDangerPromptImpl 21 class DownloadDangerPromptImpl
22 : public DownloadDangerPrompt, 22 : public DownloadDangerPrompt,
23 public content::DownloadItem::Observer, 23 public content::DownloadItem::Observer,
24 public TabModalConfirmDialogDelegate { 24 public TabModalConfirmDialogDelegate {
25 public: 25 public:
26 DownloadDangerPromptImpl(content::DownloadItem* item, 26 DownloadDangerPromptImpl(content::DownloadItem* item,
27 TabContentsWrapper* tab_contents_wrapper, 27 TabContents* tab_contents,
28 const base::Closure& accepted, 28 const base::Closure& accepted,
29 const base::Closure& canceled); 29 const base::Closure& canceled);
30 virtual ~DownloadDangerPromptImpl(); 30 virtual ~DownloadDangerPromptImpl();
31 31
32 // DownloadDangerPrompt 32 // DownloadDangerPrompt
33 virtual void InvokeActionForTesting(Action action) OVERRIDE; 33 virtual void InvokeActionForTesting(Action action) OVERRIDE;
34 34
35 private: 35 private:
36 // content::DownloadItem::Observer 36 // content::DownloadItem::Observer
37 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; 37 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE;
(...skipping 18 matching lines...) Expand all
56 56
57 content::DownloadItem* download_; 57 content::DownloadItem* download_;
58 base::Closure accepted_; 58 base::Closure accepted_;
59 base::Closure canceled_; 59 base::Closure canceled_;
60 60
61 DISALLOW_COPY_AND_ASSIGN(DownloadDangerPromptImpl); 61 DISALLOW_COPY_AND_ASSIGN(DownloadDangerPromptImpl);
62 }; 62 };
63 63
64 DownloadDangerPromptImpl::DownloadDangerPromptImpl( 64 DownloadDangerPromptImpl::DownloadDangerPromptImpl(
65 content::DownloadItem* download, 65 content::DownloadItem* download,
66 TabContentsWrapper* tab_contents_wrapper, 66 TabContents* tab_contents,
67 const base::Closure& accepted, 67 const base::Closure& accepted,
68 const base::Closure& canceled) 68 const base::Closure& canceled)
69 : TabModalConfirmDialogDelegate(tab_contents_wrapper->web_contents()), 69 : TabModalConfirmDialogDelegate(tab_contents->web_contents()),
70 download_(download), 70 download_(download),
71 accepted_(accepted), 71 accepted_(accepted),
72 canceled_(canceled) { 72 canceled_(canceled) {
73 DCHECK(!accepted_.is_null()); 73 DCHECK(!accepted_.is_null());
74 // canceled_ is allowed to be null. 74 // canceled_ is allowed to be null.
75 DCHECK(download_); 75 DCHECK(download_);
76 download_->AddObserver(this); 76 download_->AddObserver(this);
77 } 77 }
78 78
79 DownloadDangerPromptImpl::~DownloadDangerPromptImpl() { 79 DownloadDangerPromptImpl::~DownloadDangerPromptImpl() {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 download_->RemoveObserver(this); 138 download_->RemoveObserver(this);
139 download_ = NULL; 139 download_ = NULL;
140 } 140 }
141 } 141 }
142 142
143 } // namespace 143 } // namespace
144 144
145 // static 145 // static
146 DownloadDangerPrompt* DownloadDangerPrompt::Create( 146 DownloadDangerPrompt* DownloadDangerPrompt::Create(
147 content::DownloadItem* item, 147 content::DownloadItem* item,
148 TabContentsWrapper* tab_contents_wrapper, 148 TabContents* tab_contents,
149 const base::Closure& accepted, 149 const base::Closure& accepted,
150 const base::Closure& canceled) { 150 const base::Closure& canceled) {
151 DownloadDangerPromptImpl* prompt = 151 DownloadDangerPromptImpl* prompt =
152 new DownloadDangerPromptImpl(item, tab_contents_wrapper, 152 new DownloadDangerPromptImpl(item, tab_contents, accepted, canceled);
153 accepted, canceled);
154 // |prompt| will be deleted when the dialog is done. 153 // |prompt| will be deleted when the dialog is done.
155 browser::ShowTabModalConfirmDialog(prompt, tab_contents_wrapper); 154 browser::ShowTabModalConfirmDialog(prompt, tab_contents);
156 return prompt; 155 return prompt;
157 } 156 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_danger_prompt.h ('k') | chrome/browser/download/download_danger_prompt_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698