diff options
author | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-23 11:15:36 +0000 |
---|---|---|
committer | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-23 11:15:36 +0000 |
commit | 9b78cfd2818651c50f76990771fdaae1d85c3c3d (patch) | |
tree | 78fb51629371b48675769b535a5e019a06550af7 | |
parent | adf5f63b6300d9336a0b5a7c23634cb36254c5a0 (diff) | |
download | chromium_src-9b78cfd2818651c50f76990771fdaae1d85c3c3d.zip chromium_src-9b78cfd2818651c50f76990771fdaae1d85c3c3d.tar.gz chromium_src-9b78cfd2818651c50f76990771fdaae1d85c3c3d.tar.bz2 |
[cros] Initial CL for SIM card unlock support.
BUG=chromium-os:12007
TEST=Manual. Open chrome:sim-unlock.
Review URL: http://codereview.chromium.org/6708087
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79112 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 40 | ||||
-rw-r--r-- | chrome/browser/browser_resources.grd | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/webui/sim_unlock_ui.cc | 181 | ||||
-rw-r--r-- | chrome/browser/chromeos/webui/sim_unlock_ui.h | 27 | ||||
-rw-r--r-- | chrome/browser/resources/chromeos/sim_unlock.html | 11 | ||||
-rw-r--r-- | chrome/browser/resources/chromeos/sim_unlock.js | 11 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 2 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 2 | ||||
-rw-r--r-- | content/browser/webui/web_ui_factory.cc | 3 |
10 files changed, 280 insertions, 0 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index a50ef36..cb6e00b 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -9803,6 +9803,46 @@ Keep your key file in a safe place. You will need it to create new versions of y Modifier keys... </message> + <message name="IDS_SIM_UNLOCK_ENTER_PIN_TITLE" desc="Title of the SIM card unlock dialog in chrome:sim-unlock."> + Enter SIM card PIN + </message> + <message name="IDS_SIM_UNLOCK_INCORRECT_PIN_MESSAGE" desc="Incorrect PIN message shown on SIM card unlock dialog in chrome:sim-unlock."> + Incorrect PIN. + </message> + <message name="IDS_SIM_UNLOCK_PIN_TRIES_LEFT_MESSAGE" desc="Message with the number of PIN tries left shown on SIM card unlock dialog in chrome:sim-unlock."> + Tries left to enter the correct SIM card PIN: <ph name="TRIES_LEFT">$1<ex>3</ex></ph>. + </message> + <message name="IDS_SIM_UNLOCK_INCORRECT_PIN_TITLE" desc="Title of the Incorrect PIN stage (no tries left) shown on SIM card unlock dialog in chrome:sim-unlock."> + Incorrect PIN + </message> + <message name="IDS_SIM_UNLOCK_NO_PIN_TRIES_LEFT_MESSAGE" desc="Message shown when there's no PIN tries left, shown on SIM card unlock dialog in chrome:sim-unlock."> + You have entered the incorrect PIN too many times. Please contact <ph name="CARRIER_ID">$1<ex>your carrier</ex></ph> to obtain a new 8-digit PIN unlocking Key (PUK). + </message> + <message name="IDS_SIM_UNLOCK_DEFAULT_CARRIER" desc="Generic carrier name shown on SIM unlock dialog. Ex.: IDS_SIM_UNLOCK_NO_PIN_TRIES_LEFT_MESSAGE, IDS_SIM_UNLOCK_ENTER_PUK_MESSAGE"> + your carrier + </message> + <message name="IDS_SIM_UNLOCK_ENTER_PUK_BUTTON" desc="Text of the button that will take to Enter PUK dialog, part of SIM card unlock dialog in chrome:sim-unlock."> + Enter PIN Unlocking Key + </message> + <message name="IDS_SIM_UNLOCK_ENTER_PUK_TITLE" desc="Title of the Enter PUK dialog, which is part of SIM card unlock dialog in chrome:sim-unlock."> + Enter PIN Unlocking Key + </message> + <message name="IDS_SIM_UNLOCK_PUK_TRIES_LEFT_MESSAGE" desc="Message with the number of PUK tries left shown on SIM card unlock dialog in chrome:sim-unlock."> + Tries left to enter the correct PIN Unlocking Key (PUK): <ph name="TRIES_LEFT">$1<ex>3</ex></ph>, or your SIM card will be permanently blocked. + </message> + <message name="IDS_SIM_UNLOCK_ENTER_PUK_MESSAGE" desc="Message on the Enter PUK dialog, which is part of SIM card unlock dialog in chrome:sim-unlock."> + Please enter the 8-digit PIN Unlocking Key provided by <ph name="CARRIER_ID">$1<ex>your carrier</ex></ph>. + </message> + <message name="IDS_SIM_UNLOCK_NO_PUK_TRIES_LEFT_MESSAGE" desc="Message shown when there're not PUK tries left, right after last try was used and SIM card is now blocked."> + You have entered the incorrect PIN Unlocking Key too many times. Your SIM card is permanently blocked. + </message> + <message name="IDS_SIM_UNLOCK_SIM_BLOCKED_TITLE" desc="Title shown when there're not PUK tries left and SIM card is blocked."> + SIM Card Blocked. + </message> + <message name="IDS_SIM_UNLOCK_SIM_BLOCKED_MESSAGE" desc="Message shown when there're not PUK tries left and SIM card is blocked."> + This SIM card is blocked and cannot be used. Please insert a different SIM card. + </message> + <message name="IDS_EULA_BACK_BUTTON" desc="Back button shown on EULA screen."> « Back </message> diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index d4be682..b2fee28 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -109,6 +109,7 @@ without changes to the corresponding grd file. etaa --> <include name="IDR_OS_CREDITS_HTML" file="resources\about_os_credits.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_PROXY_SETTINGS_HTML" file="resources\chromeos\proxy_settings.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_SLIDESHOW_HTML" file="resources\slideshow.html" flattenhtml="true" type="BINDATA" /> + <include name="IDR_SIM_UNLOCK_HTML" file="resources\chromeos\sim_unlock.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_MENU_HTML" file="resources\menu.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_NETWORK_MENU_CSS" file="resources\network_menu.css" flattenhtml="true" type="BINDATA" /> <include name="IDR_NETWORK_MENU_JS" file="resources\network_menu.js" flattenhtml="true" type="BINDATA" /> diff --git a/chrome/browser/chromeos/webui/sim_unlock_ui.cc b/chrome/browser/chromeos/webui/sim_unlock_ui.cc new file mode 100644 index 0000000..e9f13818 --- /dev/null +++ b/chrome/browser/chromeos/webui/sim_unlock_ui.cc @@ -0,0 +1,181 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/webui/sim_unlock_ui.h" + +#include <string> + +#include "base/string_piece.h" +#include "base/values.h" +#include "base/weak_ptr.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/webui/chrome_url_data_manager.h" +#include "chrome/common/jstemplate_builder.h" +#include "chrome/common/url_constants.h" +#include "content/browser/tab_contents/tab_contents.h" +#include "grit/browser_resources.h" +#include "grit/generated_resources.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" + +namespace { + +// Host page JS API function names. +const char kJsApiEnterPinCode[] = "enterPinCode"; +const char kJsApiEnterPukCode[] = "enterPukCode"; + +} // namespace + +namespace chromeos { + +class SimUnlockUIHTMLSource : public ChromeURLDataManager::DataSource { + public: + SimUnlockUIHTMLSource(); + + // Called when the network layer has requested a resource underneath + // the path we registered. + virtual void StartDataRequest(const std::string& path, + bool is_incognito, + int request_id); + virtual std::string GetMimeType(const std::string&) const { + return "text/html"; + } + + private: + virtual ~SimUnlockUIHTMLSource() {} + + std::string service_path_; + DISALLOW_COPY_AND_ASSIGN(SimUnlockUIHTMLSource); +}; + +// The handler for Javascript messages related to the "sim-unlock" view. +class SimUnlockHandler : public WebUIMessageHandler, + public base::SupportsWeakPtr<SimUnlockHandler> { + public: + SimUnlockHandler(); + virtual ~SimUnlockHandler(); + + // Init work after Attach. + void Init(TabContents* contents); + + // WebUIMessageHandler implementation. + virtual WebUIMessageHandler* Attach(WebUI* web_ui); + virtual void RegisterMessages(); + + private: + // Handlers for JS WebUI messages. + void HandleEnterPinCode(const ListValue* args); + void HandleEnterPukCode(const ListValue* args); + + TabContents* tab_contents_; + + DISALLOW_COPY_AND_ASSIGN(SimUnlockHandler); +}; + +// SimUnlockUIHTMLSource ------------------------------------------------------- + +SimUnlockUIHTMLSource::SimUnlockUIHTMLSource() + : DataSource(chrome::kChromeUISimUnlockHost, MessageLoop::current()) { +} + +void SimUnlockUIHTMLSource::StartDataRequest(const std::string& path, + bool is_incognito, + int request_id) { + DictionaryValue strings; + strings.SetString("title", + l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_ENTER_PIN_TITLE)); + strings.SetString("enterPinTitle", + l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_ENTER_PIN_TITLE)); + strings.SetString("incorrectPinMessage", + l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_INCORRECT_PIN_MESSAGE)); + // TODO(nkostylev): Initialize string with number of PIN tries left. + strings.SetString("pinTriesLeft", + l10n_util::GetStringFUTF16(IDS_SIM_UNLOCK_PIN_TRIES_LEFT_MESSAGE, + string16())); + strings.SetString("incorrectPinTitle", + l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_INCORRECT_PIN_TITLE)); + // TODO(nkostylev): Pass carrier name if we know that. + strings.SetString("noPinTriesLeft", l10n_util::GetStringFUTF16( + IDS_SIM_UNLOCK_NO_PIN_TRIES_LEFT_MESSAGE, + l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_DEFAULT_CARRIER))); + strings.SetString("enterPukButton", + l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_ENTER_PUK_BUTTON)); + strings.SetString("enterPukTitle", + l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_ENTER_PUK_TITLE)); + // TODO(nkostylev): Initialize string with number of PIN tries left. + strings.SetString("pukTriesLeft", + l10n_util::GetStringFUTF16(IDS_SIM_UNLOCK_PUK_TRIES_LEFT_MESSAGE, + string16())); + // TODO(nkostylev): Pass carrier name if we know that. + strings.SetString("enterPukMessage", l10n_util::GetStringFUTF16( + IDS_SIM_UNLOCK_ENTER_PUK_MESSAGE, + l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_DEFAULT_CARRIER))); + strings.SetString("noPukTriesLeft", + l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_NO_PUK_TRIES_LEFT_MESSAGE)); + strings.SetString("simBlockedTitle", + l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_SIM_BLOCKED_TITLE)); + strings.SetString("simBlockedMessage", + l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_SIM_BLOCKED_MESSAGE)); + SetFontAndTextDirection(&strings); + + static const base::StringPiece html( + ResourceBundle::GetSharedInstance().GetRawDataResource( + IDR_SIM_UNLOCK_HTML)); + + const std::string& full_html = jstemplate_builder::GetI18nTemplateHtml( + html, &strings); + + scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes()); + html_bytes->data.resize(full_html.size()); + std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); + + SendResponse(request_id, html_bytes); +} + +// SimUnlockHandler ------------------------------------------------------------ + +SimUnlockHandler::SimUnlockHandler() + : tab_contents_(NULL) { +} + +SimUnlockHandler::~SimUnlockHandler() { +} + +WebUIMessageHandler* SimUnlockHandler::Attach(WebUI* web_ui) { + return WebUIMessageHandler::Attach(web_ui); +} + +void SimUnlockHandler::Init(TabContents* contents) { + tab_contents_ = contents; + // TODO(nkostylev): Init SIM lock/unlock state. +} + +void SimUnlockHandler::RegisterMessages() { + web_ui_->RegisterMessageCallback(kJsApiEnterPinCode, + NewCallback(this, &SimUnlockHandler::HandleEnterPinCode)); + web_ui_->RegisterMessageCallback(kJsApiEnterPukCode, + NewCallback(this, &SimUnlockHandler::HandleEnterPukCode)); +} + +void SimUnlockHandler::HandleEnterPinCode(const ListValue* args) { + // TODO(nkostylev): Pass PIN code to flimflam. +} + +void SimUnlockHandler::HandleEnterPukCode(const ListValue* args) { + // TODO(nkostylev): Pass PUK code to flimflam. +} + +// SimUnlockUI ----------------------------------------------------------------- + +SimUnlockUI::SimUnlockUI(TabContents* contents) : WebUI(contents) { + SimUnlockHandler* handler = new SimUnlockHandler(); + AddMessageHandler((handler)->Attach(this)); + handler->Init(contents); + SimUnlockUIHTMLSource* html_source = new SimUnlockUIHTMLSource(); + + // Set up the chrome://sim-unlock/ source. + contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/sim_unlock_ui.h b/chrome/browser/chromeos/webui/sim_unlock_ui.h new file mode 100644 index 0000000..4f39ad5 --- /dev/null +++ b/chrome/browser/chromeos/webui/sim_unlock_ui.h @@ -0,0 +1,27 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_SIM_UNLOCK_UI_H_ +#define CHROME_BROWSER_CHROMEOS_WEBUI_SIM_UNLOCK_UI_H_ +#pragma once + +#include "content/browser/webui/web_ui.h" + +namespace chromeos { + +// A custom WebUI that defines datasource for SIM unlock dialog that is used +// in Chrome OS for specific tasks: +// - Unlock SIM card (enter PIN/PUK codes). +// - Display "SIM card is blocked" message when there're no PUK tries left. +class SimUnlockUI : public WebUI { + public: + explicit SimUnlockUI(TabContents* contents); + + private: + DISALLOW_COPY_AND_ASSIGN(SimUnlockUI); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_WEBUI_SIM_UNLOCK_UI_H_ diff --git a/chrome/browser/resources/chromeos/sim_unlock.html b/chrome/browser/resources/chromeos/sim_unlock.html new file mode 100644 index 0000000..a7c214e4 --- /dev/null +++ b/chrome/browser/resources/chromeos/sim_unlock.html @@ -0,0 +1,11 @@ +<!DOCTYPE HTML> +<html i18n-values="dir:textdirection"> +<head> +<title i18n-content="title"></title> +<script src="chrome://resources/js/cr/event_target.js"></script> +<script src="chrome://resources/js/util.js"></script> +<script src="sim_unlock.js"></script> +</head> +<body i18n-values=".style.fontFamily:fontfamily;"> +</body> +</html> diff --git a/chrome/browser/resources/chromeos/sim_unlock.js b/chrome/browser/resources/chromeos/sim_unlock.js new file mode 100644 index 0000000..e80fe8d --- /dev/null +++ b/chrome/browser/resources/chromeos/sim_unlock.js @@ -0,0 +1,11 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/** + * DOMContentLoaded handler, initializes the page. + */ +function load() { +} + +document.addEventListener('DOMContentLoaded', load); diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 36d8801..c2b77ec 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -722,6 +722,8 @@ 'browser/chromeos/webui/proxy_settings_ui.h', 'browser/chromeos/webui/register_page_ui.cc', 'browser/chromeos/webui/register_page_ui.h', + 'browser/chromeos/webui/sim_unlock_ui.cc', + 'browser/chromeos/webui/sim_unlock_ui.h', 'browser/chromeos/webui/stats_options_handler.cc', 'browser/chromeos/webui/stats_options_handler.h', 'browser/chromeos/webui/system_info_ui.cc', diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index e666a09..07929da 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -109,6 +109,7 @@ const char kChromeUIMobileSetupURL[] = "chrome://mobilesetup/"; const char kChromeUIProxySettingsURL[] = "chrome://proxy-settings/"; const char kChromeUIRegisterPageURL[] = "chrome://register/"; const char kChromeUISlideshowURL[] = "chrome://slideshow/"; +const char kChromeUISimUnlockURL[] = "chrome://sim-unlock/"; const char kChromeUISystemInfoURL[] = "chrome://system/"; const char kChromeUIUserImageURL[] = "chrome://userimage/"; #endif @@ -156,6 +157,7 @@ const char kChromeUIMobileSetupHost[] = "mobilesetup"; const char kChromeUIProxySettingsHost[] = "proxy-settings"; const char kChromeUIRegisterPageHost[] = "register"; const char kChromeUISlideshowHost[] = "slideshow"; +const char kChromeUISimUnlockHost[] = "sim-unlock"; const char kChromeUISystemInfoHost[] = "system"; const char kChromeUIMenu[] = "menu"; const char kChromeUIWrenchMenu[] = "wrench-menu"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index 6d9720b..3415bce 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -101,6 +101,7 @@ extern const char kChromeUIMobileSetupURL[]; extern const char kChromeUIProxySettingsURL[]; extern const char kChromeUIRegisterPageURL[]; extern const char kChromeUISlideshowURL[]; +extern const char kChromeUISimUnlockURL[]; extern const char kChromeUISystemInfoURL[]; extern const char kChromeUIUserImageURL[]; #endif @@ -148,6 +149,7 @@ extern const char kChromeUIMobileSetupHost[]; extern const char kChromeUIProxySettingsHost[]; extern const char kChromeUIRegisterPageHost[]; extern const char kChromeUISlideshowHost[]; +extern const char kChromeUISimUnlockHost[]; extern const char kChromeUISystemInfoHost[]; extern const char kChromeUIMenu[]; extern const char kChromeUIWrenchMenu[]; diff --git a/content/browser/webui/web_ui_factory.cc b/content/browser/webui/web_ui_factory.cc index 79aed0b..ab627ff1 100644 --- a/content/browser/webui/web_ui_factory.cc +++ b/content/browser/webui/web_ui_factory.cc @@ -42,6 +42,7 @@ #include "chrome/browser/chromeos/webui/mobile_setup_ui.h" #include "chrome/browser/chromeos/webui/proxy_settings_ui.h" #include "chrome/browser/chromeos/webui/register_page_ui.h" +#include "chrome/browser/chromeos/webui/sim_unlock_ui.h" #include "chrome/browser/chromeos/webui/system_info_ui.h" #include "chrome/browser/ui/webui/filebrowse_ui.h" #include "chrome/browser/ui/webui/mediaplayer_ui.h" @@ -197,6 +198,8 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile, return &NewWebUI<OptionsUI>; if (url.host() == chrome::kChromeUISlideshowHost) return &NewWebUI<SlideshowUI>; + if (url.host() == chrome::kChromeUISimUnlockHost) + return &NewWebUI<chromeos::SimUnlockUI>; if (url.host() == chrome::kChromeUISystemInfoHost) return &NewWebUI<SystemInfoUI>; #else |