| 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/developer_private/developer_private_api.
h" | 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 *error = kCannotModifyPolicyExtensionError; | 130 *error = kCannotModifyPolicyExtensionError; |
| 131 return false; | 131 return false; |
| 132 } | 132 } |
| 133 | 133 |
| 134 return true; | 134 return true; |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Runs the install verifier for all extensions that are enabled, disabled, or | 137 // Runs the install verifier for all extensions that are enabled, disabled, or |
| 138 // terminated. | 138 // terminated. |
| 139 void PerformVerificationCheck(content::BrowserContext* context) { | 139 void PerformVerificationCheck(content::BrowserContext* context) { |
| 140 scoped_ptr<ExtensionSet> extensions = | 140 std::unique_ptr<ExtensionSet> extensions = |
| 141 ExtensionRegistry::Get(context)->GenerateInstalledExtensionsSet( | 141 ExtensionRegistry::Get(context)->GenerateInstalledExtensionsSet( |
| 142 ExtensionRegistry::ENABLED | | 142 ExtensionRegistry::ENABLED | ExtensionRegistry::DISABLED | |
| 143 ExtensionRegistry::DISABLED | | |
| 144 ExtensionRegistry::TERMINATED); | 143 ExtensionRegistry::TERMINATED); |
| 145 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); | 144 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); |
| 146 bool should_do_verification_check = false; | 145 bool should_do_verification_check = false; |
| 147 for (const scoped_refptr<const Extension>& extension : *extensions) { | 146 for (const scoped_refptr<const Extension>& extension : *extensions) { |
| 148 if (ui_util::ShouldDisplayInExtensionSettings(extension.get(), context) && | 147 if (ui_util::ShouldDisplayInExtensionSettings(extension.get(), context) && |
| 149 ((prefs->GetDisableReasons(extension->id()) & | 148 ((prefs->GetDisableReasons(extension->id()) & |
| 150 Extension::DISABLE_NOT_VERIFIED) != 0)) { | 149 Extension::DISABLE_NOT_VERIFIED) != 0)) { |
| 151 should_do_verification_check = true; | 150 should_do_verification_check = true; |
| 152 break; | 151 break; |
| 153 } | 152 } |
| 154 } | 153 } |
| 155 | 154 |
| 156 UMA_HISTOGRAM_BOOLEAN("ExtensionSettings.ShouldDoVerificationCheck", | 155 UMA_HISTOGRAM_BOOLEAN("ExtensionSettings.ShouldDoVerificationCheck", |
| 157 should_do_verification_check); | 156 should_do_verification_check); |
| 158 if (should_do_verification_check) | 157 if (should_do_verification_check) |
| 159 InstallVerifier::Get(context)->VerifyAllExtensions(); | 158 InstallVerifier::Get(context)->VerifyAllExtensions(); |
| 160 } | 159 } |
| 161 | 160 |
| 162 scoped_ptr<developer::ProfileInfo> CreateProfileInfo(Profile* profile) { | 161 std::unique_ptr<developer::ProfileInfo> CreateProfileInfo(Profile* profile) { |
| 163 scoped_ptr<developer::ProfileInfo> info(new developer::ProfileInfo()); | 162 std::unique_ptr<developer::ProfileInfo> info(new developer::ProfileInfo()); |
| 164 info->is_supervised = profile->IsSupervised(); | 163 info->is_supervised = profile->IsSupervised(); |
| 165 PrefService* prefs = profile->GetPrefs(); | 164 PrefService* prefs = profile->GetPrefs(); |
| 166 info->is_incognito_available = | 165 info->is_incognito_available = |
| 167 IncognitoModePrefs::GetAvailability(prefs) != | 166 IncognitoModePrefs::GetAvailability(prefs) != |
| 168 IncognitoModePrefs::DISABLED; | 167 IncognitoModePrefs::DISABLED; |
| 169 info->in_developer_mode = | 168 info->in_developer_mode = |
| 170 !info->is_supervised && | 169 !info->is_supervised && |
| 171 prefs->GetBoolean(prefs::kExtensionsUIDeveloperMode); | 170 prefs->GetBoolean(prefs::kExtensionsUIDeveloperMode); |
| 172 info->app_info_dialog_enabled = CanShowAppInfoDialog(); | 171 info->app_info_dialog_enabled = CanShowAppInfoDialog(); |
| 173 info->can_load_unpacked = | 172 info->can_load_unpacked = |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 bool is_now_visible) { | 340 bool is_now_visible) { |
| 342 BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, extension_id); | 341 BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, extension_id); |
| 343 } | 342 } |
| 344 | 343 |
| 345 void DeveloperPrivateEventRouter::OnExtensionDisableReasonsChanged( | 344 void DeveloperPrivateEventRouter::OnExtensionDisableReasonsChanged( |
| 346 const std::string& extension_id, int disable_reasons) { | 345 const std::string& extension_id, int disable_reasons) { |
| 347 BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, extension_id); | 346 BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, extension_id); |
| 348 } | 347 } |
| 349 | 348 |
| 350 void DeveloperPrivateEventRouter::OnExtensionManagementSettingsChanged() { | 349 void DeveloperPrivateEventRouter::OnExtensionManagementSettingsChanged() { |
| 351 scoped_ptr<base::ListValue> args(new base::ListValue()); | 350 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
| 352 args->Append(CreateProfileInfo(profile_)->ToValue()); | 351 args->Append(CreateProfileInfo(profile_)->ToValue()); |
| 353 scoped_ptr<Event> event( | 352 std::unique_ptr<Event> event( |
| 354 new Event(events::DEVELOPER_PRIVATE_ON_PROFILE_STATE_CHANGED, | 353 new Event(events::DEVELOPER_PRIVATE_ON_PROFILE_STATE_CHANGED, |
| 355 developer::OnProfileStateChanged::kEventName, std::move(args))); | 354 developer::OnProfileStateChanged::kEventName, std::move(args))); |
| 356 event_router_->BroadcastEvent(std::move(event)); | 355 event_router_->BroadcastEvent(std::move(event)); |
| 357 } | 356 } |
| 358 | 357 |
| 359 void DeveloperPrivateEventRouter::ExtensionWarningsChanged( | 358 void DeveloperPrivateEventRouter::ExtensionWarningsChanged( |
| 360 const ExtensionIdSet& affected_extensions) { | 359 const ExtensionIdSet& affected_extensions) { |
| 361 for (const ExtensionId& id : affected_extensions) | 360 for (const ExtensionId& id : affected_extensions) |
| 362 BroadcastItemStateChanged(developer::EVENT_TYPE_WARNINGS_CHANGED, id); | 361 BroadcastItemStateChanged(developer::EVENT_TYPE_WARNINGS_CHANGED, id); |
| 363 } | 362 } |
| 364 | 363 |
| 365 void DeveloperPrivateEventRouter::OnProfilePrefChanged() { | 364 void DeveloperPrivateEventRouter::OnProfilePrefChanged() { |
| 366 scoped_ptr<base::ListValue> args(new base::ListValue()); | 365 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
| 367 args->Append(CreateProfileInfo(profile_)->ToValue()); | 366 args->Append(CreateProfileInfo(profile_)->ToValue()); |
| 368 scoped_ptr<Event> event( | 367 std::unique_ptr<Event> event( |
| 369 new Event(events::DEVELOPER_PRIVATE_ON_PROFILE_STATE_CHANGED, | 368 new Event(events::DEVELOPER_PRIVATE_ON_PROFILE_STATE_CHANGED, |
| 370 developer::OnProfileStateChanged::kEventName, std::move(args))); | 369 developer::OnProfileStateChanged::kEventName, std::move(args))); |
| 371 event_router_->BroadcastEvent(std::move(event)); | 370 event_router_->BroadcastEvent(std::move(event)); |
| 372 } | 371 } |
| 373 | 372 |
| 374 void DeveloperPrivateEventRouter::BroadcastItemStateChanged( | 373 void DeveloperPrivateEventRouter::BroadcastItemStateChanged( |
| 375 developer::EventType event_type, | 374 developer::EventType event_type, |
| 376 const std::string& extension_id) { | 375 const std::string& extension_id) { |
| 377 scoped_ptr<ExtensionInfoGenerator> info_generator( | 376 std::unique_ptr<ExtensionInfoGenerator> info_generator( |
| 378 new ExtensionInfoGenerator(profile_)); | 377 new ExtensionInfoGenerator(profile_)); |
| 379 ExtensionInfoGenerator* info_generator_weak = info_generator.get(); | 378 ExtensionInfoGenerator* info_generator_weak = info_generator.get(); |
| 380 info_generator_weak->CreateExtensionInfo( | 379 info_generator_weak->CreateExtensionInfo( |
| 381 extension_id, | 380 extension_id, |
| 382 base::Bind(&DeveloperPrivateEventRouter::BroadcastItemStateChangedHelper, | 381 base::Bind(&DeveloperPrivateEventRouter::BroadcastItemStateChangedHelper, |
| 383 weak_factory_.GetWeakPtr(), event_type, extension_id, | 382 weak_factory_.GetWeakPtr(), event_type, extension_id, |
| 384 base::Passed(std::move(info_generator)))); | 383 base::Passed(std::move(info_generator)))); |
| 385 } | 384 } |
| 386 | 385 |
| 387 void DeveloperPrivateEventRouter::BroadcastItemStateChangedHelper( | 386 void DeveloperPrivateEventRouter::BroadcastItemStateChangedHelper( |
| 388 developer::EventType event_type, | 387 developer::EventType event_type, |
| 389 const std::string& extension_id, | 388 const std::string& extension_id, |
| 390 scoped_ptr<ExtensionInfoGenerator> info_generator, | 389 std::unique_ptr<ExtensionInfoGenerator> info_generator, |
| 391 ExtensionInfoGenerator::ExtensionInfoList infos) { | 390 ExtensionInfoGenerator::ExtensionInfoList infos) { |
| 392 DCHECK_LE(infos.size(), 1u); | 391 DCHECK_LE(infos.size(), 1u); |
| 393 | 392 |
| 394 developer::EventData event_data; | 393 developer::EventData event_data; |
| 395 event_data.event_type = event_type; | 394 event_data.event_type = event_type; |
| 396 event_data.item_id = extension_id; | 395 event_data.item_id = extension_id; |
| 397 if (!infos.empty()) { | 396 if (!infos.empty()) { |
| 398 event_data.extension_info.reset( | 397 event_data.extension_info.reset( |
| 399 new developer::ExtensionInfo(std::move(infos[0]))); | 398 new developer::ExtensionInfo(std::move(infos[0]))); |
| 400 } | 399 } |
| 401 | 400 |
| 402 scoped_ptr<base::ListValue> args(new base::ListValue()); | 401 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
| 403 args->Append(event_data.ToValue()); | 402 args->Append(event_data.ToValue()); |
| 404 scoped_ptr<Event> event( | 403 std::unique_ptr<Event> event( |
| 405 new Event(events::DEVELOPER_PRIVATE_ON_ITEM_STATE_CHANGED, | 404 new Event(events::DEVELOPER_PRIVATE_ON_ITEM_STATE_CHANGED, |
| 406 developer::OnItemStateChanged::kEventName, std::move(args))); | 405 developer::OnItemStateChanged::kEventName, std::move(args))); |
| 407 event_router_->BroadcastEvent(std::move(event)); | 406 event_router_->BroadcastEvent(std::move(event)); |
| 408 } | 407 } |
| 409 | 408 |
| 410 void DeveloperPrivateAPI::SetLastUnpackedDirectory(const base::FilePath& path) { | 409 void DeveloperPrivateAPI::SetLastUnpackedDirectory(const base::FilePath& path) { |
| 411 last_unpacked_directory_ = path; | 410 last_unpacked_directory_ = path; |
| 412 } | 411 } |
| 413 | 412 |
| 414 void DeveloperPrivateAPI::RegisterNotifications() { | 413 void DeveloperPrivateAPI::RegisterNotifications() { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 DeveloperPrivateGetExtensionsInfoFunction:: | 472 DeveloperPrivateGetExtensionsInfoFunction:: |
| 474 DeveloperPrivateGetExtensionsInfoFunction() { | 473 DeveloperPrivateGetExtensionsInfoFunction() { |
| 475 } | 474 } |
| 476 | 475 |
| 477 DeveloperPrivateGetExtensionsInfoFunction:: | 476 DeveloperPrivateGetExtensionsInfoFunction:: |
| 478 ~DeveloperPrivateGetExtensionsInfoFunction() { | 477 ~DeveloperPrivateGetExtensionsInfoFunction() { |
| 479 } | 478 } |
| 480 | 479 |
| 481 ExtensionFunction::ResponseAction | 480 ExtensionFunction::ResponseAction |
| 482 DeveloperPrivateGetExtensionsInfoFunction::Run() { | 481 DeveloperPrivateGetExtensionsInfoFunction::Run() { |
| 483 scoped_ptr<developer::GetExtensionsInfo::Params> params( | 482 std::unique_ptr<developer::GetExtensionsInfo::Params> params( |
| 484 developer::GetExtensionsInfo::Params::Create(*args_)); | 483 developer::GetExtensionsInfo::Params::Create(*args_)); |
| 485 EXTENSION_FUNCTION_VALIDATE(params); | 484 EXTENSION_FUNCTION_VALIDATE(params); |
| 486 | 485 |
| 487 bool include_disabled = true; | 486 bool include_disabled = true; |
| 488 bool include_terminated = true; | 487 bool include_terminated = true; |
| 489 if (params->options) { | 488 if (params->options) { |
| 490 if (params->options->include_disabled) | 489 if (params->options->include_disabled) |
| 491 include_disabled = *params->options->include_disabled; | 490 include_disabled = *params->options->include_disabled; |
| 492 if (params->options->include_terminated) | 491 if (params->options->include_terminated) |
| 493 include_terminated = *params->options->include_terminated; | 492 include_terminated = *params->options->include_terminated; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 511 DeveloperPrivateGetExtensionInfoFunction:: | 510 DeveloperPrivateGetExtensionInfoFunction:: |
| 512 DeveloperPrivateGetExtensionInfoFunction() { | 511 DeveloperPrivateGetExtensionInfoFunction() { |
| 513 } | 512 } |
| 514 | 513 |
| 515 DeveloperPrivateGetExtensionInfoFunction:: | 514 DeveloperPrivateGetExtensionInfoFunction:: |
| 516 ~DeveloperPrivateGetExtensionInfoFunction() { | 515 ~DeveloperPrivateGetExtensionInfoFunction() { |
| 517 } | 516 } |
| 518 | 517 |
| 519 ExtensionFunction::ResponseAction | 518 ExtensionFunction::ResponseAction |
| 520 DeveloperPrivateGetExtensionInfoFunction::Run() { | 519 DeveloperPrivateGetExtensionInfoFunction::Run() { |
| 521 scoped_ptr<developer::GetExtensionInfo::Params> params( | 520 std::unique_ptr<developer::GetExtensionInfo::Params> params( |
| 522 developer::GetExtensionInfo::Params::Create(*args_)); | 521 developer::GetExtensionInfo::Params::Create(*args_)); |
| 523 EXTENSION_FUNCTION_VALIDATE(params); | 522 EXTENSION_FUNCTION_VALIDATE(params); |
| 524 | 523 |
| 525 info_generator_.reset(new ExtensionInfoGenerator(browser_context())); | 524 info_generator_.reset(new ExtensionInfoGenerator(browser_context())); |
| 526 info_generator_->CreateExtensionInfo( | 525 info_generator_->CreateExtensionInfo( |
| 527 params->id, | 526 params->id, |
| 528 base::Bind(&DeveloperPrivateGetExtensionInfoFunction::OnInfosGenerated, | 527 base::Bind(&DeveloperPrivateGetExtensionInfoFunction::OnInfosGenerated, |
| 529 this /* refcounted */)); | 528 this /* refcounted */)); |
| 530 | 529 |
| 531 return RespondLater(); | 530 return RespondLater(); |
| 532 } | 531 } |
| 533 | 532 |
| 534 void DeveloperPrivateGetExtensionInfoFunction::OnInfosGenerated( | 533 void DeveloperPrivateGetExtensionInfoFunction::OnInfosGenerated( |
| 535 ExtensionInfoGenerator::ExtensionInfoList list) { | 534 ExtensionInfoGenerator::ExtensionInfoList list) { |
| 536 DCHECK_LE(1u, list.size()); | 535 DCHECK_LE(1u, list.size()); |
| 537 Respond(list.empty() ? Error(kNoSuchExtensionError) | 536 Respond(list.empty() ? Error(kNoSuchExtensionError) |
| 538 : OneArgument(list[0].ToValue())); | 537 : OneArgument(list[0].ToValue())); |
| 539 } | 538 } |
| 540 | 539 |
| 541 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {} | 540 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {} |
| 542 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {} | 541 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {} |
| 543 | 542 |
| 544 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() { | 543 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() { |
| 545 scoped_ptr<developer::GetItemsInfo::Params> params( | 544 std::unique_ptr<developer::GetItemsInfo::Params> params( |
| 546 developer::GetItemsInfo::Params::Create(*args_)); | 545 developer::GetItemsInfo::Params::Create(*args_)); |
| 547 EXTENSION_FUNCTION_VALIDATE(params); | 546 EXTENSION_FUNCTION_VALIDATE(params); |
| 548 | 547 |
| 549 info_generator_.reset(new ExtensionInfoGenerator(browser_context())); | 548 info_generator_.reset(new ExtensionInfoGenerator(browser_context())); |
| 550 info_generator_->CreateExtensionsInfo( | 549 info_generator_->CreateExtensionsInfo( |
| 551 params->include_disabled, | 550 params->include_disabled, |
| 552 params->include_terminated, | 551 params->include_terminated, |
| 553 base::Bind(&DeveloperPrivateGetItemsInfoFunction::OnInfosGenerated, | 552 base::Bind(&DeveloperPrivateGetItemsInfoFunction::OnInfosGenerated, |
| 554 this /* refcounted */)); | 553 this /* refcounted */)); |
| 555 | 554 |
| 556 return RespondLater(); | 555 return RespondLater(); |
| 557 } | 556 } |
| 558 | 557 |
| 559 void DeveloperPrivateGetItemsInfoFunction::OnInfosGenerated( | 558 void DeveloperPrivateGetItemsInfoFunction::OnInfosGenerated( |
| 560 ExtensionInfoGenerator::ExtensionInfoList list) { | 559 ExtensionInfoGenerator::ExtensionInfoList list) { |
| 561 std::vector<developer::ItemInfo> item_list; | 560 std::vector<developer::ItemInfo> item_list; |
| 562 for (const developer::ExtensionInfo& info : list) | 561 for (const developer::ExtensionInfo& info : list) |
| 563 item_list.push_back(developer_private_mangle::MangleExtensionInfo(info)); | 562 item_list.push_back(developer_private_mangle::MangleExtensionInfo(info)); |
| 564 | 563 |
| 565 Respond(ArgumentList(developer::GetItemsInfo::Results::Create(item_list))); | 564 Respond(ArgumentList(developer::GetItemsInfo::Results::Create(item_list))); |
| 566 } | 565 } |
| 567 | 566 |
| 568 DeveloperPrivateGetProfileConfigurationFunction:: | 567 DeveloperPrivateGetProfileConfigurationFunction:: |
| 569 ~DeveloperPrivateGetProfileConfigurationFunction() { | 568 ~DeveloperPrivateGetProfileConfigurationFunction() { |
| 570 } | 569 } |
| 571 | 570 |
| 572 ExtensionFunction::ResponseAction | 571 ExtensionFunction::ResponseAction |
| 573 DeveloperPrivateGetProfileConfigurationFunction::Run() { | 572 DeveloperPrivateGetProfileConfigurationFunction::Run() { |
| 574 scoped_ptr<developer::ProfileInfo> info = CreateProfileInfo(GetProfile()); | 573 std::unique_ptr<developer::ProfileInfo> info = |
| 574 CreateProfileInfo(GetProfile()); |
| 575 | 575 |
| 576 // If this is called from the chrome://extensions page, we use this as a | 576 // If this is called from the chrome://extensions page, we use this as a |
| 577 // heuristic that it's a good time to verify installs. We do this on startup, | 577 // heuristic that it's a good time to verify installs. We do this on startup, |
| 578 // but there's a chance that it failed erroneously, so it's good to double- | 578 // but there's a chance that it failed erroneously, so it's good to double- |
| 579 // check. | 579 // check. |
| 580 if (source_context_type() == Feature::WEBUI_CONTEXT) | 580 if (source_context_type() == Feature::WEBUI_CONTEXT) |
| 581 PerformVerificationCheck(browser_context()); | 581 PerformVerificationCheck(browser_context()); |
| 582 | 582 |
| 583 return RespondNow(OneArgument(info->ToValue())); | 583 return RespondNow(OneArgument(info->ToValue())); |
| 584 } | 584 } |
| 585 | 585 |
| 586 DeveloperPrivateUpdateProfileConfigurationFunction:: | 586 DeveloperPrivateUpdateProfileConfigurationFunction:: |
| 587 ~DeveloperPrivateUpdateProfileConfigurationFunction() { | 587 ~DeveloperPrivateUpdateProfileConfigurationFunction() { |
| 588 } | 588 } |
| 589 | 589 |
| 590 ExtensionFunction::ResponseAction | 590 ExtensionFunction::ResponseAction |
| 591 DeveloperPrivateUpdateProfileConfigurationFunction::Run() { | 591 DeveloperPrivateUpdateProfileConfigurationFunction::Run() { |
| 592 scoped_ptr<developer::UpdateProfileConfiguration::Params> params( | 592 std::unique_ptr<developer::UpdateProfileConfiguration::Params> params( |
| 593 developer::UpdateProfileConfiguration::Params::Create(*args_)); | 593 developer::UpdateProfileConfiguration::Params::Create(*args_)); |
| 594 EXTENSION_FUNCTION_VALIDATE(params); | 594 EXTENSION_FUNCTION_VALIDATE(params); |
| 595 | 595 |
| 596 const developer::ProfileConfigurationUpdate& update = params->update; | 596 const developer::ProfileConfigurationUpdate& update = params->update; |
| 597 PrefService* prefs = GetProfile()->GetPrefs(); | 597 PrefService* prefs = GetProfile()->GetPrefs(); |
| 598 if (update.in_developer_mode) { | 598 if (update.in_developer_mode) { |
| 599 if (GetProfile()->IsSupervised()) | 599 if (GetProfile()->IsSupervised()) |
| 600 return RespondNow(Error(kCannotUpdateSupervisedProfileSettingsError)); | 600 return RespondNow(Error(kCannotUpdateSupervisedProfileSettingsError)); |
| 601 prefs->SetBoolean(prefs::kExtensionsUIDeveloperMode, | 601 prefs->SetBoolean(prefs::kExtensionsUIDeveloperMode, |
| 602 *update.in_developer_mode); | 602 *update.in_developer_mode); |
| 603 } | 603 } |
| 604 | 604 |
| 605 return RespondNow(NoArguments()); | 605 return RespondNow(NoArguments()); |
| 606 } | 606 } |
| 607 | 607 |
| 608 DeveloperPrivateUpdateExtensionConfigurationFunction:: | 608 DeveloperPrivateUpdateExtensionConfigurationFunction:: |
| 609 ~DeveloperPrivateUpdateExtensionConfigurationFunction() {} | 609 ~DeveloperPrivateUpdateExtensionConfigurationFunction() {} |
| 610 | 610 |
| 611 ExtensionFunction::ResponseAction | 611 ExtensionFunction::ResponseAction |
| 612 DeveloperPrivateUpdateExtensionConfigurationFunction::Run() { | 612 DeveloperPrivateUpdateExtensionConfigurationFunction::Run() { |
| 613 scoped_ptr<developer::UpdateExtensionConfiguration::Params> params( | 613 std::unique_ptr<developer::UpdateExtensionConfiguration::Params> params( |
| 614 developer::UpdateExtensionConfiguration::Params::Create(*args_)); | 614 developer::UpdateExtensionConfiguration::Params::Create(*args_)); |
| 615 EXTENSION_FUNCTION_VALIDATE(params); | 615 EXTENSION_FUNCTION_VALIDATE(params); |
| 616 | 616 |
| 617 const developer::ExtensionConfigurationUpdate& update = params->update; | 617 const developer::ExtensionConfigurationUpdate& update = params->update; |
| 618 | 618 |
| 619 const Extension* extension = GetExtensionById(update.extension_id); | 619 const Extension* extension = GetExtensionById(update.extension_id); |
| 620 if (!extension) | 620 if (!extension) |
| 621 return RespondNow(Error(kNoSuchExtensionError)); | 621 return RespondNow(Error(kNoSuchExtensionError)); |
| 622 if (!user_gesture()) | 622 if (!user_gesture()) |
| 623 return RespondNow(Error(kRequiresUserGestureError)); | 623 return RespondNow(Error(kRequiresUserGestureError)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 649 extension->id(), | 649 extension->id(), |
| 650 *update.show_action_button); | 650 *update.show_action_button); |
| 651 } | 651 } |
| 652 | 652 |
| 653 return RespondNow(NoArguments()); | 653 return RespondNow(NoArguments()); |
| 654 } | 654 } |
| 655 | 655 |
| 656 DeveloperPrivateReloadFunction::~DeveloperPrivateReloadFunction() {} | 656 DeveloperPrivateReloadFunction::~DeveloperPrivateReloadFunction() {} |
| 657 | 657 |
| 658 ExtensionFunction::ResponseAction DeveloperPrivateReloadFunction::Run() { | 658 ExtensionFunction::ResponseAction DeveloperPrivateReloadFunction::Run() { |
| 659 scoped_ptr<Reload::Params> params(Reload::Params::Create(*args_)); | 659 std::unique_ptr<Reload::Params> params(Reload::Params::Create(*args_)); |
| 660 EXTENSION_FUNCTION_VALIDATE(params.get()); | 660 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 661 | 661 |
| 662 const Extension* extension = GetExtensionById(params->extension_id); | 662 const Extension* extension = GetExtensionById(params->extension_id); |
| 663 if (!extension) | 663 if (!extension) |
| 664 return RespondNow(Error(kNoSuchExtensionError)); | 664 return RespondNow(Error(kNoSuchExtensionError)); |
| 665 | 665 |
| 666 bool fail_quietly = params->options && | 666 bool fail_quietly = params->options && |
| 667 params->options->fail_quietly && | 667 params->options->fail_quietly && |
| 668 *params->options->fail_quietly; | 668 *params->options->fail_quietly; |
| 669 | 669 |
| 670 ExtensionService* service = GetExtensionService(browser_context()); | 670 ExtensionService* service = GetExtensionService(browser_context()); |
| 671 if (fail_quietly) | 671 if (fail_quietly) |
| 672 service->ReloadExtensionWithQuietFailure(params->extension_id); | 672 service->ReloadExtensionWithQuietFailure(params->extension_id); |
| 673 else | 673 else |
| 674 service->ReloadExtension(params->extension_id); | 674 service->ReloadExtension(params->extension_id); |
| 675 | 675 |
| 676 // TODO(devlin): We shouldn't return until the extension has finished trying | 676 // TODO(devlin): We shouldn't return until the extension has finished trying |
| 677 // to reload (and then we could also return the error). | 677 // to reload (and then we could also return the error). |
| 678 return RespondNow(NoArguments()); | 678 return RespondNow(NoArguments()); |
| 679 } | 679 } |
| 680 | 680 |
| 681 DeveloperPrivateShowPermissionsDialogFunction:: | 681 DeveloperPrivateShowPermissionsDialogFunction:: |
| 682 DeveloperPrivateShowPermissionsDialogFunction() {} | 682 DeveloperPrivateShowPermissionsDialogFunction() {} |
| 683 | 683 |
| 684 DeveloperPrivateShowPermissionsDialogFunction:: | 684 DeveloperPrivateShowPermissionsDialogFunction:: |
| 685 ~DeveloperPrivateShowPermissionsDialogFunction() {} | 685 ~DeveloperPrivateShowPermissionsDialogFunction() {} |
| 686 | 686 |
| 687 ExtensionFunction::ResponseAction | 687 ExtensionFunction::ResponseAction |
| 688 DeveloperPrivateShowPermissionsDialogFunction::Run() { | 688 DeveloperPrivateShowPermissionsDialogFunction::Run() { |
| 689 scoped_ptr<developer::ShowPermissionsDialog::Params> params( | 689 std::unique_ptr<developer::ShowPermissionsDialog::Params> params( |
| 690 developer::ShowPermissionsDialog::Params::Create(*args_)); | 690 developer::ShowPermissionsDialog::Params::Create(*args_)); |
| 691 EXTENSION_FUNCTION_VALIDATE(params); | 691 EXTENSION_FUNCTION_VALIDATE(params); |
| 692 | 692 |
| 693 const Extension* target_extension = GetExtensionById(params->extension_id); | 693 const Extension* target_extension = GetExtensionById(params->extension_id); |
| 694 if (!target_extension) | 694 if (!target_extension) |
| 695 return RespondNow(Error(kNoSuchExtensionError)); | 695 return RespondNow(Error(kNoSuchExtensionError)); |
| 696 | 696 |
| 697 content::WebContents* web_contents = GetSenderWebContents(); | 697 content::WebContents* web_contents = GetSenderWebContents(); |
| 698 if (!web_contents) | 698 if (!web_contents) |
| 699 return RespondNow(Error(kCouldNotFindWebContentsError)); | 699 return RespondNow(Error(kCouldNotFindWebContentsError)); |
| 700 | 700 |
| 701 ShowPermissionsDialogHelper::Show( | 701 ShowPermissionsDialogHelper::Show( |
| 702 browser_context(), | 702 browser_context(), |
| 703 web_contents, | 703 web_contents, |
| 704 target_extension, | 704 target_extension, |
| 705 source_context_type() == Feature::WEBUI_CONTEXT, | 705 source_context_type() == Feature::WEBUI_CONTEXT, |
| 706 base::Bind(&DeveloperPrivateShowPermissionsDialogFunction::Finish, this)); | 706 base::Bind(&DeveloperPrivateShowPermissionsDialogFunction::Finish, this)); |
| 707 return RespondLater(); | 707 return RespondLater(); |
| 708 } | 708 } |
| 709 | 709 |
| 710 void DeveloperPrivateShowPermissionsDialogFunction::Finish() { | 710 void DeveloperPrivateShowPermissionsDialogFunction::Finish() { |
| 711 Respond(NoArguments()); | 711 Respond(NoArguments()); |
| 712 } | 712 } |
| 713 | 713 |
| 714 DeveloperPrivateLoadUnpackedFunction::DeveloperPrivateLoadUnpackedFunction() | 714 DeveloperPrivateLoadUnpackedFunction::DeveloperPrivateLoadUnpackedFunction() |
| 715 : fail_quietly_(false) { | 715 : fail_quietly_(false) { |
| 716 } | 716 } |
| 717 | 717 |
| 718 ExtensionFunction::ResponseAction DeveloperPrivateLoadUnpackedFunction::Run() { | 718 ExtensionFunction::ResponseAction DeveloperPrivateLoadUnpackedFunction::Run() { |
| 719 scoped_ptr<developer::LoadUnpacked::Params> params( | 719 std::unique_ptr<developer::LoadUnpacked::Params> params( |
| 720 developer::LoadUnpacked::Params::Create(*args_)); | 720 developer::LoadUnpacked::Params::Create(*args_)); |
| 721 EXTENSION_FUNCTION_VALIDATE(params); | 721 EXTENSION_FUNCTION_VALIDATE(params); |
| 722 | 722 |
| 723 if (!ShowPicker( | 723 if (!ShowPicker( |
| 724 ui::SelectFileDialog::SELECT_FOLDER, | 724 ui::SelectFileDialog::SELECT_FOLDER, |
| 725 l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY), | 725 l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY), |
| 726 ui::SelectFileDialog::FileTypeInfo(), | 726 ui::SelectFileDialog::FileTypeInfo(), |
| 727 0 /* file_type_index */)) { | 727 0 /* file_type_index */)) { |
| 728 return RespondNow(Error(kCouldNotShowSelectFileDialogError)); | 728 return RespondNow(Error(kCouldNotShowSelectFileDialogError)); |
| 729 } | 729 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 response.override_flags = ExtensionCreator::kOverwriteCRX; | 812 response.override_flags = ExtensionCreator::kOverwriteCRX; |
| 813 response.status = developer::PACK_STATUS_WARNING; | 813 response.status = developer::PACK_STATUS_WARNING; |
| 814 } else { | 814 } else { |
| 815 response.status = developer::PACK_STATUS_ERROR; | 815 response.status = developer::PACK_STATUS_ERROR; |
| 816 } | 816 } |
| 817 Respond(OneArgument(response.ToValue())); | 817 Respond(OneArgument(response.ToValue())); |
| 818 Release(); // Balanced in Run(). | 818 Release(); // Balanced in Run(). |
| 819 } | 819 } |
| 820 | 820 |
| 821 ExtensionFunction::ResponseAction DeveloperPrivatePackDirectoryFunction::Run() { | 821 ExtensionFunction::ResponseAction DeveloperPrivatePackDirectoryFunction::Run() { |
| 822 scoped_ptr<PackDirectory::Params> params( | 822 std::unique_ptr<PackDirectory::Params> params( |
| 823 PackDirectory::Params::Create(*args_)); | 823 PackDirectory::Params::Create(*args_)); |
| 824 EXTENSION_FUNCTION_VALIDATE(params); | 824 EXTENSION_FUNCTION_VALIDATE(params); |
| 825 | 825 |
| 826 int flags = params->flags ? *params->flags : 0; | 826 int flags = params->flags ? *params->flags : 0; |
| 827 item_path_str_ = params->path; | 827 item_path_str_ = params->path; |
| 828 if (params->private_key_path) | 828 if (params->private_key_path) |
| 829 key_path_str_ = *params->private_key_path; | 829 key_path_str_ = *params->private_key_path; |
| 830 | 830 |
| 831 base::FilePath root_directory = | 831 base::FilePath root_directory = |
| 832 base::FilePath::FromUTF8Unsafe(item_path_str_); | 832 base::FilePath::FromUTF8Unsafe(item_path_str_); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 } | 1092 } |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 DeveloperPrivateLoadDirectoryFunction::DeveloperPrivateLoadDirectoryFunction() | 1095 DeveloperPrivateLoadDirectoryFunction::DeveloperPrivateLoadDirectoryFunction() |
| 1096 : pending_copy_operations_count_(0), success_(true) {} | 1096 : pending_copy_operations_count_(0), success_(true) {} |
| 1097 | 1097 |
| 1098 DeveloperPrivateLoadDirectoryFunction::~DeveloperPrivateLoadDirectoryFunction() | 1098 DeveloperPrivateLoadDirectoryFunction::~DeveloperPrivateLoadDirectoryFunction() |
| 1099 {} | 1099 {} |
| 1100 | 1100 |
| 1101 ExtensionFunction::ResponseAction DeveloperPrivateChoosePathFunction::Run() { | 1101 ExtensionFunction::ResponseAction DeveloperPrivateChoosePathFunction::Run() { |
| 1102 scoped_ptr<developer::ChoosePath::Params> params( | 1102 std::unique_ptr<developer::ChoosePath::Params> params( |
| 1103 developer::ChoosePath::Params::Create(*args_)); | 1103 developer::ChoosePath::Params::Create(*args_)); |
| 1104 EXTENSION_FUNCTION_VALIDATE(params); | 1104 EXTENSION_FUNCTION_VALIDATE(params); |
| 1105 | 1105 |
| 1106 ui::SelectFileDialog::Type type = ui::SelectFileDialog::SELECT_FOLDER; | 1106 ui::SelectFileDialog::Type type = ui::SelectFileDialog::SELECT_FOLDER; |
| 1107 ui::SelectFileDialog::FileTypeInfo info; | 1107 ui::SelectFileDialog::FileTypeInfo info; |
| 1108 | 1108 |
| 1109 if (params->select_type == developer::SELECT_TYPE_FILE) | 1109 if (params->select_type == developer::SELECT_TYPE_FILE) |
| 1110 type = ui::SelectFileDialog::SELECT_OPEN_FILE; | 1110 type = ui::SelectFileDialog::SELECT_OPEN_FILE; |
| 1111 base::string16 select_title; | 1111 base::string16 select_title; |
| 1112 | 1112 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 | 1211 |
| 1212 developer::RequestFileSourceResponse response; | 1212 developer::RequestFileSourceResponse response; |
| 1213 base::FilePath path_suffix = | 1213 base::FilePath path_suffix = |
| 1214 base::FilePath::FromUTF8Unsafe(properties.path_suffix); | 1214 base::FilePath::FromUTF8Unsafe(properties.path_suffix); |
| 1215 base::FilePath path = extension->path().Append(path_suffix); | 1215 base::FilePath path = extension->path().Append(path_suffix); |
| 1216 response.title = base::StringPrintf("%s: %s", | 1216 response.title = base::StringPrintf("%s: %s", |
| 1217 extension->name().c_str(), | 1217 extension->name().c_str(), |
| 1218 path.BaseName().AsUTF8Unsafe().c_str()); | 1218 path.BaseName().AsUTF8Unsafe().c_str()); |
| 1219 response.message = properties.message; | 1219 response.message = properties.message; |
| 1220 | 1220 |
| 1221 scoped_ptr<FileHighlighter> highlighter; | 1221 std::unique_ptr<FileHighlighter> highlighter; |
| 1222 if (properties.path_suffix == kManifestFile) { | 1222 if (properties.path_suffix == kManifestFile) { |
| 1223 highlighter.reset(new ManifestHighlighter( | 1223 highlighter.reset(new ManifestHighlighter( |
| 1224 file_contents, | 1224 file_contents, |
| 1225 *properties.manifest_key, | 1225 *properties.manifest_key, |
| 1226 properties.manifest_specific ? | 1226 properties.manifest_specific ? |
| 1227 *properties.manifest_specific : std::string())); | 1227 *properties.manifest_specific : std::string())); |
| 1228 } else { | 1228 } else { |
| 1229 highlighter.reset(new SourceHighlighter( | 1229 highlighter.reset(new SourceHighlighter( |
| 1230 file_contents, | 1230 file_contents, |
| 1231 properties.line_number ? *properties.line_number : 0)); | 1231 properties.line_number ? *properties.line_number : 0)); |
| 1232 } | 1232 } |
| 1233 | 1233 |
| 1234 response.before_highlight = highlighter->GetBeforeFeature(); | 1234 response.before_highlight = highlighter->GetBeforeFeature(); |
| 1235 response.highlight = highlighter->GetFeature(); | 1235 response.highlight = highlighter->GetFeature(); |
| 1236 response.after_highlight = highlighter->GetAfterFeature(); | 1236 response.after_highlight = highlighter->GetAfterFeature(); |
| 1237 | 1237 |
| 1238 Respond(OneArgument(response.ToValue())); | 1238 Respond(OneArgument(response.ToValue())); |
| 1239 } | 1239 } |
| 1240 | 1240 |
| 1241 DeveloperPrivateOpenDevToolsFunction::DeveloperPrivateOpenDevToolsFunction() {} | 1241 DeveloperPrivateOpenDevToolsFunction::DeveloperPrivateOpenDevToolsFunction() {} |
| 1242 DeveloperPrivateOpenDevToolsFunction::~DeveloperPrivateOpenDevToolsFunction() {} | 1242 DeveloperPrivateOpenDevToolsFunction::~DeveloperPrivateOpenDevToolsFunction() {} |
| 1243 | 1243 |
| 1244 ExtensionFunction::ResponseAction | 1244 ExtensionFunction::ResponseAction |
| 1245 DeveloperPrivateOpenDevToolsFunction::Run() { | 1245 DeveloperPrivateOpenDevToolsFunction::Run() { |
| 1246 scoped_ptr<developer::OpenDevTools::Params> params( | 1246 std::unique_ptr<developer::OpenDevTools::Params> params( |
| 1247 developer::OpenDevTools::Params::Create(*args_)); | 1247 developer::OpenDevTools::Params::Create(*args_)); |
| 1248 EXTENSION_FUNCTION_VALIDATE(params); | 1248 EXTENSION_FUNCTION_VALIDATE(params); |
| 1249 const developer::OpenDevToolsProperties& properties = params->properties; | 1249 const developer::OpenDevToolsProperties& properties = params->properties; |
| 1250 | 1250 |
| 1251 if (properties.render_process_id == -1) { | 1251 if (properties.render_process_id == -1) { |
| 1252 // This is a lazy background page. | 1252 // This is a lazy background page. |
| 1253 const Extension* extension = properties.extension_id ? | 1253 const Extension* extension = properties.extension_id ? |
| 1254 GetEnabledExtensionById(*properties.extension_id) : nullptr; | 1254 GetEnabledExtensionById(*properties.extension_id) : nullptr; |
| 1255 if (!extension) | 1255 if (!extension) |
| 1256 return RespondNow(Error(kNoSuchExtensionError)); | 1256 return RespondNow(Error(kNoSuchExtensionError)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(web_contents), | 1305 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(web_contents), |
| 1306 false); // Not through direct user gesture. | 1306 false); // Not through direct user gesture. |
| 1307 return RespondNow(NoArguments()); | 1307 return RespondNow(NoArguments()); |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 DeveloperPrivateDeleteExtensionErrorsFunction:: | 1310 DeveloperPrivateDeleteExtensionErrorsFunction:: |
| 1311 ~DeveloperPrivateDeleteExtensionErrorsFunction() {} | 1311 ~DeveloperPrivateDeleteExtensionErrorsFunction() {} |
| 1312 | 1312 |
| 1313 ExtensionFunction::ResponseAction | 1313 ExtensionFunction::ResponseAction |
| 1314 DeveloperPrivateDeleteExtensionErrorsFunction::Run() { | 1314 DeveloperPrivateDeleteExtensionErrorsFunction::Run() { |
| 1315 scoped_ptr<developer::DeleteExtensionErrors::Params> params( | 1315 std::unique_ptr<developer::DeleteExtensionErrors::Params> params( |
| 1316 developer::DeleteExtensionErrors::Params::Create(*args_)); | 1316 developer::DeleteExtensionErrors::Params::Create(*args_)); |
| 1317 EXTENSION_FUNCTION_VALIDATE(params); | 1317 EXTENSION_FUNCTION_VALIDATE(params); |
| 1318 const developer::DeleteExtensionErrorsProperties& properties = | 1318 const developer::DeleteExtensionErrorsProperties& properties = |
| 1319 params->properties; | 1319 params->properties; |
| 1320 | 1320 |
| 1321 ErrorConsole* error_console = ErrorConsole::Get(GetProfile()); | 1321 ErrorConsole* error_console = ErrorConsole::Get(GetProfile()); |
| 1322 int type = -1; | 1322 int type = -1; |
| 1323 if (properties.type != developer::ERROR_TYPE_NONE) { | 1323 if (properties.type != developer::ERROR_TYPE_NONE) { |
| 1324 type = properties.type == developer::ERROR_TYPE_MANIFEST ? | 1324 type = properties.type == developer::ERROR_TYPE_MANIFEST ? |
| 1325 ExtensionError::MANIFEST_ERROR : ExtensionError::RUNTIME_ERROR; | 1325 ExtensionError::MANIFEST_ERROR : ExtensionError::RUNTIME_ERROR; |
| 1326 } | 1326 } |
| 1327 std::set<int> error_ids; | 1327 std::set<int> error_ids; |
| 1328 if (properties.error_ids) { | 1328 if (properties.error_ids) { |
| 1329 error_ids.insert(properties.error_ids->begin(), | 1329 error_ids.insert(properties.error_ids->begin(), |
| 1330 properties.error_ids->end()); | 1330 properties.error_ids->end()); |
| 1331 } | 1331 } |
| 1332 error_console->RemoveErrors(ErrorMap::Filter( | 1332 error_console->RemoveErrors(ErrorMap::Filter( |
| 1333 properties.extension_id, type, error_ids, false)); | 1333 properties.extension_id, type, error_ids, false)); |
| 1334 | 1334 |
| 1335 return RespondNow(NoArguments()); | 1335 return RespondNow(NoArguments()); |
| 1336 } | 1336 } |
| 1337 | 1337 |
| 1338 DeveloperPrivateRepairExtensionFunction:: | 1338 DeveloperPrivateRepairExtensionFunction:: |
| 1339 ~DeveloperPrivateRepairExtensionFunction() {} | 1339 ~DeveloperPrivateRepairExtensionFunction() {} |
| 1340 | 1340 |
| 1341 ExtensionFunction::ResponseAction | 1341 ExtensionFunction::ResponseAction |
| 1342 DeveloperPrivateRepairExtensionFunction::Run() { | 1342 DeveloperPrivateRepairExtensionFunction::Run() { |
| 1343 scoped_ptr<developer::RepairExtension::Params> params( | 1343 std::unique_ptr<developer::RepairExtension::Params> params( |
| 1344 developer::RepairExtension::Params::Create(*args_)); | 1344 developer::RepairExtension::Params::Create(*args_)); |
| 1345 EXTENSION_FUNCTION_VALIDATE(params); | 1345 EXTENSION_FUNCTION_VALIDATE(params); |
| 1346 const Extension* extension = GetExtensionById(params->extension_id); | 1346 const Extension* extension = GetExtensionById(params->extension_id); |
| 1347 if (!extension) | 1347 if (!extension) |
| 1348 return RespondNow(Error(kNoSuchExtensionError)); | 1348 return RespondNow(Error(kNoSuchExtensionError)); |
| 1349 | 1349 |
| 1350 content::WebContents* web_contents = GetSenderWebContents(); | 1350 content::WebContents* web_contents = GetSenderWebContents(); |
| 1351 if (!web_contents) | 1351 if (!web_contents) |
| 1352 return RespondNow(Error(kCouldNotFindWebContentsError)); | 1352 return RespondNow(Error(kCouldNotFindWebContentsError)); |
| 1353 | 1353 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1364 void DeveloperPrivateRepairExtensionFunction::OnReinstallComplete( | 1364 void DeveloperPrivateRepairExtensionFunction::OnReinstallComplete( |
| 1365 bool success, | 1365 bool success, |
| 1366 const std::string& error, | 1366 const std::string& error, |
| 1367 webstore_install::Result result) { | 1367 webstore_install::Result result) { |
| 1368 Respond(success ? NoArguments() : Error(error)); | 1368 Respond(success ? NoArguments() : Error(error)); |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 DeveloperPrivateShowOptionsFunction::~DeveloperPrivateShowOptionsFunction() {} | 1371 DeveloperPrivateShowOptionsFunction::~DeveloperPrivateShowOptionsFunction() {} |
| 1372 | 1372 |
| 1373 ExtensionFunction::ResponseAction DeveloperPrivateShowOptionsFunction::Run() { | 1373 ExtensionFunction::ResponseAction DeveloperPrivateShowOptionsFunction::Run() { |
| 1374 scoped_ptr<developer::ShowOptions::Params> params( | 1374 std::unique_ptr<developer::ShowOptions::Params> params( |
| 1375 developer::ShowOptions::Params::Create(*args_)); | 1375 developer::ShowOptions::Params::Create(*args_)); |
| 1376 EXTENSION_FUNCTION_VALIDATE(params); | 1376 EXTENSION_FUNCTION_VALIDATE(params); |
| 1377 const Extension* extension = GetEnabledExtensionById(params->extension_id); | 1377 const Extension* extension = GetEnabledExtensionById(params->extension_id); |
| 1378 if (!extension) | 1378 if (!extension) |
| 1379 return RespondNow(Error(kNoSuchExtensionError)); | 1379 return RespondNow(Error(kNoSuchExtensionError)); |
| 1380 | 1380 |
| 1381 if (OptionsPageInfo::GetOptionsPage(extension).is_empty()) | 1381 if (OptionsPageInfo::GetOptionsPage(extension).is_empty()) |
| 1382 return RespondNow(Error(kNoOptionsPageForExtensionError)); | 1382 return RespondNow(Error(kNoOptionsPageForExtensionError)); |
| 1383 | 1383 |
| 1384 content::WebContents* web_contents = GetSenderWebContents(); | 1384 content::WebContents* web_contents = GetSenderWebContents(); |
| 1385 if (!web_contents) | 1385 if (!web_contents) |
| 1386 return RespondNow(Error(kCouldNotFindWebContentsError)); | 1386 return RespondNow(Error(kCouldNotFindWebContentsError)); |
| 1387 | 1387 |
| 1388 ExtensionTabUtil::OpenOptionsPage( | 1388 ExtensionTabUtil::OpenOptionsPage( |
| 1389 extension, | 1389 extension, |
| 1390 chrome::FindBrowserWithWebContents(web_contents)); | 1390 chrome::FindBrowserWithWebContents(web_contents)); |
| 1391 return RespondNow(NoArguments()); | 1391 return RespondNow(NoArguments()); |
| 1392 } | 1392 } |
| 1393 | 1393 |
| 1394 DeveloperPrivateShowPathFunction::~DeveloperPrivateShowPathFunction() {} | 1394 DeveloperPrivateShowPathFunction::~DeveloperPrivateShowPathFunction() {} |
| 1395 | 1395 |
| 1396 ExtensionFunction::ResponseAction DeveloperPrivateShowPathFunction::Run() { | 1396 ExtensionFunction::ResponseAction DeveloperPrivateShowPathFunction::Run() { |
| 1397 scoped_ptr<developer::ShowPath::Params> params( | 1397 std::unique_ptr<developer::ShowPath::Params> params( |
| 1398 developer::ShowPath::Params::Create(*args_)); | 1398 developer::ShowPath::Params::Create(*args_)); |
| 1399 EXTENSION_FUNCTION_VALIDATE(params); | 1399 EXTENSION_FUNCTION_VALIDATE(params); |
| 1400 const Extension* extension = GetExtensionById(params->extension_id); | 1400 const Extension* extension = GetExtensionById(params->extension_id); |
| 1401 if (!extension) | 1401 if (!extension) |
| 1402 return RespondNow(Error(kNoSuchExtensionError)); | 1402 return RespondNow(Error(kNoSuchExtensionError)); |
| 1403 | 1403 |
| 1404 // We explicitly show manifest.json in order to work around an issue in OSX | 1404 // We explicitly show manifest.json in order to work around an issue in OSX |
| 1405 // where opening the directory doesn't focus the Finder. | 1405 // where opening the directory doesn't focus the Finder. |
| 1406 platform_util::ShowItemInFolder(GetProfile(), | 1406 platform_util::ShowItemInFolder(GetProfile(), |
| 1407 extension->path().Append(kManifestFilename)); | 1407 extension->path().Append(kManifestFilename)); |
| 1408 return RespondNow(NoArguments()); | 1408 return RespondNow(NoArguments()); |
| 1409 } | 1409 } |
| 1410 | 1410 |
| 1411 DeveloperPrivateSetShortcutHandlingSuspendedFunction:: | 1411 DeveloperPrivateSetShortcutHandlingSuspendedFunction:: |
| 1412 ~DeveloperPrivateSetShortcutHandlingSuspendedFunction() {} | 1412 ~DeveloperPrivateSetShortcutHandlingSuspendedFunction() {} |
| 1413 | 1413 |
| 1414 ExtensionFunction::ResponseAction | 1414 ExtensionFunction::ResponseAction |
| 1415 DeveloperPrivateSetShortcutHandlingSuspendedFunction::Run() { | 1415 DeveloperPrivateSetShortcutHandlingSuspendedFunction::Run() { |
| 1416 scoped_ptr<developer::SetShortcutHandlingSuspended::Params> params( | 1416 std::unique_ptr<developer::SetShortcutHandlingSuspended::Params> params( |
| 1417 developer::SetShortcutHandlingSuspended::Params::Create(*args_)); | 1417 developer::SetShortcutHandlingSuspended::Params::Create(*args_)); |
| 1418 EXTENSION_FUNCTION_VALIDATE(params); | 1418 EXTENSION_FUNCTION_VALIDATE(params); |
| 1419 ExtensionCommandsGlobalRegistry::Get(GetProfile())-> | 1419 ExtensionCommandsGlobalRegistry::Get(GetProfile())-> |
| 1420 SetShortcutHandlingSuspended(params->is_suspended); | 1420 SetShortcutHandlingSuspended(params->is_suspended); |
| 1421 return RespondNow(NoArguments()); | 1421 return RespondNow(NoArguments()); |
| 1422 } | 1422 } |
| 1423 | 1423 |
| 1424 DeveloperPrivateUpdateExtensionCommandFunction:: | 1424 DeveloperPrivateUpdateExtensionCommandFunction:: |
| 1425 ~DeveloperPrivateUpdateExtensionCommandFunction() {} | 1425 ~DeveloperPrivateUpdateExtensionCommandFunction() {} |
| 1426 | 1426 |
| 1427 ExtensionFunction::ResponseAction | 1427 ExtensionFunction::ResponseAction |
| 1428 DeveloperPrivateUpdateExtensionCommandFunction::Run() { | 1428 DeveloperPrivateUpdateExtensionCommandFunction::Run() { |
| 1429 scoped_ptr<developer::UpdateExtensionCommand::Params> params( | 1429 std::unique_ptr<developer::UpdateExtensionCommand::Params> params( |
| 1430 developer::UpdateExtensionCommand::Params::Create(*args_)); | 1430 developer::UpdateExtensionCommand::Params::Create(*args_)); |
| 1431 EXTENSION_FUNCTION_VALIDATE(params); | 1431 EXTENSION_FUNCTION_VALIDATE(params); |
| 1432 const developer::ExtensionCommandUpdate& update = params->update; | 1432 const developer::ExtensionCommandUpdate& update = params->update; |
| 1433 | 1433 |
| 1434 CommandService* command_service = CommandService::Get(GetProfile()); | 1434 CommandService* command_service = CommandService::Get(GetProfile()); |
| 1435 | 1435 |
| 1436 if (update.scope != developer::COMMAND_SCOPE_NONE) { | 1436 if (update.scope != developer::COMMAND_SCOPE_NONE) { |
| 1437 command_service->SetScope(update.extension_id, update.command_name, | 1437 command_service->SetScope(update.extension_id, update.command_name, |
| 1438 update.scope == developer::COMMAND_SCOPE_GLOBAL); | 1438 update.scope == developer::COMMAND_SCOPE_GLOBAL); |
| 1439 } | 1439 } |
| 1440 | 1440 |
| 1441 if (update.keybinding) { | 1441 if (update.keybinding) { |
| 1442 command_service->UpdateKeybindingPrefs( | 1442 command_service->UpdateKeybindingPrefs( |
| 1443 update.extension_id, update.command_name, *update.keybinding); | 1443 update.extension_id, update.command_name, *update.keybinding); |
| 1444 } | 1444 } |
| 1445 | 1445 |
| 1446 return RespondNow(NoArguments()); | 1446 return RespondNow(NoArguments()); |
| 1447 } | 1447 } |
| 1448 | 1448 |
| 1449 | 1449 |
| 1450 } // namespace api | 1450 } // namespace api |
| 1451 | 1451 |
| 1452 } // namespace extensions | 1452 } // namespace extensions |
| OLD | NEW |