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

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: addressed comment 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 file_manager { 22 namespace file_manager {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } else if (operation == "reset") { 192 } else if (operation == "reset") {
192 zoom_type = content::PAGE_ZOOM_RESET; 193 zoom_type = content::PAGE_ZOOM_RESET;
193 } else { 194 } else {
194 NOTREACHED(); 195 NOTREACHED();
195 return false; 196 return false;
196 } 197 }
197 view_host->Zoom(zoom_type); 198 view_host->Zoom(zoom_type);
198 return true; 199 return true;
199 } 200 }
200 201
202 InstallWebstoreItemFunction::InstallWebstoreItemFunction() {
203 }
204
205 InstallWebstoreItemFunction::~InstallWebstoreItemFunction() {
206 }
207
208 bool InstallWebstoreItemFunction::RunImpl() {
209 if (args_->GetSize() < 1)
210 return false;
211
212 if (!args_->GetString(0, &webstore_item_id_) || webstore_item_id_.empty())
213 return false;
214
215 extensions::WebstoreStandaloneInstaller::Callback callback =
216 base::Bind(&InstallWebstoreItemFunction::OnInstallComplete, this);
217
218 scoped_refptr<FileManagerInstaller> installer(
219 new FileManagerInstaller(
220 GetAssociatedWebContents(), // web_contents(),
221 webstore_item_id_,
222 profile(),
223 callback));
224 // installer will be AddRef()'d in BeginInstall().
225 installer->BeginInstall();
226 return true;
227 }
228
229 void InstallWebstoreItemFunction::OnInstallComplete(bool success,
230 const std::string& error) {
231 if (success) {
232 drive::util::Log(logging::LOG_INFO,
233 "App install succeeded. (item id: %s)",
234 webstore_item_id_.c_str());
235 } else {
236 drive::util::Log(logging::LOG_ERROR,
237 "App install failed. (item id: %s, reason: %s)",
238 webstore_item_id_.c_str(),
239 error.c_str());
240 error_ = error;
241 }
242
243 SendResponse(success);
244 }
245
201 } // namespace file_manager 246 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698