Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) { | |
|
hashimoto
2013/08/30 09:09:37
nit: No need to have '{'?
yoshiki
2013/08/30 09:51:46
Removed.
| |
| 210 return false; | |
| 211 } | |
| 212 | |
| 213 if (!args_->GetString(0, &webstore_item_id_) || webstore_item_id_.empty()) | |
| 214 return false; | |
| 215 | |
| 216 extensions::WebstoreStandaloneInstaller::Callback callback = | |
| 217 base::Bind(&InstallWebstoreItemFunction::OnInstallComplete, | |
| 218 base::Unretained(this)); | |
| 219 | |
| 220 scoped_refptr<FileManagerInstaller> installer( | |
| 221 new FileManagerInstaller( | |
| 222 GetAssociatedWebContents(), // web_contents(), | |
| 223 webstore_item_id_, | |
| 224 profile(), | |
| 225 callback)); | |
| 226 // installer will be AddRef()'d in BeginInstall(). | |
| 227 installer->BeginInstall(); | |
| 228 | |
| 229 AddRef(); // Balanced in Release() in OnInstallComplete. | |
|
hashimoto
2013/08/30 09:09:37
How about binding |this| to the callback without b
yoshiki
2013/08/30 09:51:46
Nice. Done.
| |
| 230 return true; | |
| 231 } | |
| 232 | |
| 233 void InstallWebstoreItemFunction::OnInstallComplete(bool success, | |
| 234 const std::string& error) { | |
|
hashimoto
2013/08/30 09:09:37
nit: indent.
yoshiki
2013/08/30 09:51:46
Done.
| |
| 235 if (success) { | |
| 236 drive::util::Log(logging::LOG_INFO, | |
| 237 "App install succeeded. (item id: %s)", | |
| 238 webstore_item_id_.c_str()); | |
| 239 } else { | |
| 240 drive::util::Log(logging::LOG_ERROR, | |
| 241 "App install failed. (item id: %s, reason: %s)", | |
| 242 webstore_item_id_.c_str(), | |
| 243 error.c_str()); | |
| 244 error_ = error; | |
| 245 } | |
| 246 | |
| 247 SendResponse(success); | |
| 248 | |
| 249 Release(); // Matches the AddRef in RunImpl. | |
| 250 } | |
| 251 | |
| 201 } // namespace file_manager | 252 } // namespace file_manager |
| OLD | NEW |