diff options
author | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-20 07:52:50 +0000 |
---|---|---|
committer | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-20 07:52:50 +0000 |
commit | 777b0c5f2c37449d982d000dc628d8aa048197c2 (patch) | |
tree | 21d8feccb6f7b35be526898f74b195e3532d2324 | |
parent | bc2ab1efb49ccd7a06be7878062c6b8022bf9e50 (diff) | |
download | chromium_src-777b0c5f2c37449d982d000dc628d8aa048197c2.zip chromium_src-777b0c5f2c37449d982d000dc628d8aa048197c2.tar.gz chromium_src-777b0c5f2c37449d982d000dc628d8aa048197c2.tar.bz2 |
Merge 118361 - Changed account details button from the settings page to redirect to payment portal (not activation page). This should work with portals that require either GET or POST at landing.
BUG=chromium-os:24522
TEST=make sure that account details button from the settings page take you to payment portal not activation flow
Review URL: https://chromiumcodereview.appspot.com/9249049
TBR=zelidrag@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9269002
git-svn-id: svn://svn.chromium.org/chrome/branches/963/src@118421 0039d316-1c4b-4281-b951-d872f2087c98
7 files changed, 61 insertions, 10 deletions
diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc index 5f8233d..2580b6d 100644 --- a/chrome/browser/chromeos/cros/network_library.cc +++ b/chrome/browser/chromeos/cros/network_library.cc @@ -39,6 +39,7 @@ #include "content/public/browser/browser_thread.h" #include "crypto/nss_util.h" // crypto::GetTPMTokenInfo() for 802.1X and VPN. #include "grit/generated_resources.h" +#include "net/base/escape.h" #include "net/base/x509_certificate.h" #include "third_party/cros_system_api/dbus/service_constants.h" #include "ui/base/l10n/l10n_util.h" @@ -118,6 +119,12 @@ const int kRecentPlanPaymentHours = 6; // If cellular device doesn't have SIM card, then retries are never used. const int kDefaultSimUnlockRetriesCount = 999; +// Redirect extension url for POST-ing url parameters to mobile account status +// sites. +const char kRedirectExtensionPage[] = + "chrome-extension://iadeocfgjdjdmpenejdbfeaocpbikmab/redirect.html?" + "autoPost=1"; + // List of cellular operators names that should have data roaming always enabled // to be able to connect to any network. const char* kAlwaysInRoamingOperators[] = { @@ -336,6 +343,19 @@ GHashTable* ConvertDictionaryValueToGValueMap(const DictionaryValue* dict) { return ghash; } +GURL AppendQueryParameter(const GURL& url, + const std::string& name, + const std::string& value) { + std::string query(url.query()); + if (!query.empty()) + query += "&"; + query += (net::EscapeQueryParamValue(name, true) + "=" + + net::EscapeQueryParamValue(value, true)); + GURL::Replacements replacements; + replacements.SetQueryStr(query); + return url.ReplaceComponents(replacements); +} + } // namespace //////////////////////////////////////////////////////////////////////////////// @@ -1154,6 +1174,20 @@ bool CellularNetwork::SupportsDataPlan() const { return !usage_url().empty() || !payment_url().empty(); } +GURL CellularNetwork::GetAccountInfoUrl() const { + if (!post_data_.length()) + return GURL(payment_url()); + + GURL base_url(kRedirectExtensionPage); + GURL temp_url = AppendQueryParameter(base_url, + "post_data", + post_data_); + GURL redir_url = AppendQueryParameter(temp_url, + "formUrl", + payment_url()); + return redir_url; +} + std::string CellularNetwork::GetNetworkTechnologyString() const { // No need to localize these cellular technology abbreviations. switch (network_technology_) { diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h index f18d46a..a48f246 100644 --- a/chrome/browser/chromeos/cros/network_library.h +++ b/chrome/browser/chromeos/cros/network_library.h @@ -18,6 +18,7 @@ #include "base/observer_list.h" #include "base/string16.h" #include "base/timer.h" +#include "googleurl/src/gurl.h" #include "third_party/cros/chromeos_network.h" namespace base { @@ -1084,6 +1085,8 @@ class CellularNetwork : public WirelessNetwork { // Returns true if one of the usage_url_ / payment_url_ (or both) is defined. bool SupportsDataPlan() const; + // Return a URL for account info page. + GURL GetAccountInfoUrl() const; // Return a string representation of network technology. std::string GetNetworkTechnologyString() const; // Return a string representation of activation state. diff --git a/chrome/browser/resources/options/chromeos/internet_options.js b/chrome/browser/resources/options/chromeos/internet_options.js index a983d66..04ed13a 100644 --- a/chrome/browser/resources/options/chromeos/internet_options.js +++ b/chrome/browser/resources/options/chromeos/internet_options.js @@ -95,7 +95,7 @@ cr.define('options', function() { OptionsPage.closeOverlay(); }); $('viewAccountDetails').addEventListener('click', function(event) { - chrome.send('buyDataPlan'); + chrome.send('showMorePlanInfo'); OptionsPage.closeOverlay(); }); $('cellularApnUseDefault').addEventListener('click', function(event) { diff --git a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc index b9dedc6..393168a 100644 --- a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc +++ b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc @@ -1399,8 +1399,7 @@ void MobileSetupHandler::StartActivationOnUIThread() { //////////////////////////////////////////////////////////////////////////////// MobileSetupUI::MobileSetupUI(TabContents* contents) - : ChromeWebUI(contents), - frame_load_observer_(NULL) { + : ChromeWebUI(contents) { chromeos::CellularNetwork* network = GetCellularNetwork(); std::string service_path = network ? network->service_path() : std::string(); MobileSetupHandler* handler = new MobileSetupHandler(service_path); @@ -1417,6 +1416,5 @@ MobileSetupUI::MobileSetupUI(TabContents* contents) void MobileSetupUI::RenderViewCreated(RenderViewHost* host) { ChromeWebUI::RenderViewCreated(host); // Destroyed by the corresponding RenderViewHost. - frame_load_observer_ = - new PortalFrameLoadObserver(AsWeakPtr(), host); + new PortalFrameLoadObserver(AsWeakPtr(), host); } diff --git a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.h b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.h index 8af042c..30bfc0d 100644 --- a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.h +++ b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.h @@ -9,7 +9,6 @@ #include "base/memory/weak_ptr.h" #include "chrome/browser/ui/webui/chrome_web_ui.h" -class PortalFrameLoadObserver; // A custom WebUI that defines datasource for mobile setup registration page // that is used in Chrome OS activate modem and perform plan subscription tasks. class MobileSetupUI : public ChromeWebUI, @@ -17,13 +16,10 @@ class MobileSetupUI : public ChromeWebUI, public: explicit MobileSetupUI(TabContents* contents); - void OnObserverDeleted(); - private: // ChromeWebUI overrides. virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; - PortalFrameLoadObserver* frame_load_observer_; DISALLOW_COPY_AND_ASSIGN(MobileSetupUI); }; 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 7527fc6..d7a2d9c 100644 --- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc @@ -584,7 +584,7 @@ void InternetOptionsHandler::RegisterMessages() { base::Bind(&InternetOptionsHandler::BuyDataPlanCallback, base::Unretained(this))); web_ui_->RegisterMessageCallback("showMorePlanInfo", - base::Bind(&InternetOptionsHandler::BuyDataPlanCallback, + base::Bind(&InternetOptionsHandler::ShowMorePlanInfoCallback, base::Unretained(this))); web_ui_->RegisterMessageCallback("setApn", base::Bind(&InternetOptionsHandler::SetApnCallback, @@ -623,6 +623,25 @@ void InternetOptionsHandler::DisableCellularCallback(const ListValue* args) { cros_->EnableCellularNetworkDevice(false); } +void InternetOptionsHandler::ShowMorePlanInfoCallback(const ListValue* args) { + if (!web_ui_) + return; + + Browser* browser = BrowserList::FindBrowserWithFeature( + Profile::FromWebUI(web_ui_), Browser::FEATURE_TABSTRIP); + if (!browser) + return; + + const chromeos::CellularNetwork* cellular = cros_->cellular_network(); + if (!cellular) + return; + + browser->OpenURL(cellular->GetAccountInfoUrl(), + GURL(), + NEW_FOREGROUND_TAB, + content::PAGE_TRANSITION_LINK); +} + void InternetOptionsHandler::BuyDataPlanCallback(const ListValue* args) { if (!web_ui_) return; 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 e971a7b..0c9cf32 100644 --- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.h +++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.h @@ -93,6 +93,7 @@ class InternetOptionsHandler void SetSimCardLockCallback(const base::ListValue* args); void ChangePinCallback(const base::ListValue* args); void ShareNetworkCallback(const base::ListValue* args); + void ShowMorePlanInfoCallback(const ListValue* args); // Populates the ui with the details of the given device path. This forces // an overlay to be displayed in the UI. |