OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/extension_reenabler.h" | 5 #include "chrome/browser/extensions/extension_reenabler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/webstore_data_fetcher.h" | 10 #include "chrome/browser/extensions/webstore_data_fetcher.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 extension->id())); | 90 extension->id())); |
91 webstore_data_fetcher_->Start(); | 91 webstore_data_fetcher_->Start(); |
92 } else { | 92 } else { |
93 ExtensionInstallPrompt::PromptType type = | 93 ExtensionInstallPrompt::PromptType type = |
94 ExtensionInstallPrompt::GetReEnablePromptTypeForExtension( | 94 ExtensionInstallPrompt::GetReEnablePromptTypeForExtension( |
95 browser_context, extension.get()); | 95 browser_context, extension.get()); |
96 install_prompt_->ShowDialog( | 96 install_prompt_->ShowDialog( |
97 base::Bind(&ExtensionReenabler::OnInstallPromptDone, | 97 base::Bind(&ExtensionReenabler::OnInstallPromptDone, |
98 weak_factory_.GetWeakPtr()), | 98 weak_factory_.GetWeakPtr()), |
99 extension.get(), nullptr, | 99 extension.get(), nullptr, |
100 base::WrapUnique(new ExtensionInstallPrompt::Prompt(type)), | 100 base::MakeUnique<ExtensionInstallPrompt::Prompt>(type), |
101 show_dialog_callback_); | 101 show_dialog_callback_); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 void ExtensionReenabler::OnInstallPromptDone( | 105 void ExtensionReenabler::OnInstallPromptDone( |
106 ExtensionInstallPrompt::Result install_result) { | 106 ExtensionInstallPrompt::Result install_result) { |
107 ReenableResult result = ABORTED; | 107 ReenableResult result = ABORTED; |
108 switch (install_result) { | 108 switch (install_result) { |
109 case ExtensionInstallPrompt::Result::ACCEPTED: { | 109 case ExtensionInstallPrompt::Result::ACCEPTED: { |
110 // Stop observing - we don't want to see our own enablement. | 110 // Stop observing - we don't want to see our own enablement. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 &error)) { | 166 &error)) { |
167 Finish(NOT_ALLOWED); | 167 Finish(NOT_ALLOWED); |
168 } else { | 168 } else { |
169 ExtensionInstallPrompt::PromptType type = | 169 ExtensionInstallPrompt::PromptType type = |
170 ExtensionInstallPrompt::GetReEnablePromptTypeForExtension( | 170 ExtensionInstallPrompt::GetReEnablePromptTypeForExtension( |
171 browser_context_, extension_.get()); | 171 browser_context_, extension_.get()); |
172 install_prompt_->ShowDialog( | 172 install_prompt_->ShowDialog( |
173 base::Bind(&ExtensionReenabler::OnInstallPromptDone, | 173 base::Bind(&ExtensionReenabler::OnInstallPromptDone, |
174 weak_factory_.GetWeakPtr()), | 174 weak_factory_.GetWeakPtr()), |
175 extension_.get(), nullptr, | 175 extension_.get(), nullptr, |
176 base::WrapUnique(new ExtensionInstallPrompt::Prompt(type)), | 176 base::MakeUnique<ExtensionInstallPrompt::Prompt>(type), |
177 show_dialog_callback_); | 177 show_dialog_callback_); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 void ExtensionReenabler::OnWebstoreResponseParseFailure( | 181 void ExtensionReenabler::OnWebstoreResponseParseFailure( |
182 const std::string& error) { | 182 const std::string& error) { |
183 Finish(ABORTED); | 183 Finish(ABORTED); |
184 } | 184 } |
185 | 185 |
186 void ExtensionReenabler::Finish(ReenableResult result) { | 186 void ExtensionReenabler::Finish(ReenableResult result) { |
187 DCHECK(!finished_); | 187 DCHECK(!finished_); |
188 finished_ = true; | 188 finished_ = true; |
189 registry_observer_.RemoveAll(); | 189 registry_observer_.RemoveAll(); |
190 callback_.Run(result); | 190 callback_.Run(result); |
191 } | 191 } |
192 | 192 |
193 } // namespace extensions | 193 } // namespace extensions |
OLD | NEW |