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

Side by Side Diff: chrome/browser/extensions/api/dashboard_private/dashboard_private_api.cc

Issue 1534123002: [Extensions] Migrate ExtensionInstallPrompt::Delegate to be a callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/api/dashboard_private/dashboard_private_api. h" 5 #include "chrome/browser/extensions/api/dashboard_private/dashboard_private_api. h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 Release(); 140 Release();
141 return; 141 return;
142 } 142 }
143 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt( 143 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt(
144 new ExtensionInstallPrompt::Prompt( 144 new ExtensionInstallPrompt::Prompt(
145 ExtensionInstallPrompt::DELEGATED_PERMISSIONS_PROMPT)); 145 ExtensionInstallPrompt::DELEGATED_PERMISSIONS_PROMPT));
146 prompt->set_delegated_username(details().delegated_user); 146 prompt->set_delegated_username(details().delegated_user);
147 147
148 install_prompt_.reset(new ExtensionInstallPrompt(web_contents)); 148 install_prompt_.reset(new ExtensionInstallPrompt(web_contents));
149 install_prompt_->ShowDialog( 149 install_prompt_->ShowDialog(
150 this, dummy_extension_.get(), &icon, std::move(prompt), 150 base::Bind(
151 &DashboardPrivateShowPermissionPromptForDelegatedInstallFunction::
152 OnInstallPromptDone,
153 this),
154 dummy_extension_.get(), &icon, std::move(prompt),
151 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); 155 ExtensionInstallPrompt::GetDefaultShowDialogCallback());
152 // Control flow finishes up in InstallUIProceed or InstallUIAbort. 156 // Control flow finishes up in OnInstallPromptDone().
153 } 157 }
154 158
155 void DashboardPrivateShowPermissionPromptForDelegatedInstallFunction:: 159 void DashboardPrivateShowPermissionPromptForDelegatedInstallFunction::
156 OnWebstoreParseFailure( 160 OnWebstoreParseFailure(
157 const std::string& id, 161 const std::string& id,
158 WebstoreInstallHelper::Delegate::InstallHelperResultCode result, 162 WebstoreInstallHelper::Delegate::InstallHelperResultCode result,
159 const std::string& error_message) { 163 const std::string& error_message) {
160 CHECK_EQ(params_->details.id, id); 164 CHECK_EQ(params_->details.id, id);
161 165
162 Respond(BuildResponse(WebstoreInstallHelperResultToApiResult(result), 166 Respond(BuildResponse(WebstoreInstallHelperResultToApiResult(result),
163 error_message)); 167 error_message));
164 168
165 // Matches the AddRef in Run(). 169 // Matches the AddRef in Run().
166 Release(); 170 Release();
167 } 171 }
168 172
169 void DashboardPrivateShowPermissionPromptForDelegatedInstallFunction:: 173 void DashboardPrivateShowPermissionPromptForDelegatedInstallFunction::
170 InstallUIProceed() { 174 OnInstallPromptDone(ExtensionInstallPrompt::Result result) {
171 Respond(BuildResponse(api::dashboard_private::RESULT_SUCCESS, std::string())); 175 if (result == ExtensionInstallPrompt::Result::ACCEPTED) {
176 Respond(
177 BuildResponse(api::dashboard_private::RESULT_SUCCESS, std::string()));
178 } else {
179 Respond(BuildResponse(api::dashboard_private::RESULT_USER_CANCELLED,
180 kUserCancelledError));
181 }
172 182
173 // Matches the AddRef in Run(). 183 Release(); // Matches the AddRef in Run().
174 Release();
175 }
176
177 void DashboardPrivateShowPermissionPromptForDelegatedInstallFunction::
178 InstallUIAbort(bool user_initiated) {
179 Respond(BuildResponse(api::dashboard_private::RESULT_USER_CANCELLED,
180 kUserCancelledError));
181
182 // Matches the AddRef in Run().
183 Release();
184 } 184 }
185 185
186 ExtensionFunction::ResponseValue 186 ExtensionFunction::ResponseValue
187 DashboardPrivateShowPermissionPromptForDelegatedInstallFunction::BuildResponse( 187 DashboardPrivateShowPermissionPromptForDelegatedInstallFunction::BuildResponse(
188 api::dashboard_private::Result result, const std::string& error) { 188 api::dashboard_private::Result result, const std::string& error) {
189 if (result != api::dashboard_private::RESULT_SUCCESS) 189 if (result != api::dashboard_private::RESULT_SUCCESS)
190 return ErrorWithArguments(CreateResults(result), error); 190 return ErrorWithArguments(CreateResults(result), error);
191 191
192 // The web store expects an empty string on success, so don't use 192 // The web store expects an empty string on success, so don't use
193 // RESULT_SUCCESS here. 193 // RESULT_SUCCESS here.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 ? kUserCancelledError 282 ? kUserCancelledError
283 : kInvalidBundleError)); 283 : kInvalidBundleError));
284 return; 284 return;
285 } 285 }
286 286
287 Respond(NoArguments()); 287 Respond(NoArguments());
288 } 288 }
289 289
290 } // namespace extensions 290 } // namespace extensions
291 291
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698