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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc

Issue 23332012: Add a private API method to install a webstore app from Files.app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chromeos/extensions/file_manager/private_api_misc.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_misc.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 10 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
11 #include "chrome/browser/chromeos/drive/logging.h" 11 #include "chrome/browser/chromeos/drive/logging.h"
12 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 12 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
13 #include "chrome/browser/chromeos/extensions/file_manager/webstore_app_installer .h"
13 #include "chrome/browser/chromeos/settings/cros_settings.h" 14 #include "chrome/browser/chromeos/settings/cros_settings.h"
14 #include "chrome/browser/lifetime/application_lifetime.h" 15 #include "chrome/browser/lifetime/application_lifetime.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
18 #include "content/public/common/page_zoom.h" 19 #include "content/public/common/page_zoom.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 namespace file_manager { 22 namespace file_manager {
22 23
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } else if (operation == "reset") { 195 } else if (operation == "reset") {
195 zoom_type = content::PAGE_ZOOM_RESET; 196 zoom_type = content::PAGE_ZOOM_RESET;
196 } else { 197 } else {
197 NOTREACHED(); 198 NOTREACHED();
198 return false; 199 return false;
199 } 200 }
200 view_host->Zoom(zoom_type); 201 view_host->Zoom(zoom_type);
201 return true; 202 return true;
202 } 203 }
203 204
205 InstallWebstoreAppFunction::InstallWebstoreAppFunction() {
206 }
207
208 InstallWebstoreAppFunction::~InstallWebstoreAppFunction() {
209 }
210
211 bool InstallWebstoreAppFunction::RunImpl() {
212 if (args_->GetSize() < 1) {
213 return false;
214 }
215
216 if (!args_->GetString(0, &webstore_item_id_) || webstore_item_id_.empty())
217 return false;
218
219 extensions::WebstoreStandaloneInstaller::Callback callback =
220 base::Bind(&InstallWebstoreAppFunction::OnInstallComplete,
221 base::Unretained(this));
222
223 scoped_refptr<WebstoreAppInstaller> installer(
224 new WebstoreAppInstaller(
225 GetAssociatedWebContents(), // web_contents(),
226 webstore_item_id_,
227 profile(),
228 callback));
229 // installer will be AddRef()'d in BeginInstall().
230 installer->BeginInstall();
231
232 AddRef(); // Balanced in Release() in OnInstallComplete.
233 return true;
234 }
235
236 void InstallWebstoreAppFunction::OnInstallComplete(bool success,
237 const std::string& error) {
238 scoped_ptr<DictionaryValue> result(new DictionaryValue());
239 result->SetBoolean("result", success);
240 result->SetString("error", error);
241
242 if (success) {
243 drive::util::Log(logging::LOG_INFO,
244 "App install succeeded. (item id: %s)",
245 webstore_item_id_.c_str());
246 } else {
247 drive::util::Log(logging::LOG_ERROR,
248 "App install failed. (item id: %s, reason: %s)",
249 webstore_item_id_.c_str(),
250 error.c_str());
251 }
252
253 SetResult(result.release());
254 SendResponse(success);
255
256 Release(); // Matches the AddRef in RunImpl.
257 }
258
204 } // namespace file_manager 259 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698