diff options
author | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-12 06:29:37 +0000 |
---|---|---|
committer | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-12 06:29:37 +0000 |
commit | dee9b1db807ffc75de7f6071ad6c622e843a54a9 (patch) | |
tree | da25daae2f18b93354abfab7d2fa2b2a853cf98b | |
parent | eabbe2787e330720bd547f11183b3cf689f6a87d (diff) | |
download | chromium_src-dee9b1db807ffc75de7f6071ad6c622e843a54a9.zip chromium_src-dee9b1db807ffc75de7f6071ad6c622e843a54a9.tar.gz chromium_src-dee9b1db807ffc75de7f6071ad6c622e843a54a9.tar.bz2 |
[cros] Adding mobile connection "security" tab (change RequirePin pref/change PIN, GSM only).
Hide "Plan" tab for GSM networks.
Ask user to Enter PIN when changing RequirePin pref (reusing SIM unlock dialog).
Add strings for 3G data notification.
BUG=chromium-os:12007
TEST=manual
Review URL: http://codereview.chromium.org/6693065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81222 0039d316-1c4b-4281-b951-d872f2087c98
13 files changed, 380 insertions, 41 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index da87ecb..f7b7a39 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -4345,24 +4345,28 @@ Keep your key file in a safe place. You will need it to create new versions of y You have DNS certificate provenance checking enabled. This may result in private information being sent to Google. </message> - <!-- Locale Change Notification--> <if expr="pp_ifdef('chromeos')"> + <!-- Locale Change Notification--> <message name="IDS_LOCALE_CHANGE_MESSAGE" desc="Message shown when locale was changed based on profile content."> Chrome's language has changed from "<ph name="FROM_LOCALE">$1<ex>Italian</ex></ph>" to "<ph name="TO_LOCALE">$2<ex>English (United States)</ex></ph>" after syncing your settings. </message> <message name="IDS_LOCALE_CHANGE_REVERT_MESSAGE" desc="Link to revert a change."> Change back to "<ph name="FROM_LOCALE">$1<ex>Italian</ex></ph>" (requires restart) </message> - </if> - <!-- SMS Notifications --> - <if expr="pp_ifdef('chromeos')"> + <!-- SMS Notifications --> <message name="IDS_SMS_NOTIFICATION_TITLE" desc="Title of SMS message notification."> SMS from <ph name="PHONE_NUMBER">$1<ex>08700 776655</ex></ph> </message> - </if> - <if expr="pp_ifdef('chromeos')"> + <!-- 3G data Notifications --> + <message name="IDS_3G_FREE_DATA_NOTIFICATION_TITLE" desc="Title of 3G data notification telling user that she has x free data."> + You have <ph name="DATE">$1<ex>3GB</ex></ph> of free data, courtesy of <ph name="DATE">$1<ex>Vodafone</ex></ph> + </message> + <message name="IDS_3G_NOTIFICATION_MESSAGE" desc="Text of the 3G data notification telling that 3G data is enabled."> + Chrome will use 3G data when no WiFi connection is present. + </message> + <!-- about:system strings --> <message name="IDS_ABOUT_SYS_TITLE" desc="about:system page title"> About System @@ -9794,7 +9798,7 @@ Keep your key file in a safe place. You will need it to create new versions of y Join wifi network </message> <message name="IDS_OPTIONS_SETTINGS_ENABLE_DATA_ROAMING" desc="In the settings tab, the text next to the checkbox for data roaming."> - Enable data roaming + Allow mobile data roaming </message> <message name="IDS_OPTIONS_ACCOUNTS_ALLOW_BWSI_DESCRIPTION" desc="In the Accounts settings tab, the text on the checkbox to allow browse without signing in."> Enable guest browsing @@ -9859,6 +9863,9 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_OPTIONS_SETTINGS_INTERNET_TAB_NETWORK" desc="In settings Internet options, the title for buy cellular data plan button."> Network </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_TAB_SECURITY" desc="In settings Internet options, the title for security tab."> + Security + </message> <message name="IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_ID" desc="In settings Internet options, the label for the network id."> SSID: </message> @@ -10119,6 +10126,33 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_SET" desc="Cellular device set APN settings button under network details in chrome:settings/internet."> Save </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_ACCESS_SECURITY_TAB" desc="In settings Internet options, the text of the link shown when SIM card is locked, to access security tab."> + To access Security settings enter the SIM card PIN + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_LOCK_SIM_CARD" desc="Cellular device enable SIM card PIN lock checkbox label in chrome:settings/internet."> + Lock SIM card (require PIN to use mobile data) + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_BUTTON" desc="Cellular device change PIN button text in chrome:settings/internet."> + Change PIN + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_TITLE" desc="Cellular device change PIN dialog title in chrome:settings/internet."> + Change SIM Card PIN + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_MESSAGE" desc="Cellular device change PIN dialog message in chrome:settings/internet."> + Please enter old and new PIN. + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_INCORRECT_ERROR" desc="Cellular device change PIN dialog error message in chrome:settings/internet."> + Incorrect PIN, please try again. + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_OLD_PIN" desc="Cellular device change PIN dialog old PIN label text in chrome:settings/internet."> + Old PIN: + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_NEW_PIN" desc="Cellular device change PIN dialog new PIN label text in chrome:settings/internet."> + New PIN: + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_RETYPE_PIN" desc="Cellular device change PIN dialog re-type new PIN label text in chrome:settings/internet."> + Re-type new PIN: + </message> <message name="IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_CANCEL" desc="Cellular device cancel APN settings edit button under network details in chrome:settings/internet."> Cancel </message> @@ -10137,7 +10171,7 @@ Keep your key file in a safe place. You will need it to create new versions of y </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 + Enter SIM Card PIN </message> <message name="IDS_SIM_UNLOCK_ENTER_PIN_MESSAGE" desc="Message on the the SIM card unlock dialog asking to enter PIN in chrome:sim-unlock."> SIM card is locked, please enter PIN. @@ -10164,7 +10198,7 @@ Keep your key file in a safe place. You will need it to create new versions of y Enter PIN Unlocking Key </message> <message name="IDS_SIM_UNLOCK_ENTER_PUK_WARNING" desc="Warning on the Enter PUK dialog with the number of tries left, which is part of SIM card unlock dialog in chrome:sim-unlock."> - If you enter ther incorrect PIN Unlocking Key your SIM card will be permanently disabled. Tries left: <ph name="TRIES_COUNT">$1<ex>42</ex></ph> + Your SIM card will be permanently disabled if you cannot enter the correct PIN Unlocking Key. Tries left: <ph name="TRIES_COUNT">$1<ex>42</ex></ph> </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>. diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc index 69d9d35..65d6df1 100644 --- a/chrome/browser/chromeos/cros/network_library.cc +++ b/chrome/browser/chromeos/cros/network_library.cc @@ -3197,6 +3197,14 @@ class NetworkLibraryImpl : public NetworkLibrary { AddNetwork(cellular1); active_cellular_ = cellular1; + CellularNetwork* cellular2 = new CellularNetwork("fc2"); + cellular2->set_name("Fake Cellular 2"); + cellular2->set_strength(70); + cellular2->set_connected(true); + cellular2->set_activation_state(ACTIVATION_STATE_ACTIVATED); + cellular2->set_network_technology(NETWORK_TECHNOLOGY_UMTS); + AddNetwork(cellular2); + // Remembered Networks ClearRememberedNetworks(true /*delete networks*/); WifiNetwork* remembered_wifi2 = new WifiNetwork("fw2"); diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h index f550fde..6420686 100644 --- a/chrome/browser/chromeos/cros/network_library.h +++ b/chrome/browser/chromeos/cros/network_library.h @@ -308,6 +308,7 @@ class Network { ConnectionType type_; friend class NetworkLibraryImpl; + friend class NetworkLibraryStubImpl; // ChangeAutoConnectSaveTest accesses |favorite_|. FRIEND_TEST_ALL_PREFIXES(WifiConfigViewTest, ChangeAutoConnectSaveTest); }; @@ -347,6 +348,7 @@ class WirelessNetwork : public Network { void set_strength(int strength) { strength_ = strength; } friend class NetworkLibraryImpl; + friend class NetworkLibraryStubImpl; }; // Class for networks of TYPE_CELLULAR. @@ -468,6 +470,7 @@ class CellularNetwork : public WirelessNetwork { void set_last_good_apn(const Apn& apn) { last_good_apn_ = apn; } friend class NetworkLibraryImpl; + friend class NetworkLibraryStubImpl; }; typedef std::vector<CellularNetwork*> CellularNetworkVector; diff --git a/chrome/browser/chromeos/sim_unlock_dialog_delegate.cc b/chrome/browser/chromeos/sim_unlock_dialog_delegate.cc index a003f9f..ba85c8d 100644 --- a/chrome/browser/chromeos/sim_unlock_dialog_delegate.cc +++ b/chrome/browser/chromeos/sim_unlock_dialog_delegate.cc @@ -4,6 +4,7 @@ #include "chrome/browser/chromeos/sim_unlock_dialog_delegate.h" +#include "base/stringprintf.h" #include "chrome/browser/chromeos/frame/bubble_window.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" @@ -16,6 +17,11 @@ namespace { const int kDefaultWidth = 350; const int kDefaultHeight = 225; +// URL that includes new value for the RequirePin SIM preference. +// In general SIM unlock case sim-unlock URL is loaded w/o params. +const char kSimUnlockRequirePinPrefURL[] = + "chrome://sim-unlock/?pin-req=%s"; + // Custom HtmlDialogView with disabled context menu. class HtmlDialogWithoutContextMenuView : public HtmlDialogView { public: @@ -36,9 +42,22 @@ namespace chromeos { // static void SimUnlockDialogDelegate::ShowDialog(gfx::NativeWindow owning_window) { + SimUnlockDialogDelegate::ShowDialog(owning_window, NOT_CHANGED); +} + +// static +void SimUnlockDialogDelegate::ShowDialog(gfx::NativeWindow owning_window, + bool require_pin) { + SimUnlockDialogDelegate::ShowDialog( + owning_window, require_pin ? PIN_REQUIRED : PIN_NOT_REQUIRED); +} + +// static +void SimUnlockDialogDelegate::ShowDialog(gfx::NativeWindow owning_window, + SimRequirePin require_pin) { Browser* browser = BrowserList::GetLastActive(); HtmlDialogView* html_view = new HtmlDialogWithoutContextMenuView( - browser->profile(), new SimUnlockDialogDelegate()); + browser->profile(), new SimUnlockDialogDelegate(require_pin)); html_view->InitDialog(); chromeos::BubbleWindow::Create(owning_window, gfx::Rect(), @@ -47,7 +66,12 @@ void SimUnlockDialogDelegate::ShowDialog(gfx::NativeWindow owning_window) { html_view->window()->Show(); } -SimUnlockDialogDelegate::SimUnlockDialogDelegate() { +SimUnlockDialogDelegate::SimUnlockDialogDelegate() + : require_pin_(NOT_CHANGED) { +} + +SimUnlockDialogDelegate::SimUnlockDialogDelegate(SimRequirePin require_pin) + : require_pin_(require_pin) { } SimUnlockDialogDelegate::~SimUnlockDialogDelegate() { @@ -62,8 +86,13 @@ std::wstring SimUnlockDialogDelegate::GetDialogTitle() const { } GURL SimUnlockDialogDelegate::GetDialogContentURL() const { - std::string url_string(chrome::kChromeUISimUnlockURL); - return GURL(url_string); + if (require_pin_ == NOT_CHANGED) { + std::string url_string(chrome::kChromeUISimUnlockURL); + return GURL(url_string); + } else { + std::string value(require_pin_ == PIN_REQUIRED ? "true" : "false"); + return GURL(StringPrintf(kSimUnlockRequirePinPrefURL, value.c_str())); + } } void SimUnlockDialogDelegate::GetWebUIMessageHandlers( diff --git a/chrome/browser/chromeos/sim_unlock_dialog_delegate.h b/chrome/browser/chromeos/sim_unlock_dialog_delegate.h index 10e225a..62f21c7 100644 --- a/chrome/browser/chromeos/sim_unlock_dialog_delegate.h +++ b/chrome/browser/chromeos/sim_unlock_dialog_delegate.h @@ -13,14 +13,34 @@ namespace chromeos { // SIM unlock dialog displayed in cases when SIM card has to be unlocked. class SimUnlockDialogDelegate : public HtmlDialogUIDelegate { public: + // NOT_CHANGED is used as an indication that SIM RequirePin setting + // was not requested to be changed. In that case normal SIM unlock flow is + // executed i.e. entered PIN is used to call EnterPin command. + // Otherwise, each time user enters PIN, RequirePin command is used and + // new value of RequirePin setting is passed with the PIN just entered. + typedef enum SimRequirePin { + NOT_CHANGED, + PIN_NOT_REQUIRED, + PIN_REQUIRED, + } SimRequirePin; + SimUnlockDialogDelegate(); + explicit SimUnlockDialogDelegate(SimRequirePin require_pin); - // Shows the keyboard overlay dialog box. + // Shows the SIM unlock dialog box. static void ShowDialog(gfx::NativeWindow owning_window); + // Shows the SIM unlock dialog box and once user enters PIN, + // passes that with new setting for RequirePin SIM preference. + static void ShowDialog(gfx::NativeWindow owning_window, bool require_pin); + private: ~SimUnlockDialogDelegate(); + // Internal implementation that launches SIM unlock dialog. + static void ShowDialog(gfx::NativeWindow owning_window, + SimRequirePin require_pin); + // Overridden from HtmlDialogUI::Delegate: virtual bool IsDialogModal() const; virtual std::wstring GetDialogTitle() const; @@ -33,6 +53,8 @@ class SimUnlockDialogDelegate : public HtmlDialogUIDelegate { virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); virtual bool ShouldShowDialogTitle() const; + SimRequirePin require_pin_; + DISALLOW_COPY_AND_ASSIGN(SimUnlockDialogDelegate); }; diff --git a/chrome/browser/resources/chromeos/sim_unlock.js b/chrome/browser/resources/chromeos/sim_unlock.js index da258fb..dc44a78 100644 --- a/chrome/browser/resources/chromeos/sim_unlock.js +++ b/chrome/browser/resources/chromeos/sim_unlock.js @@ -11,11 +11,12 @@ cr.define('mobile', function() { SimUnlock.SIM_UNLOCK_LOADING = -1; SimUnlock.SIM_ABSENT_NOT_LOCKED = 0, - SimUnlock.SIM_LOCKED_PIN = 1; - SimUnlock.SIM_LOCKED_NO_PIN_TRIES_LEFT = 2; - SimUnlock.SIM_LOCKED_PUK = 3; - SimUnlock.SIM_LOCKED_NO_PUK_TRIES_LEFT = 4; - SimUnlock.SIM_DISABLED = 5; + SimUnlock.SIM_NOT_LOCKED_ASK_PIN = 1; + SimUnlock.SIM_LOCKED_PIN = 2; + SimUnlock.SIM_LOCKED_NO_PIN_TRIES_LEFT = 3; + SimUnlock.SIM_LOCKED_PUK = 4; + SimUnlock.SIM_LOCKED_NO_PUK_TRIES_LEFT = 5; + SimUnlock.SIM_DISABLED = 6; SimUnlock.ERROR_PIN = 'incorrectPin'; SimUnlock.ERROR_PUK = 'incorrectPuk'; @@ -25,6 +26,9 @@ cr.define('mobile', function() { SimUnlock.prototype = { initialized_: false, + // True if when entering PIN we're changing PinRequired preference. + changingPinRequiredPref_: false, + pinRequiredNewValue_: false, state_: -1, changeState_: function(simInfo) { @@ -39,8 +43,6 @@ cr.define('mobile', function() { SimUnlock.close(); break; case SimUnlock.SIM_LOCKED_PIN: - $('pin-input').value = ''; - SimUnlock.enablePinDialog(true); var pinMessage; if (error == SimUnlock.ERROR_OK) { pinMessage = SimUnlock.localStrings_.getString('enterPinMessage'); @@ -56,6 +58,9 @@ cr.define('mobile', function() { $('pin-error-msg').classList.add('error'); } $('pin-error-msg').textContent = pinMessage; + case SimUnlock.SIM_NOT_LOCKED_ASK_PIN: + $('pin-input').value = ''; + SimUnlock.enablePinDialog(true); $('locked-pin-overlay').hidden = false; break; case SimUnlock.SIM_LOCKED_NO_PIN_TRIES_LEFT: @@ -94,31 +99,47 @@ cr.define('mobile', function() { }, }; + SimUnlock.cancel = function() { + chrome.send('cancel'); + SimUnlock.close(); + }; + SimUnlock.close = function() { window.close(); }; SimUnlock.initialize = function() { this.initialized_ = true; + + var pinReqPattern = /(^\?|&)pin-req=([^&#]*)/; + var results = pinReqPattern.exec(window.location.search); + if (results == null) { + this.changingPinRequiredPref_ = false; + this.pinRequiredNewValue_ = false; + } else { + this.changingPinRequiredPref_ = true; + this.pinRequiredNewValue_ = /^true$/.test(results[2]); + } + $('enter-pin-confirm').addEventListener('click', function(event) { SimUnlock.enablePinDialog(false); chrome.send('enterPinCode', [$('pin-input').value]); }); $('enter-pin-dismiss').addEventListener('click', function(event) { - SimUnlock.close(); + SimUnlock.cancel(); }); $('pin-no-tries-proceed').addEventListener('click', function(event) { chrome.send('proceedToPukInput'); }); $('pin-no-tries-dismiss').addEventListener('click', function(event) { - SimUnlock.close(); + SimUnlock.cancel(); }); $('enter-puk-confirm').addEventListener('click', function(event) { SimUnlock.enablePinDialog(false); chrome.send('enterPukCode', [$('puk-input').value]); }); $('enter-puk-dismiss').addEventListener('click', function(event) { - SimUnlock.close(); + SimUnlock.cancel(); }); $('puk-no-tries-confirm').addEventListener('click', function(event) { SimUnlock.close(); @@ -126,7 +147,8 @@ cr.define('mobile', function() { $('sim-disabled-confirm').addEventListener('click', function(event) { SimUnlock.close(); }); - chrome.send('simStatusInitialize'); + chrome.send('simStatusInitialize', [this.changingPinRequiredPref_, + this.pinRequiredNewValue_]); }; SimUnlock.enablePinDialog = function(enabled) { diff --git a/chrome/browser/resources/options/chromeos/internet_detail.html b/chrome/browser/resources/options/chromeos/internet_detail.html index c96ea30..5e21724 100644 --- a/chrome/browser/resources/options/chromeos/internet_detail.html +++ b/chrome/browser/resources/options/chromeos/internet_detail.html @@ -8,7 +8,7 @@ i18n-content="wifiNetworkTabLabel"></span> <span class="active-tab-label" i18n-content="wifiNetworkTabLabel"></span> </span> - <span id="cellularPlanNavTab" class="tab cellular-details" + <span id="cellularPlanNavTab" class="tab cellular-details cdma-only" tab-contents="cellularPlanTab"> <span class="tab-label" i18n-content="cellularPlanTabLabel"></span> @@ -31,6 +31,11 @@ <span class="tab-label" i18n-content="networkTabLabel"></span> <span class="active-tab-label" i18n-content="networkTabLabel"></span> </span> + <span id="security-nav-tab" class="tab cellular-details gsm-only" + tab-contents="security-tab"> + <span class="tab-label" i18n-content="securityTabLabel"></span> + <span class="active-tab-label" i18n-content="securityTabLabel"></span> + </span> </div> <div id="wifiNetworkTab" class="subpages-tab-contents wifi-details"> <section> @@ -87,7 +92,8 @@ </table> </section> </div> - <div id="cellularPlanTab" class="subpages-tab-contents cellular-details"> + <div id="cellularPlanTab" + class="subpages-tab-contents cellular-details cdma-only"> <section> <div> <table class="option-control-table" id="details-plan-table"> @@ -260,6 +266,23 @@ </table> </section> </div> + <div id="security-tab" class="subpages-tab-contents cellular-details gsm-only"> + <div id="cellular-security-options"> + <section> + <div id="sim-pin-lock" class="checkbox"> + <label> + <input id="sim-card-lock-enabled" type="checkbox"> + <span i18n-content="lockSimCard"></span> + </label> + </div> + </section> + <section> + <div id="change-pin-area"> + <button id="change-pin" i18n-content="changePinButton"></button> + </div> + </section> + </div> + </div> <div class="action-area bottom-strip button-strip"> <button id="detailsInternetDismiss" i18n-content="detailsInternetDismiss"></button> diff --git a/chrome/browser/resources/options/chromeos/internet_options.js b/chrome/browser/resources/options/chromeos/internet_options.js index 8fe8f5ff..92630c8 100644 --- a/chrome/browser/resources/options/chromeos/internet_options.js +++ b/chrome/browser/resources/options/chromeos/internet_options.js @@ -95,6 +95,18 @@ cr.define('options', function() { String($('cellularApnUsername').value), String($('cellularApnPassword').value)]); }); + $('sim-card-lock-enabled').addEventListener('click', function(event) { + var newValue = $('sim-card-lock-enabled').checked; + // Leave value as is because user needs to enter PIN code first. + // When PIN will be entered and value changed, + // we'll update UI to reflect that change. + $('sim-card-lock-enabled').checked = !newValue; + InternetOptions.enableSecurityTab(false); + chrome.send('setSimCardLock', [newValue]); + }); + $('change-pin').addEventListener('click', function(event) { + // TODO(nkostylev): Display change PIN dialog. + }); this.showNetworkDetails_(); }, @@ -163,6 +175,11 @@ cr.define('options', function() { OptionsPage.closeOverlay(); }; + InternetOptions.enableSecurityTab = function(enabled) { + $('sim-card-lock-enabled').disabled = !enabled; + $('change-pin').disabled = !enabled; + }; + InternetOptions.setupAttributes = function(data) { var buttons = $('wireless-buttons'); if (data.wifiEnabled) { @@ -277,6 +294,11 @@ cr.define('options', function() { page.removeChild(dummy); }; + InternetOptions.updateSecurityTab = function(data) { + InternetOptions.enableSecurityTab(true); + $('sim-card-lock-enabled').checked = data.requirePin; + }; + InternetOptions.showPasswordEntry = function (data) { var element = $(data.servicePath); element.showPassword(); @@ -354,7 +376,10 @@ cr.define('options', function() { } } } else if(data.type == 5) { - OptionsPage.showTab($('cellularPlanNavTab')); + if (!data.gsm) + OptionsPage.showTab($('cellularPlanNavTab')); + else + OptionsPage.showTab($('cellularConnNavTab')); page.removeAttribute('ethernet'); page.removeAttribute('wireless'); page.removeAttribute('cert'); @@ -386,6 +411,8 @@ cr.define('options', function() { $('cellularApn').value = data.apn; $('cellularApnUsername').value = data.apn_username; $('cellularApnPassword').value = data.apn_password; + $('sim-card-lock-enabled').checked = data.simCardLockEnabled; + InternetOptions.enableSecurityTab(true); page.setAttribute('gsm', true); } diff --git a/chrome/browser/resources/options/chromeos/internet_options_page.css b/chrome/browser/resources/options/chromeos/internet_options_page.css index 21e9f31..836988a 100644 --- a/chrome/browser/resources/options/chromeos/internet_options_page.css +++ b/chrome/browser/resources/options/chromeos/internet_options_page.css @@ -207,6 +207,7 @@ html[dir='rtl'] .details-button { #detailsInternetPage[nocellplan] .plan-loading-info, #detailsInternetPage[nocellplan] .plan-details-info, #detailsInternetPage:not([gsm]) .gsm-only, +#detailsInternetPage[gsm] .cdma-only, #detailsInternetPage:not([password]) .password-details, #detailsInternetPage[cert] .password-details, #detailsInternetPage[certPkcs] .password-details, diff --git a/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc b/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc index ddc90ba..9f1827d 100644 --- a/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc +++ b/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc @@ -18,6 +18,8 @@ #include "chrome/common/url_constants.h" #include "content/browser/browser_thread.h" #include "content/browser/tab_contents/tab_contents.h" +#include "content/common/notification_service.h" +#include "content/common/notification_type.h" #include "grit/browser_resources.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -26,6 +28,7 @@ namespace { // JS API callbacks names. +const char kJsApiCancel[] = "cancel"; const char kJsApiEnterPinCode[] = "enterPinCode"; const char kJsApiEnterPukCode[] = "enterPukCode"; const char kJsApiProceedToPukInput[] = "proceedToPukInput"; @@ -94,14 +97,17 @@ class SimUnlockHandler : public WebUIMessageHandler, private: // Should keep this state enum in sync with similar one in JS code. + // SIM_NOT_LOCKED_ASK_PIN - state when SIM card is not locked but we ask user + // for PIN input because PinRequired preference change was requested. typedef enum SimUnlockState { SIM_UNLOCK_LOADING = -1, SIM_ABSEND_NOT_LOCKED = 0, - SIM_LOCKED_PIN = 1, - SIM_LOCKED_NO_PIN_TRIES_LEFT = 2, - SIM_LOCKED_PUK = 3, - SIM_LOCKED_NO_PUK_TRIES_LEFT = 4, - SIM_DISABLED = 5, + SIM_NOT_LOCKED_ASK_PIN = 1, + SIM_LOCKED_PIN = 2, + SIM_LOCKED_NO_PIN_TRIES_LEFT = 3, + SIM_LOCKED_PUK = 4, + SIM_LOCKED_NO_PUK_TRIES_LEFT = 5, + SIM_DISABLED = 6, } SimUnlockState; // Type of the SIM unlock code. @@ -124,6 +130,11 @@ class SimUnlockHandler : public WebUIMessageHandler, code_type_(code_type) { } + void HandleCancel() { + if (handler_) + handler_->CancelDialog(); + } + void HandleEnterCode() { if (handler_) handler_->EnterCode(code_, code_type_); @@ -151,6 +162,9 @@ class SimUnlockHandler : public WebUIMessageHandler, DISALLOW_COPY_AND_ASSIGN(TaskProxy); }; + // Processing for the cases when dialog was cancelled. + void CancelDialog(); + // Pass PIN/PUK code to flimflam and check status. void EnterCode(const std::string& code, SimUnlockCode code_type); @@ -161,6 +175,7 @@ class SimUnlockHandler : public WebUIMessageHandler, void HandleEnterCode(const ListValue* args, SimUnlockCode code_type); // Handlers for JS WebUI messages. + void HandleCancel(const ListValue* args); void HandleEnterPinCode(const ListValue* args); void HandleEnterPukCode(const ListValue* args); void HandleProceedToPukInput(const ListValue* args); @@ -169,6 +184,10 @@ class SimUnlockHandler : public WebUIMessageHandler, // Initialize current SIM card status, passes that to page. void InitializeSimStatus(); + // Notifies SIM Security tab handler that RequirePin preference change + // has been ended (either updated or cancelled). + void NotifyOnRequirePinChangeEnded(bool new_value); + // Checks whether SIM card is in PUK locked state and proceeds to PUK input. void ProceedToPukInput(); @@ -182,6 +201,13 @@ class SimUnlockHandler : public WebUIMessageHandler, TabContents* tab_contents_; SimUnlockState state_; + // True if SIM unlock dialog should unlock card if it's locked and + // set new value of PinRequired preference, otherwise just performs unlock. + bool changing_pin_required_pref_; + + // New value of the PinRequired preference. + bool new_pin_required_value_; + DISALLOW_COPY_AND_ASSIGN(SimUnlockHandler); }; @@ -249,7 +275,9 @@ void SimUnlockUIHTMLSource::StartDataRequest(const std::string& path, SimUnlockHandler::SimUnlockHandler() : tab_contents_(NULL), - state_(SIM_UNLOCK_LOADING) { + state_(SIM_UNLOCK_LOADING), + changing_pin_required_pref_(false), + new_pin_required_value_(false) { } SimUnlockHandler::~SimUnlockHandler() { @@ -265,6 +293,8 @@ void SimUnlockHandler::Init(TabContents* contents) { } void SimUnlockHandler::RegisterMessages() { + web_ui_->RegisterMessageCallback(kJsApiCancel, + NewCallback(this, &SimUnlockHandler::HandleCancel)); web_ui_->RegisterMessageCallback(kJsApiEnterPinCode, NewCallback(this, &SimUnlockHandler::HandleEnterPinCode)); web_ui_->RegisterMessageCallback(kJsApiEnterPukCode, @@ -275,13 +305,34 @@ void SimUnlockHandler::RegisterMessages() { NewCallback(this, &SimUnlockHandler::HandleSimStatusInitialize)); } +void SimUnlockHandler::CancelDialog() { + if (changing_pin_required_pref_) { + // When async (Unlock)/Change RequirePin operation is performed, + // dialog UI controls such as Cancel button are disabled. + // If dialog was cancelled that means RequirePin preference hasn't been + // changed and is not in process of changing in the moment. + NotifyOnRequirePinChangeEnded(!new_pin_required_value_); + } +} + void SimUnlockHandler::EnterCode(const std::string& code, SimUnlockCode code_type) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // TODO(nkostylev): Pass PIN/PUK code to flimflam. + // 1. If SIM card is locked, call EnterPin / UnblockPin (async). + // 2. If changing RequirePin preference, cache PIN code value and + // call RequirePin after card is unlocked. + // NotifyOnRequirePinChangeEnded(new_pin_required_value_); ProcessSimCardState(GetCellularNetwork()); } +void SimUnlockHandler::NotifyOnRequirePinChangeEnded(bool new_value) { + NotificationService::current()->Notify( + NotificationType::REQUIRE_PIN_SETTING_CHANGE_ENDED, + NotificationService::AllSources(), + Details<bool>(&new_value)); +} + void SimUnlockHandler::GetSimInfo(chromeos::CellularNetwork* network, DictionaryValue* value) { if (network) { @@ -290,6 +341,17 @@ void SimUnlockHandler::GetSimInfo(chromeos::CellularNetwork* network, } } +void SimUnlockHandler::HandleCancel(const ListValue* args) { + const size_t kEnterCodeParamCount = 0; + if (args->GetSize() != kEnterCodeParamCount) { + NOTREACHED(); + return; + } + scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr()); + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + NewRunnableMethod(task.get(), &TaskProxy::HandleCancel)); +} + void SimUnlockHandler::HandleEnterCode(const ListValue* args, SimUnlockCode code_type) { const size_t kEnterCodeParamCount = 1; @@ -324,6 +386,13 @@ void SimUnlockHandler::HandleProceedToPukInput(const ListValue* args) { } void SimUnlockHandler::HandleSimStatusInitialize(const ListValue* args) { + const size_t kSimStatusInitializeParamCount = 2; + if (args->GetSize() != kSimStatusInitializeParamCount || + !args->GetBoolean(0, &changing_pin_required_pref_) || + !args->GetBoolean(1, &new_pin_required_value_)) { + NOTREACHED(); + return; + } scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr()); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod(task.get(), &TaskProxy::HandleInitialize)); @@ -345,7 +414,9 @@ void SimUnlockHandler::ProcessSimCardState(chromeos::CellularNetwork* network) { // Absent/Not Locked/PIN locked, n tries/PUK locked, n tries/Blocked. switch (state_) { case SIM_UNLOCK_LOADING: + break; case SIM_ABSEND_NOT_LOCKED: + case SIM_NOT_LOCKED_ASK_PIN: case SIM_LOCKED_PIN: break; case SIM_LOCKED_NO_PIN_TRIES_LEFT: diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc index 72d7147..e48733b 100644 --- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc @@ -22,6 +22,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/login/user_manager.h" +#include "chrome/browser/chromeos/sim_unlock_dialog_delegate.h" #include "chrome/browser/chromeos/status/network_menu.h" #include "chrome/browser/chromeos/user_cros_settings_provider.h" #include "chrome/browser/prefs/pref_service.h" @@ -32,6 +33,8 @@ #include "chrome/browser/ui/webui/web_ui_util.h" #include "chrome/common/pref_names.h" #include "chrome/common/time_format.h" +#include "content/common/notification_service.h" +#include "content/common/notification_type.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -63,6 +66,8 @@ InternetOptionsHandler::InternetOptionsHandler() : chromeos::CrosOptionsPageUIHandler( new chromeos::UserCrosSettingsProvider), use_settings_ui_(false) { + registrar_.Add(this, NotificationType::REQUIRE_PIN_SETTING_CHANGE_ENDED, + NotificationService::AllSources()); chromeos::NetworkLibrary* netlib = chromeos::CrosLibrary::Get()->GetNetworkLibrary(); netlib->AddNetworkManagerObserver(this); @@ -129,6 +134,9 @@ void InternetOptionsHandler::GetLocalizedValues( localized_strings->SetString("networkTabLabel", l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_INTERNET_TAB_NETWORK)); + localized_strings->SetString("securityTabLabel", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_TAB_SECURITY)); localized_strings->SetString("connectionState", l10n_util::GetStringUTF16( @@ -270,6 +278,34 @@ void InternetOptionsHandler::GetLocalizedValues( l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_APN_SET)); + localized_strings->SetString("accessSecurityTabLink", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_ACCESS_SECURITY_TAB)); + localized_strings->SetString("lockSimCard", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_LOCK_SIM_CARD)); + localized_strings->SetString("changePinButton", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_BUTTON)); + localized_strings->SetString("changePinTitle", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_TITLE)); + localized_strings->SetString("changePinMessage", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_MESSAGE)); + localized_strings->SetString("incorrectPin", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_INCORRECT_ERROR)); + localized_strings->SetString("oldPin", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_OLD_PIN)); + localized_strings->SetString("newPin", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_NEW_PIN)); + localized_strings->SetString("retypeNewPin", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_CHANGE_PIN_RETYPE_PIN)); + localized_strings->SetString("planName", l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_INTERNET_CELL_PLAN_NAME)); @@ -367,7 +403,11 @@ void InternetOptionsHandler::RegisterMessages() { web_ui_->RegisterMessageCallback("showMorePlanInfo", NewCallback(this, &InternetOptionsHandler::BuyDataPlanCallback)); web_ui_->RegisterMessageCallback("setApn", - NewCallback(this, &InternetOptionsHandler::SetApnCallback)); + NewCallback(this, &InternetOptionsHandler::SetApnCallback)); + web_ui_->RegisterMessageCallback("setSimCardLock", + NewCallback(this, &InternetOptionsHandler::SetSimCardLockCallback)); + web_ui_->RegisterMessageCallback("changePin", + NewCallback(this, &InternetOptionsHandler::ChangePinCallback)); } void InternetOptionsHandler::EnableWifiCallback(const ListValue* args) { @@ -427,6 +467,25 @@ void InternetOptionsHandler::SetApnCallback(const ListValue* args) { } } +void InternetOptionsHandler::SetSimCardLockCallback(const ListValue* args) { + bool require_pin_new_value; + if (!args->GetBoolean(0, &require_pin_new_value)) { + NOTREACHED(); + return; + } + // 1. Bring up SIM unlock dialog, pass new RequirePin setting in URL. + // 2. Dialog will ask for current PIN in any case. + // 3. If card is locked it will first call PIN unlock operation + // 4. Then it will call Set RequirePin, passing the same PIN. + // 5. We'll get notified by REQUIRE_PIN_SETTING_CHANGE_ENDED notification. + chromeos::SimUnlockDialogDelegate::ShowDialog(GetNativeWindow(), + require_pin_new_value); +} + +void InternetOptionsHandler::ChangePinCallback(const ListValue* args) { + // TODO(nkostylev): Check OLD pin, compare new PIN inputs, change PIN if ok. +} + void InternetOptionsHandler::RefreshNetworkData( chromeos::NetworkLibrary* cros) { DictionaryValue dictionary; @@ -501,6 +560,20 @@ void InternetOptionsHandler::OnCellularDataPlanChanged( "options.InternetOptions.updateCellularPlans", connection_plans); } + +void InternetOptionsHandler::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + chromeos::CrosOptionsPageUIHandler::Observe(type, source, details); + if (type == NotificationType::REQUIRE_PIN_SETTING_CHANGE_ENDED) { + bool require_pin = *Details<bool>(details).ptr(); + DictionaryValue dictionary; + dictionary.SetBoolean("requirePin", require_pin); + web_ui_->CallJavascriptFunction( + "options.InternetOptions.updateSecurityTab", dictionary); + } +} + DictionaryValue* InternetOptionsHandler::CellularDataPlanToDictionary( const chromeos::CellularDataPlan* plan) { DictionaryValue* plan_dict = new DictionaryValue(); @@ -708,6 +781,10 @@ void InternetOptionsHandler::PopulateCellularDetails( dictionary->SetString("imsi", device->imsi()); dictionary->SetString("esn", device->esn()); dictionary->SetString("min", device->min()); + + // TODO(nkostylev): Populate real status for SIM card locked state. + // dictionary->SetBoolean("simCardLocked", true); + // dictionary->SetBoolean("simCardLockEnabled", true); } SetActivationButtonVisibility(cellular, dictionary); @@ -796,14 +873,18 @@ void InternetOptionsHandler::LoginToOtherCallback(const ListValue* args) { void InternetOptionsHandler::CreateModalPopup(views::WindowDelegate* view) { DCHECK(!use_settings_ui_); + views::Window* window = browser::CreateViewsWindow(GetNativeWindow(), + gfx::Rect(), + view); + window->SetIsAlwaysOnTop(true); + window->Show(); +} +gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { // TODO(beng): This is an improper direct dependency on Browser. Route this // through some sort of delegate. Browser* browser = BrowserList::FindBrowserWithProfile(web_ui_->GetProfile()); - views::Window* window = browser::CreateViewsWindow( - browser->window()->GetNativeHandle(), gfx::Rect(), view); - window->SetIsAlwaysOnTop(true); - window->Show(); + return browser->window()->GetNativeHandle(); } void InternetOptionsHandler::ButtonClickCallback(const ListValue* args) { @@ -862,8 +943,7 @@ void InternetOptionsHandler::HandleWifiButtonClick( "options.InternetOptions.showPasswordEntry", dictionary); } } else { - CreateModalPopup( - new chromeos::NetworkConfigView(wifi)); + CreateModalPopup(new chromeos::NetworkConfigView(wifi)); } } else { cros->ConnectToWifiNetwork(wifi); diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.h b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.h index d22ba8c..dfa89cd 100644 --- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.h +++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.h @@ -9,6 +9,8 @@ #include "chrome/browser/chromeos/cros/network_library.h" #include "chrome/browser/ui/webui/options/chromeos/cros_options_page_ui_handler.h" +#include "content/common/notification_registrar.h" +#include "ui/gfx/native_widget_types.h" class SkBitmap; namespace views { @@ -40,9 +42,15 @@ class InternetOptionsHandler // NetworkLibrary::CellularDataPlanObserver implementation. virtual void OnCellularDataPlanChanged(chromeos::NetworkLibrary* network_lib); + // NotificationObserver implementation. + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) OVERRIDE; + private: // Opens a modal popup dialog. void CreateModalPopup(views::WindowDelegate* view); + gfx::NativeWindow GetNativeWindow() const; // Passes data needed to show details overlay for network. // |args| will be [ network_type, service_path, command ] @@ -74,6 +82,8 @@ class InternetOptionsHandler void DisableCellularCallback(const ListValue* args); void BuyDataPlanCallback(const ListValue* args); void SetApnCallback(const ListValue* args); + void SetSimCardLockCallback(const ListValue* args); + void ChangePinCallback(const ListValue* args); // Parses 'path' to determine if the certificate is stored in a pkcs#11 // device. flimflam recognizes the string "SETTINGS:" to specify @@ -128,6 +138,8 @@ class InternetOptionsHandler // and false to use Views dialogs. bool use_settings_ui_; + NotificationRegistrar registrar_; + DISALLOW_COPY_AND_ASSIGN(InternetOptionsHandler); }; diff --git a/content/common/notification_type.h b/content/common/notification_type.h index c704567..6201e7d 100644 --- a/content/common/notification_type.h +++ b/content/common/notification_type.h @@ -1292,6 +1292,13 @@ class NotificationType { // changed. The source is the CrosSettings and the details a std::string of // the changed setting. SYSTEM_SETTING_CHANGED, + + // Sent by SIM unlock dialog when it has finished with the process of + // updating RequirePin setting. RequirePin setting might have been changed + // to a new value or update might have been canceled. + // In either case notification is sent and details contain a bool + // that represents current value. + REQUIRE_PIN_SETTING_CHANGE_ENDED, #endif // Sent before the repost form warning is brought up. |