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

Side by Side Diff: chrome/browser/plugins/plugin_installer.cc

Issue 2438513002: Remove FOR_EACH_OBSERVER macro usage in chrome/browser/supervised_user (Closed)
Patch Set: Created 4 years, 2 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/plugins/plugin_installer.h" 5 #include "chrome/browser/plugins/plugin_installer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 31
32 void PluginInstaller::OnDownloadUpdated(DownloadItem* download) { 32 void PluginInstaller::OnDownloadUpdated(DownloadItem* download) {
33 DownloadItem::DownloadState state = download->GetState(); 33 DownloadItem::DownloadState state = download->GetState();
34 switch (state) { 34 switch (state) {
35 case DownloadItem::IN_PROGRESS: 35 case DownloadItem::IN_PROGRESS:
36 return; 36 return;
37 case DownloadItem::COMPLETE: { 37 case DownloadItem::COMPLETE: {
38 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 38 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
39 state_ = INSTALLER_STATE_IDLE; 39 state_ = INSTALLER_STATE_IDLE;
40 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, 40 for (PluginInstallerObserver& observer : observers_)
41 DownloadFinished()); 41 observer.DownloadFinished();
42 break; 42 break;
43 } 43 }
44 case DownloadItem::CANCELLED: { 44 case DownloadItem::CANCELLED: {
45 DownloadCancelled(); 45 DownloadCancelled();
46 break; 46 break;
47 } 47 }
48 case DownloadItem::INTERRUPTED: { 48 case DownloadItem::INTERRUPTED: {
49 content::DownloadInterruptReason reason = download->GetLastReason(); 49 content::DownloadInterruptReason reason = download->GetLastReason();
50 DownloadError(content::DownloadInterruptReasonToString(reason)); 50 DownloadError(content::DownloadInterruptReasonToString(reason));
51 break; 51 break;
(...skipping 14 matching lines...) Expand all
66 66
67 void PluginInstaller::AddObserver(PluginInstallerObserver* observer) { 67 void PluginInstaller::AddObserver(PluginInstallerObserver* observer) {
68 strong_observer_count_++; 68 strong_observer_count_++;
69 observers_.AddObserver(observer); 69 observers_.AddObserver(observer);
70 } 70 }
71 71
72 void PluginInstaller::RemoveObserver(PluginInstallerObserver* observer) { 72 void PluginInstaller::RemoveObserver(PluginInstallerObserver* observer) {
73 strong_observer_count_--; 73 strong_observer_count_--;
74 observers_.RemoveObserver(observer); 74 observers_.RemoveObserver(observer);
75 if (strong_observer_count_ == 0) { 75 if (strong_observer_count_ == 0) {
76 FOR_EACH_OBSERVER(WeakPluginInstallerObserver, weak_observers_, 76 for (WeakPluginInstallerObserver& observer : weak_observers_)
77 OnlyWeakObserversLeft()); 77 observer.OnlyWeakObserversLeft();
78 } 78 }
79 } 79 }
80 80
81 void PluginInstaller::AddWeakObserver(WeakPluginInstallerObserver* observer) { 81 void PluginInstaller::AddWeakObserver(WeakPluginInstallerObserver* observer) {
82 weak_observers_.AddObserver(observer); 82 weak_observers_.AddObserver(observer);
83 } 83 }
84 84
85 void PluginInstaller::RemoveWeakObserver( 85 void PluginInstaller::RemoveWeakObserver(
86 WeakPluginInstallerObserver* observer) { 86 WeakPluginInstallerObserver* observer) {
87 weak_observers_.RemoveObserver(observer); 87 weak_observers_.RemoveObserver(observer);
88 } 88 }
89 89
90 void PluginInstaller::StartInstalling(const GURL& plugin_url, 90 void PluginInstaller::StartInstalling(const GURL& plugin_url,
91 content::WebContents* web_contents) { 91 content::WebContents* web_contents) {
92 content::DownloadManager* download_manager = 92 content::DownloadManager* download_manager =
93 content::BrowserContext::GetDownloadManager( 93 content::BrowserContext::GetDownloadManager(
94 web_contents->GetBrowserContext()); 94 web_contents->GetBrowserContext());
95 StartInstallingWithDownloadManager( 95 StartInstallingWithDownloadManager(
96 plugin_url, web_contents, download_manager); 96 plugin_url, web_contents, download_manager);
97 } 97 }
98 98
99 void PluginInstaller::StartInstallingWithDownloadManager( 99 void PluginInstaller::StartInstallingWithDownloadManager(
100 const GURL& plugin_url, 100 const GURL& plugin_url,
101 content::WebContents* web_contents, 101 content::WebContents* web_contents,
102 content::DownloadManager* download_manager) { 102 content::DownloadManager* download_manager) {
103 DCHECK_EQ(INSTALLER_STATE_IDLE, state_); 103 DCHECK_EQ(INSTALLER_STATE_IDLE, state_);
104 state_ = INSTALLER_STATE_DOWNLOADING; 104 state_ = INSTALLER_STATE_DOWNLOADING;
105 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadStarted()); 105 for (PluginInstallerObserver& observer : observers_)
106 observer.DownloadStarted();
106 std::unique_ptr<content::DownloadUrlParameters> download_parameters( 107 std::unique_ptr<content::DownloadUrlParameters> download_parameters(
107 content::DownloadUrlParameters::CreateForWebContentsMainFrame( 108 content::DownloadUrlParameters::CreateForWebContentsMainFrame(
108 web_contents, plugin_url)); 109 web_contents, plugin_url));
109 download_parameters->set_callback( 110 download_parameters->set_callback(
110 base::Bind(&PluginInstaller::DownloadStarted, base::Unretained(this))); 111 base::Bind(&PluginInstaller::DownloadStarted, base::Unretained(this)));
111 RecordDownloadSource(DOWNLOAD_INITIATED_BY_PLUGIN_INSTALLER); 112 RecordDownloadSource(DOWNLOAD_INITIATED_BY_PLUGIN_INSTALLER);
112 download_manager->DownloadUrl(std::move(download_parameters)); 113 download_manager->DownloadUrl(std::move(download_parameters));
113 } 114 }
114 115
115 void PluginInstaller::DownloadStarted( 116 void PluginInstaller::DownloadStarted(
(...skipping 12 matching lines...) Expand all
128 } 129 }
129 130
130 void PluginInstaller::OpenDownloadURL(const GURL& plugin_url, 131 void PluginInstaller::OpenDownloadURL(const GURL& plugin_url,
131 content::WebContents* web_contents) { 132 content::WebContents* web_contents) {
132 DCHECK_EQ(INSTALLER_STATE_IDLE, state_); 133 DCHECK_EQ(INSTALLER_STATE_IDLE, state_);
133 web_contents->OpenURL(content::OpenURLParams( 134 web_contents->OpenURL(content::OpenURLParams(
134 plugin_url, content::Referrer(web_contents->GetURL(), 135 plugin_url, content::Referrer(web_contents->GetURL(),
135 blink::WebReferrerPolicyDefault), 136 blink::WebReferrerPolicyDefault),
136 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_TYPED, 137 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_TYPED,
137 false)); 138 false));
138 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadFinished()); 139 for (PluginInstallerObserver& observer : observers_)
140 observer.DownloadFinished();
139 } 141 }
140 142
141 void PluginInstaller::DownloadError(const std::string& msg) { 143 void PluginInstaller::DownloadError(const std::string& msg) {
142 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 144 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
143 state_ = INSTALLER_STATE_IDLE; 145 state_ = INSTALLER_STATE_IDLE;
144 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg)); 146 for (PluginInstallerObserver& observer : observers_)
147 observer.DownloadError(msg);
145 } 148 }
146 149
147 void PluginInstaller::DownloadCancelled() { 150 void PluginInstaller::DownloadCancelled() {
148 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 151 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
149 state_ = INSTALLER_STATE_IDLE; 152 state_ = INSTALLER_STATE_IDLE;
150 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); 153 for (PluginInstallerObserver& observer : observers_)
154 observer.DownloadCancelled();
151 } 155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698