Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webstore_private/webstore_private_api.h" | 5 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" |
| 6 | 6 |
| 7 #include "apps/app_launcher.h" | 7 #include "apps/app_launcher.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
| 41 #include "extensions/common/error_utils.h" | 41 #include "extensions/common/error_utils.h" |
| 42 #include "grit/chromium_strings.h" | 42 #include "grit/chromium_strings.h" |
| 43 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
| 44 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
| 45 | 45 |
| 46 using content::GpuDataManager; | 46 using content::GpuDataManager; |
| 47 | 47 |
| 48 namespace extensions { | 48 namespace extensions { |
| 49 | 49 |
| 50 namespace BeginInstallWithManifest3 = | |
| 51 api::webstore_private::BeginInstallWithManifest3; | |
| 52 namespace CompleteInstall = api::webstore_private::CompleteInstall; | |
| 53 namespace GetBrowserLogin = api::webstore_private::GetBrowserLogin; | |
| 54 namespace GetIsLauncherEnabled = api::webstore_private::GetIsLauncherEnabled; | |
| 55 namespace GetStoreLogin = api::webstore_private::GetStoreLogin; | |
| 56 namespace GetWebGLStatus = api::webstore_private::GetWebGLStatus; | |
| 57 namespace InstallBundle = api::webstore_private::InstallBundle; | |
| 58 namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode; | |
| 59 namespace SetStoreLogin = api::webstore_private::SetStoreLogin; | |
| 60 | |
| 50 namespace { | 61 namespace { |
| 51 | 62 |
| 52 // Holds the Approvals between the time we prompt and start the installs. | 63 // Holds the Approvals between the time we prompt and start the installs. |
| 53 class PendingApprovals { | 64 class PendingApprovals { |
| 54 public: | 65 public: |
| 55 PendingApprovals(); | 66 PendingApprovals(); |
| 56 ~PendingApprovals(); | 67 ~PendingApprovals(); |
| 57 | 68 |
| 58 void PushApproval(scoped_ptr<WebstoreInstaller::Approval> approval); | 69 void PushApproval(scoped_ptr<WebstoreInstaller::Approval> approval); |
| 59 scoped_ptr<WebstoreInstaller::Approval> PopApproval( | 70 scoped_ptr<WebstoreInstaller::Approval> PopApproval( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 return (installs_.begin() + i); | 146 return (installs_.begin() + i); |
| 136 } | 147 } |
| 137 return installs_.end(); | 148 return installs_.end(); |
| 138 } | 149 } |
| 139 | 150 |
| 140 static base::LazyInstance<PendingApprovals> g_pending_approvals = | 151 static base::LazyInstance<PendingApprovals> g_pending_approvals = |
| 141 LAZY_INSTANCE_INITIALIZER; | 152 LAZY_INSTANCE_INITIALIZER; |
| 142 static base::LazyInstance<PendingInstalls> g_pending_installs = | 153 static base::LazyInstance<PendingInstalls> g_pending_installs = |
| 143 LAZY_INSTANCE_INITIALIZER; | 154 LAZY_INSTANCE_INITIALIZER; |
| 144 | 155 |
| 145 const char kAppInstallBubbleKey[] = "appInstallBubble"; | |
| 146 const char kEnableLauncherKey[] = "enableLauncher"; | |
| 147 const char kIconDataKey[] = "iconData"; | |
| 148 const char kIconUrlKey[] = "iconUrl"; | |
| 149 const char kIdKey[] = "id"; | |
| 150 const char kLocalizedNameKey[] = "localizedName"; | |
| 151 const char kLoginKey[] = "login"; | |
| 152 const char kManifestKey[] = "manifest"; | |
| 153 | |
| 154 // A preference set by the web store to indicate login information for | 156 // A preference set by the web store to indicate login information for |
| 155 // purchased apps. | 157 // purchased apps. |
| 156 const char kWebstoreLogin[] = "extensions.webstore_login"; | 158 const char kWebstoreLogin[] = "extensions.webstore_login"; |
| 157 const char kAlreadyInstalledError[] = "This item is already installed"; | 159 const char kAlreadyInstalledError[] = "This item is already installed"; |
| 158 const char kCannotSpecifyIconDataAndUrlError[] = | 160 const char kCannotSpecifyIconDataAndUrlError[] = |
| 159 "You cannot specify both icon data and an icon url"; | 161 "You cannot specify both icon data and an icon url"; |
| 160 const char kInvalidIconUrlError[] = "Invalid icon url"; | 162 const char kInvalidIconUrlError[] = "Invalid icon url"; |
| 161 const char kInvalidIdError[] = "Invalid id"; | 163 const char kInvalidIdError[] = "Invalid id"; |
| 162 const char kInvalidManifestError[] = "Invalid manifest"; | 164 const char kInvalidManifestError[] = "Invalid manifest"; |
| 163 const char kNoPreviousBeginInstallWithManifestError[] = | 165 const char kNoPreviousBeginInstallWithManifestError[] = |
| 164 "* does not match a previous call to beginInstallWithManifest3"; | 166 "* does not match a previous call to beginInstallWithManifest3"; |
| 165 const char kUserCancelledError[] = "User cancelled install"; | 167 const char kUserCancelledError[] = "User cancelled install"; |
| 166 | 168 |
| 167 // Helper to create a dictionary with login properties set from the appropriate | |
| 168 // values in the passed-in |profile|. | |
| 169 base::DictionaryValue* CreateLoginResult(Profile* profile) { | |
| 170 base::DictionaryValue* dictionary = new base::DictionaryValue(); | |
| 171 std::string username = profile->GetPrefs()->GetString( | |
| 172 prefs::kGoogleServicesUsername); | |
| 173 dictionary->SetString(kLoginKey, username); | |
| 174 return dictionary; | |
| 175 } | |
| 176 | |
| 177 WebstoreInstaller::Delegate* test_webstore_installer_delegate = NULL; | 169 WebstoreInstaller::Delegate* test_webstore_installer_delegate = NULL; |
| 178 | 170 |
| 179 // We allow the web store to set a string containing login information when a | 171 // We allow the web store to set a string containing login information when a |
| 180 // purchase is made, so that when a user logs into sync with a different | 172 // purchase is made, so that when a user logs into sync with a different |
| 181 // account we can recognize the situation. The Get function returns the login if | 173 // account we can recognize the situation. The Get function returns the login if |
| 182 // there was previously stored data, or an empty string otherwise. The Set will | 174 // there was previously stored data, or an empty string otherwise. The Set will |
| 183 // overwrite any previous login. | 175 // overwrite any previous login. |
| 184 std::string GetWebstoreLogin(Profile* profile) { | 176 std::string GetWebstoreLogin(Profile* profile) { |
| 185 if (profile->GetPrefs()->HasPrefPath(kWebstoreLogin)) | 177 if (profile->GetPrefs()->HasPrefPath(kWebstoreLogin)) |
| 186 return profile->GetPrefs()->GetString(kWebstoreLogin); | 178 return profile->GetPrefs()->GetString(kWebstoreLogin); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 203 scoped_ptr<WebstoreInstaller::Approval> | 195 scoped_ptr<WebstoreInstaller::Approval> |
| 204 WebstorePrivateApi::PopApprovalForTesting( | 196 WebstorePrivateApi::PopApprovalForTesting( |
| 205 Profile* profile, const std::string& extension_id) { | 197 Profile* profile, const std::string& extension_id) { |
| 206 return g_pending_approvals.Get().PopApproval(profile, extension_id); | 198 return g_pending_approvals.Get().PopApproval(profile, extension_id); |
| 207 } | 199 } |
| 208 | 200 |
| 209 WebstorePrivateInstallBundleFunction::WebstorePrivateInstallBundleFunction() {} | 201 WebstorePrivateInstallBundleFunction::WebstorePrivateInstallBundleFunction() {} |
| 210 WebstorePrivateInstallBundleFunction::~WebstorePrivateInstallBundleFunction() {} | 202 WebstorePrivateInstallBundleFunction::~WebstorePrivateInstallBundleFunction() {} |
| 211 | 203 |
| 212 bool WebstorePrivateInstallBundleFunction::RunImpl() { | 204 bool WebstorePrivateInstallBundleFunction::RunImpl() { |
| 213 base::ListValue* extensions = NULL; | 205 scoped_ptr<InstallBundle::Params> params( |
| 214 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &extensions)); | 206 InstallBundle::Params::Create(*args_)); |
| 207 EXTENSION_FUNCTION_VALIDATE(params.get()); | |
|
not at google - send to devlin
2013/08/12 20:48:38
VALIDATE(params) is enough
pals
2013/08/14 09:12:31
Done.
| |
| 215 | 208 |
| 216 BundleInstaller::ItemList items; | 209 BundleInstaller::ItemList items; |
| 217 if (!ReadBundleInfo(extensions, &items)) | 210 if (!ReadBundleInfo(params.get(), &items)) |
| 218 return false; | 211 return false; |
| 219 | 212 |
| 220 bundle_ = new BundleInstaller(GetCurrentBrowser(), items); | 213 bundle_ = new BundleInstaller(GetCurrentBrowser(), items); |
| 221 | 214 |
| 222 AddRef(); // Balanced in OnBundleInstallCompleted / OnBundleInstallCanceled. | 215 AddRef(); // Balanced in OnBundleInstallCompleted / OnBundleInstallCanceled. |
| 223 | 216 |
| 224 bundle_->PromptForApproval(this); | 217 bundle_->PromptForApproval(this); |
| 225 return true; | 218 return true; |
| 226 } | 219 } |
| 227 | 220 |
| 228 bool WebstorePrivateInstallBundleFunction:: | 221 bool WebstorePrivateInstallBundleFunction:: |
| 229 ReadBundleInfo(base::ListValue* extensions, | 222 ReadBundleInfo(InstallBundle::Params* params, |
|
not at google - send to devlin
2013/08/12 20:48:38
make this a const ref?
pals
2013/08/14 09:12:31
Done.
| |
| 230 BundleInstaller::ItemList* items) { | 223 BundleInstaller::ItemList* items) { |
| 231 for (size_t i = 0; i < extensions->GetSize(); ++i) { | 224 for (size_t i = 0; i < params->details.size(); ++i) { |
| 232 base::DictionaryValue* details = NULL; | |
| 233 EXTENSION_FUNCTION_VALIDATE(extensions->GetDictionary(i, &details)); | |
| 234 | |
| 235 BundleInstaller::Item item; | 225 BundleInstaller::Item item; |
| 236 EXTENSION_FUNCTION_VALIDATE(details->GetString( | 226 item.id = params->details[i]->id; |
| 237 kIdKey, &item.id)); | 227 item.manifest = params->details[i]->manifest; |
| 238 EXTENSION_FUNCTION_VALIDATE(details->GetString( | 228 item.localized_name = params->details[i]->localized_name; |
| 239 kManifestKey, &item.manifest)); | |
| 240 EXTENSION_FUNCTION_VALIDATE(details->GetString( | |
| 241 kLocalizedNameKey, &item.localized_name)); | |
| 242 | |
| 243 items->push_back(item); | 229 items->push_back(item); |
| 244 } | 230 } |
| 245 | 231 |
| 246 return true; | 232 return true; |
| 247 } | 233 } |
| 248 | 234 |
| 249 void WebstorePrivateInstallBundleFunction::OnBundleInstallApproved() { | 235 void WebstorePrivateInstallBundleFunction::OnBundleInstallApproved() { |
| 250 bundle_->CompleteInstall( | 236 bundle_->CompleteInstall( |
| 251 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), | 237 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), |
| 252 this); | 238 this); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 271 } | 257 } |
| 272 | 258 |
| 273 WebstorePrivateBeginInstallWithManifest3Function:: | 259 WebstorePrivateBeginInstallWithManifest3Function:: |
| 274 WebstorePrivateBeginInstallWithManifest3Function() | 260 WebstorePrivateBeginInstallWithManifest3Function() |
| 275 : use_app_installed_bubble_(false), enable_launcher_(false) {} | 261 : use_app_installed_bubble_(false), enable_launcher_(false) {} |
| 276 | 262 |
| 277 WebstorePrivateBeginInstallWithManifest3Function:: | 263 WebstorePrivateBeginInstallWithManifest3Function:: |
| 278 ~WebstorePrivateBeginInstallWithManifest3Function() {} | 264 ~WebstorePrivateBeginInstallWithManifest3Function() {} |
| 279 | 265 |
| 280 bool WebstorePrivateBeginInstallWithManifest3Function::RunImpl() { | 266 bool WebstorePrivateBeginInstallWithManifest3Function::RunImpl() { |
| 281 base::DictionaryValue* details = NULL; | 267 scoped_ptr<BeginInstallWithManifest3::Params> params( |
| 282 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); | 268 BeginInstallWithManifest3::Params::Create(*args_)); |
| 283 CHECK(details); | 269 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 270 CHECK(params.get()); | |
|
not at google - send to devlin
2013/08/12 20:48:38
270 is redundant, EFV(params) will return if it fa
pals
2013/08/14 09:12:31
Done.
| |
| 284 | 271 |
| 285 EXTENSION_FUNCTION_VALIDATE(details->GetString(kIdKey, &id_)); | 272 id_ = params->details.id; |
| 286 if (!extensions::Extension::IdIsValid(id_)) { | 273 if (!extensions::Extension::IdIsValid(id_)) { |
| 287 SetResultCode(INVALID_ID); | 274 SetResultCode(INVALID_ID); |
| 288 error_ = kInvalidIdError; | 275 error_ = kInvalidIdError; |
| 289 return false; | 276 return false; |
| 290 } | 277 } |
| 291 | 278 |
| 292 EXTENSION_FUNCTION_VALIDATE(details->GetString(kManifestKey, &manifest_)); | 279 manifest_ = params->details.manifest; |
| 293 | 280 |
| 294 if (details->HasKey(kIconDataKey) && details->HasKey(kIconUrlKey)) { | 281 if (params->details.icon_data.get() && params->details.icon_url.get()) { |
|
not at google - send to devlin
2013/08/12 20:48:38
I won't make this comment on every instance of thi
pals
2013/08/14 09:12:31
Done.
| |
| 295 SetResultCode(ICON_ERROR); | 282 SetResultCode(ICON_ERROR); |
| 296 error_ = kCannotSpecifyIconDataAndUrlError; | 283 error_ = kCannotSpecifyIconDataAndUrlError; |
| 297 return false; | 284 return false; |
| 298 } | 285 } |
| 299 | 286 |
| 300 if (details->HasKey(kIconDataKey)) | 287 if(params->details.icon_data.get()) |
|
not at google - send to devlin
2013/08/12 20:48:38
space between if and (, ditto elsewhere.
pals
2013/08/14 09:12:31
Done.
| |
| 301 EXTENSION_FUNCTION_VALIDATE(details->GetString(kIconDataKey, &icon_data_)); | 288 icon_data_ = *params->details.icon_data; |
| 302 | 289 |
| 303 GURL icon_url; | 290 GURL icon_url; |
| 304 if (details->HasKey(kIconUrlKey)) { | 291 if(params->details.icon_url.get()) { |
| 305 std::string tmp_url; | 292 std::string tmp_url; |
| 306 EXTENSION_FUNCTION_VALIDATE(details->GetString(kIconUrlKey, &tmp_url)); | 293 icon_url = source_url().Resolve(*params->details.icon_url); |
| 307 icon_url = source_url().Resolve(tmp_url); | |
| 308 if (!icon_url.is_valid()) { | 294 if (!icon_url.is_valid()) { |
| 309 SetResultCode(INVALID_ICON_URL); | 295 SetResultCode(INVALID_ICON_URL); |
| 310 error_ = kInvalidIconUrlError; | 296 error_ = kInvalidIconUrlError; |
| 311 return false; | 297 return false; |
| 312 } | 298 } |
| 313 } | 299 } |
| 314 | 300 |
| 315 if (details->HasKey(kLocalizedNameKey)) | 301 if(params->details.localized_name.get()) |
| 316 EXTENSION_FUNCTION_VALIDATE(details->GetString(kLocalizedNameKey, | 302 localized_name_ = *params->details.localized_name; |
| 317 &localized_name_)); | |
| 318 | 303 |
| 319 if (details->HasKey(kAppInstallBubbleKey)) | 304 if(params->details.app_install_bubble.get()) |
| 320 EXTENSION_FUNCTION_VALIDATE(details->GetBoolean( | 305 use_app_installed_bubble_ = *params->details.app_install_bubble; |
| 321 kAppInstallBubbleKey, &use_app_installed_bubble_)); | |
| 322 | 306 |
| 323 if (details->HasKey(kEnableLauncherKey)) | 307 if(params->details.enable_launcher.get()) |
| 324 EXTENSION_FUNCTION_VALIDATE(details->GetBoolean( | 308 enable_launcher_ = *params->details.enable_launcher; |
|
not at google - send to devlin
2013/08/12 20:48:38
all of this assigning into variables makes me thin
pals
2013/08/14 09:12:31
Done.
| |
| 325 kEnableLauncherKey, &enable_launcher_)); | |
| 326 | 309 |
| 327 ExtensionService* service = | 310 ExtensionService* service = |
| 328 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 311 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 329 if (service->GetInstalledExtension(id_) || | 312 if (service->GetInstalledExtension(id_) || |
| 330 !g_pending_installs.Get().InsertInstall(profile_, id_)) { | 313 !g_pending_installs.Get().InsertInstall(profile_, id_)) { |
| 331 SetResultCode(ALREADY_INSTALLED); | 314 SetResultCode(ALREADY_INSTALLED); |
| 332 error_ = kAlreadyInstalledError; | 315 error_ = kAlreadyInstalledError; |
| 333 return false; | 316 return false; |
| 334 } | 317 } |
| 335 | 318 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 350 // The response is sent asynchronously in OnWebstoreParseSuccess/ | 333 // The response is sent asynchronously in OnWebstoreParseSuccess/ |
| 351 // OnWebstoreParseFailure. | 334 // OnWebstoreParseFailure. |
| 352 return true; | 335 return true; |
| 353 } | 336 } |
| 354 | 337 |
| 355 | 338 |
| 356 void WebstorePrivateBeginInstallWithManifest3Function::SetResultCode( | 339 void WebstorePrivateBeginInstallWithManifest3Function::SetResultCode( |
| 357 ResultCode code) { | 340 ResultCode code) { |
| 358 switch (code) { | 341 switch (code) { |
| 359 case ERROR_NONE: | 342 case ERROR_NONE: |
| 360 SetResult(Value::CreateStringValue(std::string())); | 343 results_ = BeginInstallWithManifest3::Results::Create(std::string()); |
| 361 break; | 344 break; |
| 362 case UNKNOWN_ERROR: | 345 case UNKNOWN_ERROR: |
| 363 SetResult(Value::CreateStringValue("unknown_error")); | 346 results_ = BeginInstallWithManifest3::Results::Create("unknown_error"); |
| 364 break; | 347 break; |
| 365 case USER_CANCELLED: | 348 case USER_CANCELLED: |
| 366 SetResult(Value::CreateStringValue("user_cancelled")); | 349 results_ = BeginInstallWithManifest3::Results::Create("user_cancelled"); |
| 367 break; | 350 break; |
| 368 case MANIFEST_ERROR: | 351 case MANIFEST_ERROR: |
| 369 SetResult(Value::CreateStringValue("manifest_error")); | 352 results_ = BeginInstallWithManifest3::Results::Create("manifest_error"); |
| 370 break; | 353 break; |
| 371 case ICON_ERROR: | 354 case ICON_ERROR: |
| 372 SetResult(Value::CreateStringValue("icon_error")); | 355 results_ = BeginInstallWithManifest3::Results::Create("icon_error"); |
| 373 break; | 356 break; |
| 374 case INVALID_ID: | 357 case INVALID_ID: |
| 375 SetResult(Value::CreateStringValue("invalid_id")); | 358 results_ = BeginInstallWithManifest3::Results::Create("invalid_id"); |
| 376 break; | 359 break; |
| 377 case PERMISSION_DENIED: | 360 case PERMISSION_DENIED: |
| 378 SetResult(Value::CreateStringValue("permission_denied")); | 361 results_ = BeginInstallWithManifest3::Results::Create( |
| 362 "permission_denied"); | |
| 379 break; | 363 break; |
| 380 case INVALID_ICON_URL: | 364 case INVALID_ICON_URL: |
| 381 SetResult(Value::CreateStringValue("invalid_icon_url")); | 365 results_ = BeginInstallWithManifest3::Results::Create("invalid_icon_url"); |
| 382 break; | 366 break; |
| 383 case SIGNIN_FAILED: | 367 case SIGNIN_FAILED: |
| 384 SetResult(Value::CreateStringValue("signin_failed")); | 368 results_ = BeginInstallWithManifest3::Results::Create("signin_failed"); |
| 385 break; | 369 break; |
| 386 case ALREADY_INSTALLED: | 370 case ALREADY_INSTALLED: |
| 387 SetResult(Value::CreateStringValue("already_installed")); | 371 results_ = BeginInstallWithManifest3::Results::Create( |
| 372 "already_installed"); | |
| 388 break; | 373 break; |
| 389 default: | 374 default: |
| 390 CHECK(false); | 375 CHECK(false); |
|
not at google - send to devlin
2013/08/12 20:48:38
pull this switch into a separate function which re
pals
2013/08/14 09:12:31
Done.
| |
| 391 } | 376 } |
| 392 } | 377 } |
| 393 | 378 |
| 394 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess( | 379 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess( |
| 395 const std::string& id, | 380 const std::string& id, |
| 396 const SkBitmap& icon, | 381 const SkBitmap& icon, |
| 397 base::DictionaryValue* parsed_manifest) { | 382 base::DictionaryValue* parsed_manifest) { |
| 398 CHECK_EQ(id_, id); | 383 CHECK_EQ(id_, id); |
| 399 CHECK(parsed_manifest); | 384 CHECK(parsed_manifest); |
| 400 icon_ = icon; | 385 icon_ = icon; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 Release(); | 529 Release(); |
| 545 } | 530 } |
| 546 | 531 |
| 547 WebstorePrivateCompleteInstallFunction:: | 532 WebstorePrivateCompleteInstallFunction:: |
| 548 WebstorePrivateCompleteInstallFunction() {} | 533 WebstorePrivateCompleteInstallFunction() {} |
| 549 | 534 |
| 550 WebstorePrivateCompleteInstallFunction:: | 535 WebstorePrivateCompleteInstallFunction:: |
| 551 ~WebstorePrivateCompleteInstallFunction() {} | 536 ~WebstorePrivateCompleteInstallFunction() {} |
| 552 | 537 |
| 553 bool WebstorePrivateCompleteInstallFunction::RunImpl() { | 538 bool WebstorePrivateCompleteInstallFunction::RunImpl() { |
| 554 std::string id; | 539 scoped_ptr<CompleteInstall::Params> params( |
| 555 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &id)); | 540 CompleteInstall::Params::Create(*args_)); |
| 556 if (!extensions::Extension::IdIsValid(id)) { | 541 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 542 if (!extensions::Extension::IdIsValid(params->expected_id)) { | |
| 557 error_ = kInvalidIdError; | 543 error_ = kInvalidIdError; |
| 558 return false; | 544 return false; |
| 559 } | 545 } |
| 560 | 546 |
| 561 approval_ = g_pending_approvals.Get().PopApproval(profile(), id).Pass(); | 547 approval_ = g_pending_approvals.Get().PopApproval(profile(), |
| 548 params->expected_id).Pass(); | |
| 562 if (!approval_) { | 549 if (!approval_) { |
| 563 error_ = ErrorUtils::FormatErrorMessage( | 550 error_ = ErrorUtils::FormatErrorMessage( |
| 564 kNoPreviousBeginInstallWithManifestError, id); | 551 kNoPreviousBeginInstallWithManifestError, params->expected_id); |
| 565 return false; | 552 return false; |
| 566 } | 553 } |
| 567 | 554 |
| 568 // Balanced in OnExtensionInstallSuccess() or OnExtensionInstallFailure(). | 555 // Balanced in OnExtensionInstallSuccess() or OnExtensionInstallFailure(). |
| 569 AddRef(); | 556 AddRef(); |
| 570 | 557 |
| 571 if (approval_->enable_launcher) | 558 if (approval_->enable_launcher) |
| 572 AppListService::Get()->EnableAppList(profile()); | 559 AppListService::Get()->EnableAppList(profile()); |
| 573 | 560 |
| 574 if (apps::IsAppLauncherEnabled()) { | 561 if (apps::IsAppLauncherEnabled()) { |
| 575 // Show the app list to show download is progressing. Don't show the app | 562 // Show the app list to show download is progressing. Don't show the app |
| 576 // list on first app install so users can be trained to open it themselves. | 563 // list on first app install so users can be trained to open it themselves. |
| 577 if (approval_->manifest->is_app() && !approval_->enable_launcher) | 564 if (approval_->manifest->is_app() && !approval_->enable_launcher) |
| 578 AppListService::Get()->ShowForProfile(profile()); | 565 AppListService::Get()->ShowForProfile(profile()); |
| 579 } | 566 } |
| 580 | 567 |
| 581 // The extension will install through the normal extension install flow, but | 568 // The extension will install through the normal extension install flow, but |
| 582 // the whitelist entry will bypass the normal permissions install dialog. | 569 // the whitelist entry will bypass the normal permissions install dialog. |
| 583 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( | 570 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( |
| 584 profile(), this, | 571 profile(), this, |
| 585 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), | 572 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), |
| 586 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); | 573 params->expected_id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); |
| 587 installer->Start(); | 574 installer->Start(); |
| 588 | 575 |
| 589 return true; | 576 return true; |
| 590 } | 577 } |
| 591 | 578 |
| 592 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallSuccess( | 579 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallSuccess( |
| 593 const std::string& id) { | 580 const std::string& id) { |
| 594 if (test_webstore_installer_delegate) | 581 if (test_webstore_installer_delegate) |
| 595 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); | 582 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); |
| 596 | 583 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 626 WebstorePrivateEnableAppLauncherFunction:: | 613 WebstorePrivateEnableAppLauncherFunction:: |
| 627 ~WebstorePrivateEnableAppLauncherFunction() {} | 614 ~WebstorePrivateEnableAppLauncherFunction() {} |
| 628 | 615 |
| 629 bool WebstorePrivateEnableAppLauncherFunction::RunImpl() { | 616 bool WebstorePrivateEnableAppLauncherFunction::RunImpl() { |
| 630 AppListService::Get()->EnableAppList(profile()); | 617 AppListService::Get()->EnableAppList(profile()); |
| 631 SendResponse(true); | 618 SendResponse(true); |
| 632 return true; | 619 return true; |
| 633 } | 620 } |
| 634 | 621 |
| 635 bool WebstorePrivateGetBrowserLoginFunction::RunImpl() { | 622 bool WebstorePrivateGetBrowserLoginFunction::RunImpl() { |
| 636 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); | 623 GetBrowserLogin::Results::Info info; |
| 624 info.login = profile_->GetOriginalProfile()->GetPrefs()->GetString( | |
| 625 prefs::kGoogleServicesUsername); | |
| 626 results_ = GetBrowserLogin::Results::Create(info); | |
| 637 return true; | 627 return true; |
| 638 } | 628 } |
| 639 | 629 |
| 640 bool WebstorePrivateGetStoreLoginFunction::RunImpl() { | 630 bool WebstorePrivateGetStoreLoginFunction::RunImpl() { |
| 641 SetResult(Value::CreateStringValue(GetWebstoreLogin(profile_))); | 631 results_ = GetStoreLogin::Results::Create(GetWebstoreLogin(profile_)); |
| 642 return true; | 632 return true; |
| 643 } | 633 } |
| 644 | 634 |
| 645 bool WebstorePrivateSetStoreLoginFunction::RunImpl() { | 635 bool WebstorePrivateSetStoreLoginFunction::RunImpl() { |
| 646 std::string login; | 636 scoped_ptr<SetStoreLogin::Params> params( |
| 647 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &login)); | 637 SetStoreLogin::Params::Create(*args_)); |
| 648 SetWebstoreLogin(profile_, login); | 638 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 639 SetWebstoreLogin(profile_, params->login); | |
| 649 return true; | 640 return true; |
| 650 } | 641 } |
| 651 | 642 |
| 652 WebstorePrivateGetWebGLStatusFunction::WebstorePrivateGetWebGLStatusFunction() { | 643 WebstorePrivateGetWebGLStatusFunction::WebstorePrivateGetWebGLStatusFunction() { |
| 653 feature_checker_ = new GPUFeatureChecker( | 644 feature_checker_ = new GPUFeatureChecker( |
| 654 gpu::GPU_FEATURE_TYPE_WEBGL, | 645 gpu::GPU_FEATURE_TYPE_WEBGL, |
| 655 base::Bind(&WebstorePrivateGetWebGLStatusFunction::OnFeatureCheck, | 646 base::Bind(&WebstorePrivateGetWebGLStatusFunction::OnFeatureCheck, |
| 656 base::Unretained(this))); | 647 base::Unretained(this))); |
| 657 } | 648 } |
| 658 | 649 |
| 659 WebstorePrivateGetWebGLStatusFunction:: | 650 WebstorePrivateGetWebGLStatusFunction:: |
| 660 ~WebstorePrivateGetWebGLStatusFunction() {} | 651 ~WebstorePrivateGetWebGLStatusFunction() {} |
| 661 | 652 |
| 662 void WebstorePrivateGetWebGLStatusFunction::CreateResult(bool webgl_allowed) { | 653 void WebstorePrivateGetWebGLStatusFunction::CreateResult(bool webgl_allowed) { |
| 663 SetResult(Value::CreateStringValue( | 654 results_ = GetWebGLStatus::Results::Create(GetWebGLStatus::Results:: |
| 664 webgl_allowed ? "webgl_allowed" : "webgl_blocked")); | 655 ParseWebgl_status(webgl_allowed ? "webgl_allowed" : "webgl_blocked")); |
| 665 } | 656 } |
| 666 | 657 |
| 667 bool WebstorePrivateGetWebGLStatusFunction::RunImpl() { | 658 bool WebstorePrivateGetWebGLStatusFunction::RunImpl() { |
| 668 feature_checker_->CheckGPUFeatureAvailability(); | 659 feature_checker_->CheckGPUFeatureAvailability(); |
| 669 return true; | 660 return true; |
| 670 } | 661 } |
| 671 | 662 |
| 672 void WebstorePrivateGetWebGLStatusFunction:: | 663 void WebstorePrivateGetWebGLStatusFunction:: |
| 673 OnFeatureCheck(bool feature_allowed) { | 664 OnFeatureCheck(bool feature_allowed) { |
| 674 CreateResult(feature_allowed); | 665 CreateResult(feature_allowed); |
| 675 SendResponse(true); | 666 SendResponse(true); |
| 676 } | 667 } |
| 677 | 668 |
| 678 bool WebstorePrivateGetIsLauncherEnabledFunction::RunImpl() { | 669 bool WebstorePrivateGetIsLauncherEnabledFunction::RunImpl() { |
| 679 SetResult(Value::CreateBooleanValue(apps::IsAppLauncherEnabled())); | 670 results_ = GetIsLauncherEnabled::Results::Create( |
| 671 apps::IsAppLauncherEnabled()); | |
| 680 SendResponse(true); | 672 SendResponse(true); |
| 681 return true; | 673 return true; |
| 682 } | 674 } |
| 683 | 675 |
| 684 bool WebstorePrivateIsInIncognitoModeFunction::RunImpl() { | 676 bool WebstorePrivateIsInIncognitoModeFunction::RunImpl() { |
| 685 SetResult( | 677 results_ = IsInIncognitoMode::Results::Create( |
| 686 Value::CreateBooleanValue(profile_ != profile_->GetOriginalProfile())); | 678 profile_ != profile_->GetOriginalProfile()); |
| 687 SendResponse(true); | 679 SendResponse(true); |
|
not at google - send to devlin
2013/08/12 20:48:38
Make these SyncExtensionFunctions then you won't n
pals
2013/08/14 09:12:31
Done.
| |
| 688 return true; | 680 return true; |
| 689 } | 681 } |
| 690 | 682 |
| 691 } // namespace extensions | 683 } // namespace extensions |
| OLD | NEW |