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

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: rebase Created 7 years, 3 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/file_manager_installer .h"
12 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 13 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.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 extensions { 22 namespace extensions {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } else if (operation == "reset") { 198 } else if (operation == "reset") {
198 zoom_type = content::PAGE_ZOOM_RESET; 199 zoom_type = content::PAGE_ZOOM_RESET;
199 } else { 200 } else {
200 NOTREACHED(); 201 NOTREACHED();
201 return false; 202 return false;
202 } 203 }
203 view_host->Zoom(zoom_type); 204 view_host->Zoom(zoom_type);
204 return true; 205 return true;
205 } 206 }
206 207
208 FileBrowserPrivateInstallWebstoreItemFunction::
209 FileBrowserPrivateInstallWebstoreItemFunction() {
210 }
211
212 FileBrowserPrivateInstallWebstoreItemFunction::
213 ~FileBrowserPrivateInstallWebstoreItemFunction() {
214 }
215
216 bool FileBrowserPrivateInstallWebstoreItemFunction::RunImpl() {
217 if (args_->GetSize() < 1)
218 return false;
219
220 if (!args_->GetString(0, &webstore_item_id_) || webstore_item_id_.empty())
221 return false;
222
223 extensions::WebstoreStandaloneInstaller::Callback callback =
224 base::Bind(
225 &FileBrowserPrivateInstallWebstoreItemFunction::OnInstallComplete,
226 this);
227
228 scoped_refptr<file_manager::FileManagerInstaller> installer(
229 new file_manager::FileManagerInstaller(
230 GetAssociatedWebContents(), // web_contents(),
231 webstore_item_id_,
232 profile(),
233 callback));
234 // installer will be AddRef()'d in BeginInstall().
235 installer->BeginInstall();
236 return true;
237 }
238
239 void FileBrowserPrivateInstallWebstoreItemFunction::OnInstallComplete(
240 bool success,
241 const std::string& error) {
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 error_ = error;
252 }
253
254 SendResponse(success);
255 }
256
207 } // namespace extensions 257 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698