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

Unified Diff: chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc

Issue 562393002: Remove unused chrome.screenlockPrivate methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc
diff --git a/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc b/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc
index f5e44b2e5eec456ea09d9fd3e688650dfe600a0e..b319b6aa8c432ae132bdefe2c8f84de03d2d2209 100644
--- a/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc
+++ b/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc
@@ -4,16 +4,11 @@
#include "chrome/browser/extensions/api/screenlock_private/screenlock_private_api.h"
-#include <vector>
-
#include "base/lazy_instance.h"
-#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/screenlock_private.h"
#include "extensions/browser/event_router.h"
-#include "extensions/browser/image_loader.h"
-#include "ui/gfx/image/image.h"
namespace screenlock = extensions::api::screenlock_private;
@@ -22,23 +17,6 @@ namespace extensions {
namespace {
const char kNotLockedError[] = "Screen is not currently locked.";
-const char kInvalidIconError[] = "Invalid custom icon data.";
-
-ScreenlockBridge::LockHandler::AuthType ToLockHandlerAuthType(
- screenlock::AuthType auth_type) {
- switch (auth_type) {
- case screenlock::AUTH_TYPE_OFFLINEPASSWORD:
- return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD;
- case screenlock::AUTH_TYPE_NUMERICPIN:
- return ScreenlockBridge::LockHandler::NUMERIC_PIN;
- case screenlock::AUTH_TYPE_USERCLICK:
- return ScreenlockBridge::LockHandler::USER_CLICK;
- case screenlock::AUTH_TYPE_NONE:
- break;
- }
- NOTREACHED();
- return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD;
-}
screenlock::AuthType FromLockHandlerAuthType(
ScreenlockBridge::LockHandler::AuthType auth_type) {
@@ -92,165 +70,6 @@ bool ScreenlockPrivateSetLockedFunction::RunAsync() {
return true;
}
-ScreenlockPrivateShowMessageFunction::ScreenlockPrivateShowMessageFunction() {}
-
-ScreenlockPrivateShowMessageFunction::~ScreenlockPrivateShowMessageFunction() {}
-
-bool ScreenlockPrivateShowMessageFunction::RunAsync() {
- scoped_ptr<screenlock::ShowMessage::Params> params(
- screenlock::ShowMessage::Params::Create(*args_));
- EXTENSION_FUNCTION_VALIDATE(params.get());
- ScreenlockBridge::LockHandler* locker =
- ScreenlockBridge::Get()->lock_handler();
- if (locker)
- locker->ShowBannerMessage(base::UTF8ToUTF16(params->message));
- SendResponse(error_.empty());
- return true;
-}
-
-ScreenlockPrivateShowCustomIconFunction::
- ScreenlockPrivateShowCustomIconFunction() {}
-
-ScreenlockPrivateShowCustomIconFunction::
- ~ScreenlockPrivateShowCustomIconFunction() {}
-
-bool ScreenlockPrivateShowCustomIconFunction::RunAsync() {
- scoped_ptr<screenlock::ShowCustomIcon::Params> params(
- screenlock::ShowCustomIcon::Params::Create(*args_));
- EXTENSION_FUNCTION_VALIDATE(params.get());
- ScreenlockBridge::LockHandler* locker =
- ScreenlockBridge::Get()->lock_handler();
- if (!locker) {
- SetError(kNotLockedError);
- return false;
- }
-
- const int kMaxButtonIconSize = 40;
- bool has_scale_100P = false;
- std::vector<extensions::ImageLoader::ImageRepresentation> icon_info;
- for (size_t i = 0; i < params->icon.size(); ++i) {
- ui::ScaleFactor scale_factor;
- if (params->icon[i]->scale_factor == 1.) {
- scale_factor = ui::SCALE_FACTOR_100P;
- } else if (params->icon[i]->scale_factor == 2.) {
- scale_factor = ui::SCALE_FACTOR_200P;
- } else {
- continue;
- }
-
- ExtensionResource resource = extension()->GetResource(params->icon[i]->url);
- if (resource.empty())
- continue;
-
- icon_info.push_back(
- ImageLoader::ImageRepresentation(
- resource,
- ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER,
- gfx::Size(kMaxButtonIconSize * params->icon[i]->scale_factor,
- kMaxButtonIconSize * params->icon[i]->scale_factor),
- scale_factor));
- if (scale_factor == ui::SCALE_FACTOR_100P)
- has_scale_100P = true;
- }
-
- if (!has_scale_100P) {
- SetError(kInvalidIconError);
- return false;
- }
-
- extensions::ImageLoader* loader = extensions::ImageLoader::Get(GetProfile());
- loader->LoadImagesAsync(
- extension(),
- icon_info,
- base::Bind(&ScreenlockPrivateShowCustomIconFunction::OnImageLoaded,
- this));
- return true;
-}
-
-void ScreenlockPrivateShowCustomIconFunction::OnImageLoaded(
- const gfx::Image& image) {
- ScreenlockBridge::LockHandler* locker =
- ScreenlockBridge::Get()->lock_handler();
- if (!locker) {
- SetError(kNotLockedError);
- SendResponse(false);
- return;
- }
-
- ScreenlockBridge::UserPodCustomIconOptions icon;
- icon.SetIconAsImage(image);
- locker->ShowUserPodCustomIcon(
- ScreenlockBridge::GetAuthenticatedUserEmail(GetProfile()),
- icon);
- SendResponse(error_.empty());
-}
-
-ScreenlockPrivateHideCustomIconFunction::
- ScreenlockPrivateHideCustomIconFunction() {
-}
-
-ScreenlockPrivateHideCustomIconFunction::
- ~ScreenlockPrivateHideCustomIconFunction() {
-}
-
-bool ScreenlockPrivateHideCustomIconFunction::RunAsync() {
- ScreenlockBridge::LockHandler* locker =
- ScreenlockBridge::Get()->lock_handler();
- if (locker) {
- locker->HideUserPodCustomIcon(
- ScreenlockBridge::GetAuthenticatedUserEmail(GetProfile()));
- } else {
- SetError(kNotLockedError);
- }
- SendResponse(error_.empty());
- return true;
-}
-
-ScreenlockPrivateSetAuthTypeFunction::ScreenlockPrivateSetAuthTypeFunction() {}
-
-ScreenlockPrivateSetAuthTypeFunction::~ScreenlockPrivateSetAuthTypeFunction() {}
-
-bool ScreenlockPrivateSetAuthTypeFunction::RunAsync() {
- scoped_ptr<screenlock::SetAuthType::Params> params(
- screenlock::SetAuthType::Params::Create(*args_));
- EXTENSION_FUNCTION_VALIDATE(params.get());
-
- ScreenlockBridge::LockHandler* locker =
- ScreenlockBridge::Get()->lock_handler();
- if (locker) {
- std::string initial_value =
- params->initial_value.get() ? *(params->initial_value.get()) : "";
- locker->SetAuthType(
- ScreenlockBridge::GetAuthenticatedUserEmail(GetProfile()),
- ToLockHandlerAuthType(params->auth_type),
- base::UTF8ToUTF16(initial_value));
- } else {
- SetError(kNotLockedError);
- }
- SendResponse(error_.empty());
- return true;
-}
-
-ScreenlockPrivateGetAuthTypeFunction::ScreenlockPrivateGetAuthTypeFunction() {}
-
-ScreenlockPrivateGetAuthTypeFunction::~ScreenlockPrivateGetAuthTypeFunction() {}
-
-bool ScreenlockPrivateGetAuthTypeFunction::RunAsync() {
- ScreenlockBridge::LockHandler* locker =
- ScreenlockBridge::Get()->lock_handler();
- if (locker) {
- ScreenlockBridge::LockHandler::AuthType auth_type = locker->GetAuthType(
- ScreenlockBridge::GetAuthenticatedUserEmail(GetProfile()));
- std::string auth_type_name =
- screenlock::ToString(FromLockHandlerAuthType(auth_type));
- SetResult(new base::StringValue(auth_type_name));
- } else {
- SetError(kNotLockedError);
- }
- SendResponse(error_.empty());
- return true;
-}
-
ScreenlockPrivateAcceptAuthAttemptFunction::
ScreenlockPrivateAcceptAuthAttemptFunction() {}

Powered by Google App Engine
This is Rietveld 408576698