summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-25 06:17:04 +0000
committerzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-25 06:17:04 +0000
commit9d3f7d5e85d9834495434d7b925c1ba7933a344f (patch)
tree1b1100ef3ca76cbd86aa302cd29603c7dbffed84
parent5530ac65a61c659e28ced24a4479a5c4d11dc546 (diff)
downloadchromium_src-9d3f7d5e85d9834495434d7b925c1ba7933a344f.zip
chromium_src-9d3f7d5e85d9834495434d7b925c1ba7933a344f.tar.gz
chromium_src-9d3f7d5e85d9834495434d7b925c1ba7933a344f.tar.bz2
Skeleton for mobile device activation UI.
BUG=chromium-os:6868 TEST=none Review URL: http://codereview.chromium.org/3448018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60568 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd10
-rw-r--r--chrome/browser/browser_resources.grd1
-rw-r--r--chrome/browser/chromeos/cros/network_library.cc10
-rw-r--r--chrome/browser/chromeos/cros/network_library.h19
-rw-r--r--chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc237
-rw-r--r--chrome/browser/chromeos/dom_ui/mobile_setup_ui.h21
-rw-r--r--chrome/browser/chromeos/dom_ui/register_page_ui.cc (renamed from chrome/browser/dom_ui/register_page_ui.cc)15
-rw-r--r--chrome/browser/chromeos/dom_ui/register_page_ui.h (renamed from chrome/browser/dom_ui/register_page_ui.h)6
-rw-r--r--chrome/browser/dom_ui/dom_ui_factory.cc13
-rw-r--r--chrome/browser/resources/connection_manager.js49
-rw-r--r--chrome/browser/resources/mobile_setup.html32
-rw-r--r--chrome/browser/resources/mobile_setup.js82
-rw-r--r--chrome/chrome_browser.gypi6
-rw-r--r--chrome/common/url_constants.cc28
-rw-r--r--chrome/common/url_constants.h28
-rwxr-xr-xchrome/test/data/chromeos/mobile_activation.html55
16 files changed, 572 insertions, 40 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 9738ef1..8a766dc 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -3886,8 +3886,8 @@ Keep your key file in a safe place. You will need it to create new versions of y
You are using an unsupported command-line flag: <ph name="BAD_FLAG">$1<ex>--no-sandbox</ex></ph>. Stability and security will suffer.
</message>
- <!-- about:system strings -->
<if expr="pp_ifdef('chromeos')">
+ <!-- about:system strings -->
<message name="IDS_ABOUT_SYS_TITLE" desc="about:system page title">
About System
</message>
@@ -3909,6 +3909,14 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_ABOUT_SYS_COLLAPSE" desc="name of a button that hides (collapses) specific system details">
Collapse...
</message>
+
+ <!-- chrome://mobilesetup strings -->
+ <message name="IDS_MOBILE_SETUP_TITLE" desc="ChromeOS mobile device activation page title">
+ Activate your cellular connection
+ </message>
+ <message name="IDS_MOBILE_SETUP_HEADER" desc="ChromeOS mobile device activation page heade">
+ Cellular device activation
+ </message>
</if>
<!-- about:version strings -->
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index b70f99c..bbdcf6c 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -71,6 +71,7 @@ without changes to the corresponding grd file. eeeeet -->
<include name="IDR_IMAGEBURNER_HTML" file="resources\imageburner.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_MEDIAPLAYER_HTML" file="resources\mediaplayer.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_MEDIAPLAYERPLAYLIST_HTML" file="resources\playlist.html" flattenhtml="true" type="BINDATA" />
+ <include name="IDR_MOBILE_SETUP_PAGE_HTML" file="resources\mobile_setup.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_OFFLINE_LOAD_HTML" file="resources\offline_load.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_OS_CREDITS_HTML" file="resources\about_os_credits.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_SLIDESHOW_HTML" file="resources\slideshow.html" flattenhtml="true" type="BINDATA" />
diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc
index 920a18e..b034c87 100644
--- a/chrome/browser/chromeos/cros/network_library.cc
+++ b/chrome/browser/chromeos/cros/network_library.cc
@@ -156,12 +156,22 @@ void WirelessNetwork::ConfigureFromService(const ServiceInfo& service) {
////////////////////////////////////////////////////////////////////////////////
// CellularNetwork
+
+bool CellularNetwork::StartActivation() const {
+ // TODO(ers, jglasgow): Kick of device activation process.
+ return true;
+}
+
void CellularNetwork::Clear() {
WirelessNetwork::Clear();
}
void CellularNetwork::ConfigureFromService(const ServiceInfo& service) {
WirelessNetwork::ConfigureFromService(service);
+ if (service.activation_state)
+ activation_state_ = service.activation_state;
+ // TODO(ers): Set other cellular properties here once they get added
+ // to ServiceInfo.
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h
index bdf445a..a705ca7 100644
--- a/chrome/browser/chromeos/cros/network_library.h
+++ b/chrome/browser/chromeos/cros/network_library.h
@@ -121,10 +121,29 @@ class CellularNetwork : public WirelessNetwork {
: WirelessNetwork() {
ConfigureFromService(service);
}
+ // Starts device activation process. Returns false if the device state does
+ // not permit activation.
+ bool StartActivation() const;
+ const std::string& activation_state() const { return activation_state_; }
+ const std::string& payment_url() const { return payment_url_; }
+ const std::string& meid() const { return meid_; }
+ const std::string& imei() const { return imei_; }
+ const std::string& imsi() const { return imsi_; }
+ const std::string& esn() const { return esn_; }
+ const std::string& mdn() const { return mdn_; }
// WirelessNetwork overrides.
virtual void Clear();
virtual void ConfigureFromService(const ServiceInfo& service);
+
+ protected:
+ std::string activation_state_;
+ std::string payment_url_;
+ std::string meid_;
+ std::string imei_;
+ std::string imsi_;
+ std::string esn_;
+ std::string mdn_;
};
class WifiNetwork : public WirelessNetwork {
diff --git a/chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc b/chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc
new file mode 100644
index 0000000..07b8133
--- /dev/null
+++ b/chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc
@@ -0,0 +1,237 @@
+// Copyright (c) 2010 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/dom_ui/mobile_setup_ui.h"
+
+#include <string>
+
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "base/callback.h"
+#include "base/logging.h"
+#include "base/string_piece.h"
+#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
+#include "base/values.h"
+#include "base/weak_ptr.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/jstemplate_builder.h"
+#include "chrome/common/url_constants.h"
+#include "googleurl/src/gurl.h"
+#include "grit/browser_resources.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+#include "grit/locale_settings.h"
+
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/cros/network_library.h"
+#include "chrome/browser/chromeos/cros/system_library.h"
+
+namespace {
+
+// Host page JS API function names.
+const char kJsApiGetDeviceInfo[] = "getDeviceInfo";
+const char kJsApiSetTransactionStatus[] = "setTransactionStatus";
+
+const wchar_t kJsDeviceStatusChangedHandler[] =
+ L"mobile.MobileSetup.onDeviceStatusChanged";
+
+} // namespace
+
+class MobileSetupUIHTMLSource : public ChromeURLDataManager::DataSource {
+ public:
+ MobileSetupUIHTMLSource();
+
+ // Called when the network layer has requested a resource underneath
+ // the path we registered.
+ virtual void StartDataRequest(const std::string& path,
+ bool is_off_the_record,
+ int request_id);
+ virtual std::string GetMimeType(const std::string&) const {
+ return "text/html";
+ }
+
+ private:
+ ~MobileSetupUIHTMLSource() {}
+
+ DISALLOW_COPY_AND_ASSIGN(MobileSetupUIHTMLSource);
+};
+
+// The handler for Javascript messages related to the "register" view.
+class MobileSetupHandler : public DOMMessageHandler,
+ public base::SupportsWeakPtr<MobileSetupHandler> {
+ public:
+ MobileSetupHandler();
+ virtual ~MobileSetupHandler();
+
+ // Init work after Attach.
+ void Init();
+
+ // DOMMessageHandler implementation.
+ virtual DOMMessageHandler* Attach(DOMUI* dom_ui);
+ virtual void RegisterMessages();
+
+ private:
+ // Handlers for JS DOMUI messages.
+ void HandleGetDeviceInfo(const ListValue* args);
+ void HandleSetTransactionStatus(const ListValue* args);
+
+ // Sends message to host registration page with system/user info data.
+ void SendDeviceInfo();
+
+ // Converts device the current CelularNetork into JS object.
+ bool GetDeviceInfo(DictionaryValue* value);
+
+ DISALLOW_COPY_AND_ASSIGN(MobileSetupHandler);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// MobileSetupUIHTMLSource
+//
+////////////////////////////////////////////////////////////////////////////////
+
+MobileSetupUIHTMLSource::MobileSetupUIHTMLSource()
+ : DataSource(chrome::kChromeUIMobileSetupHost, MessageLoop::current()) {
+}
+
+void MobileSetupUIHTMLSource::StartDataRequest(const std::string& path,
+ bool is_off_the_record,
+ int request_id) {
+ DictionaryValue strings;
+ strings.SetString("title", l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE));
+ strings.SetString("header",
+ l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_HEADER));
+ SetFontAndTextDirection(&strings);
+
+ static const base::StringPiece html(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_MOBILE_SETUP_PAGE_HTML));
+ const std::string full_html = jstemplate_builder::GetTemplatesHtml(
+ html, &strings, "t" /* template root node id */);
+
+ 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);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// MobileSetupHandler
+//
+////////////////////////////////////////////////////////////////////////////////
+MobileSetupHandler::MobileSetupHandler() {
+}
+
+MobileSetupHandler::~MobileSetupHandler() {
+}
+
+DOMMessageHandler* MobileSetupHandler::Attach(DOMUI* dom_ui) {
+ return DOMMessageHandler::Attach(dom_ui);
+}
+
+void MobileSetupHandler::Init() {
+ // TODO(zelidag): Register for network change notification to make sure
+ // that the status of the cellular network does not flip to something we
+ // can't handle (disabled, suddenly activated by divine intervention...).
+}
+
+void MobileSetupHandler::RegisterMessages() {
+ dom_ui_->RegisterMessageCallback(kJsApiGetDeviceInfo,
+ NewCallback(this, &MobileSetupHandler::HandleGetDeviceInfo));
+ dom_ui_->RegisterMessageCallback(kJsApiSetTransactionStatus,
+ NewCallback(this, &MobileSetupHandler::HandleSetTransactionStatus));
+}
+
+void MobileSetupHandler::HandleGetDeviceInfo(const ListValue* args) {
+ const size_t kGetDeviceInfoParamCount = 1;
+ if (args->GetSize() != kGetDeviceInfoParamCount)
+ return;
+
+ // Get change callback function name.
+ string16 callback_func_name;
+ if (!args->GetString(0, &callback_func_name))
+ return;
+
+ DictionaryValue value;
+ if (GetDeviceInfo(&value))
+ dom_ui_->CallJavascriptFunction(UTF16ToWide(callback_func_name), value);
+}
+
+void MobileSetupHandler::HandleSetTransactionStatus(const ListValue* args) {
+ const size_t kSetTransactionStatusParamCount = 1;
+ if (args->GetSize() != kSetTransactionStatusParamCount)
+ return;
+
+ // Get change callback function name.
+ std::string status;
+ if (!args->GetString(0, &status))
+ return;
+
+ chromeos::NetworkLibrary* network_lib =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ const chromeos::CellularNetworkVector& cell_networks =
+ network_lib->cellular_networks();
+ if (!cell_networks.size())
+ return;
+ const chromeos::CellularNetwork& network = *(cell_networks.begin());
+
+ if (LowerCaseEqualsASCII(status, "OK") && network.StartActivation()) {
+ DictionaryValue value;
+ if (GetDeviceInfo(&value))
+ dom_ui_->CallJavascriptFunction(kJsDeviceStatusChangedHandler, value);
+ }
+ // TODO(zelidrag): Close the setup tab automatically when payment fails?
+ // Pending UX decision on this one.
+}
+
+
+bool MobileSetupHandler::GetDeviceInfo(DictionaryValue* value) {
+ DCHECK(value);
+ chromeos::NetworkLibrary* network_lib =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+
+ const chromeos::CellularNetworkVector& cell_networks =
+ network_lib->cellular_networks();
+ if (!cell_networks.size())
+ return false;
+
+ const chromeos::CellularNetwork& network = *(cell_networks.begin());
+
+ value->SetString("carrier", UTF8ToUTF16(network.name()));
+ value->SetString("payment_url", UTF8ToUTF16(network.payment_url()));
+ value->SetString("activation_state", UTF8ToUTF16(network.activation_state()));
+ value->SetString("MEID", UTF8ToUTF16(network.meid()));
+ value->SetString("IMEI", UTF8ToUTF16(network.imei()));
+ value->SetString("IMSI", UTF8ToUTF16(network.imsi()));
+ value->SetString("ESN", UTF8ToUTF16(network.esn()));
+ value->SetString("MDN", UTF8ToUTF16(network.mdn()));
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// MobileSetupUI
+//
+////////////////////////////////////////////////////////////////////////////////
+
+MobileSetupUI::MobileSetupUI(TabContents* contents) : DOMUI(contents){
+ MobileSetupHandler* handler = new MobileSetupHandler();
+ AddMessageHandler((handler)->Attach(this));
+ handler->Init();
+ MobileSetupUIHTMLSource* html_source = new MobileSetupUIHTMLSource();
+
+ // Set up the chrome://mobilesetup/ source.
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ Singleton<ChromeURLDataManager>::get(),
+ &ChromeURLDataManager::AddDataSource,
+ make_scoped_refptr(html_source)));
+}
diff --git a/chrome/browser/chromeos/dom_ui/mobile_setup_ui.h b/chrome/browser/chromeos/dom_ui/mobile_setup_ui.h
new file mode 100644
index 0000000..f30af42
--- /dev/null
+++ b/chrome/browser/chromeos/dom_ui/mobile_setup_ui.h
@@ -0,0 +1,21 @@
+// Copyright (c) 2010 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_DOM_UI_MOBILE_SETUP_UI_H_
+#define CHROME_BROWSER_CHROMEOS_DOM_UI_MOBILE_SETUP_UI_H_
+#pragma once
+
+#include "chrome/browser/dom_ui/dom_ui.h"
+
+// A custom DOMUI that defines datasource for mobile setup registration page
+// that is used in Chrome OS activate modem and perform plan subscription tasks.
+class MobileSetupUI : public DOMUI {
+ public:
+ explicit MobileSetupUI(TabContents* contents);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MobileSetupUI);
+};
+
+#endif // CHROME_BROWSER_CHROMEOS_DOM_UI_MOBILE_SETUP_UI_H_
diff --git a/chrome/browser/dom_ui/register_page_ui.cc b/chrome/browser/chromeos/dom_ui/register_page_ui.cc
index f41d7bb..2deda48 100644
--- a/chrome/browser/dom_ui/register_page_ui.cc
+++ b/chrome/browser/chromeos/dom_ui/register_page_ui.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/dom_ui/register_page_ui.h"
+#include "chrome/browser/chromeos/dom_ui/register_page_ui.h"
#include <string>
@@ -15,20 +15,17 @@
#include "base/weak_ptr.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_thread.h"
-#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/common/url_constants.h"
-#include "googleurl/src/gurl.h"
-#include "grit/browser_resources.h"
-
-#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/cros/system_library.h"
#include "chrome/browser/chromeos/customization_document.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/version_loader.h"
-#endif
+#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/url_constants.h"
+#include "googleurl/src/gurl.h"
+#include "grit/browser_resources.h"
namespace {
diff --git a/chrome/browser/dom_ui/register_page_ui.h b/chrome/browser/chromeos/dom_ui/register_page_ui.h
index 10c9ca9..44138eb 100644
--- a/chrome/browser/dom_ui/register_page_ui.h
+++ b/chrome/browser/chromeos/dom_ui/register_page_ui.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_DOM_UI_REGISTER_PAGE_UI_H_
-#define CHROME_BROWSER_DOM_UI_REGISTER_PAGE_UI_H_
+#ifndef CHROME_BROWSER_CHROMEOS_DOM_UI_REGISTER_PAGE_UI_H_
+#define CHROME_BROWSER_CHROMEOS_DOM_UI_REGISTER_PAGE_UI_H_
#pragma once
#include "chrome/browser/dom_ui/dom_ui.h"
@@ -18,4 +18,4 @@ class RegisterPageUI : public DOMUI {
DISALLOW_COPY_AND_ASSIGN(RegisterPageUI);
};
-#endif // CHROME_BROWSER_DOM_UI_REGISTER_PAGE_UI_H_
+#endif // CHROME_BROWSER_CHROMEOS_DOM_UI_REGISTER_PAGE_UI_H_
diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc
index 3b80c43..ac3c4624 100644
--- a/chrome/browser/dom_ui/dom_ui_factory.cc
+++ b/chrome/browser/dom_ui/dom_ui_factory.cc
@@ -37,10 +37,11 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/dom_ui/imageburner_ui.h"
+#include "chrome/browser/chromeos/dom_ui/mobile_setup_ui.h"
+#include "chrome/browser/chromeos/dom_ui/register_page_ui.h"
#include "chrome/browser/chromeos/dom_ui/system_info_ui.h"
#include "chrome/browser/dom_ui/filebrowse_ui.h"
#include "chrome/browser/dom_ui/mediaplayer_ui.h"
-#include "chrome/browser/dom_ui/register_page_ui.h"
#endif
const DOMUITypeID DOMUIFactory::kNoDOMUI = NULL;
@@ -145,16 +146,18 @@ static DOMUIFactoryFunction GetDOMUIFactoryFunction(Profile* profile,
#if defined(OS_CHROMEOS)
if (url.host() == chrome::kChromeUIFileBrowseHost)
return &NewDOMUI<FileBrowseUI>;
- if (url.host() == chrome::kChromeUIMediaplayerHost)
- return &NewDOMUI<MediaplayerUI>;
if (url.host() == chrome::kChromeUIImageBurnerHost)
return &NewDOMUI<ImageBurnUI>;
+ if (url.host() == chrome::kChromeUIMediaplayerHost)
+ return &NewDOMUI<MediaplayerUI>;
+ if (url.host() == chrome::kChromeUIMobileSetupHost)
+ return &NewDOMUI<MobileSetupUI>;
+ if (url.host() == chrome::kChromeUISettingsHost)
+ return &NewDOMUI<OptionsUI>;
if (url.host() == chrome::kChromeUIRegisterPageHost)
return &NewDOMUI<RegisterPageUI>;
if (url.host() == chrome::kChromeUISlideshowHost)
return &NewDOMUI<SlideshowUI>;
- if (url.host() == chrome::kChromeUISettingsHost)
- return &NewDOMUI<OptionsUI>;
if (url.host() == chrome::kChromeUISystemInfoHost)
return &NewDOMUI<SystemInfoUI>;
#else
diff --git a/chrome/browser/resources/connection_manager.js b/chrome/browser/resources/connection_manager.js
new file mode 100644
index 0000000..bf443c4
--- /dev/null
+++ b/chrome/browser/resources/connection_manager.js
@@ -0,0 +1,49 @@
+// Copyright (c) 2010 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.
+
+
+function chromeos() {
+}
+
+chromeos.connectionManager = function() {
+};
+
+chromeos.connectionManager.device_info_callback_ = null;
+chromeos.connectionManager.transaction_status_callback_ = null;
+chromeos.connectionManager.parent_page_url_ = 'chrome://mobilesetup';
+
+chromeos.connectionManager.getDeviceInfo = function(callback) {
+ chromeos.connectionManager.device_info_callback_ = callback;
+ chromeos.connectionManager.requestDeviceInfo_();
+};
+
+chromeos.connectionManager.setTransactionStatus = function(status, callback) {
+ chromeos.connectionManager.transaction_status_callback_ = callback;
+ chromeos.connectionManager.reportTransactionStatus_(status);
+};
+
+chromeos.connectionManager.reportTransactionStatus_ = function(status) {
+ var msg = {
+ 'type': 'reportTransactionStatusMsg',
+ 'domain': location.href,
+ 'status': status
+ };
+ window.parent.postMessage(msg, chromeos.connectionManager.parent_page_url_);
+};
+
+chromeos.connectionManager.requestDeviceInfo_ = function() {
+ var msg = {
+ 'type': 'requestDeviceInfoMsg',
+ 'domain': location.href,
+ };
+ window.parent.postMessage(msg, chromeos.connectionManager.parent_page_url_);
+}
+
+window.addEventListener('message', function(e) {
+ if (e.data.type == 'deviceInfoMsg') {
+ if (chromeos.connectionManager.device_info_callback_)
+ chromeos.connectionManager.device_info_callback_(e.data.payload);
+ }
+});
+
diff --git a/chrome/browser/resources/mobile_setup.html b/chrome/browser/resources/mobile_setup.html
new file mode 100644
index 0000000..1811e7b
--- /dev/null
+++ b/chrome/browser/resources/mobile_setup.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title i18n-content="title"></title>
+<style>
+body {
+ font-family: sans-serif;
+ font-size: 10px;
+}
+
+#payment-form {
+ width: 600px;
+ height: 300px;
+ overflow: hidden;
+}
+
+#error-div {
+}
+</style>
+<script src="chrome://resources/js/cr.js"></script>
+<script src="chrome://resources/js/util.js"></script>
+<script src="mobile_setup.js"></script>
+<script>
+ mobile.MobileSetup.getInstance().initialize('payment-form');
+</script>
+</head>
+<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
+<h1 i18n-content="header"></h1>
+<div id="error-div"></div>
+<iframe id="payment-form" frameborder="0"></iframe></body>
+</html>
diff --git a/chrome/browser/resources/mobile_setup.js b/chrome/browser/resources/mobile_setup.js
new file mode 100644
index 0000000..fa1e98e
--- /dev/null
+++ b/chrome/browser/resources/mobile_setup.js
@@ -0,0 +1,82 @@
+// Copyright (c) 2010 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.
+
+
+cr.define('mobile', function() {
+
+ function MobileSetup() {
+ }
+
+ cr.addSingletonGetter(MobileSetup);
+
+ MobileSetup.prototype = {
+ // Mobile device information.
+ deviceInfo_: null,
+ frame_name_ : '',
+
+ initialize: function(frame_name) {
+ self = this;
+ this.frame_name_ = frame_name;
+ document.addEventListener('DOMContentLoaded', function(deviceInfo) {
+ chrome.send('getDeviceInfo',
+ ['mobile.MobileSetup.getDeviceInfoCallback']);
+ });
+ window.addEventListener('message', function(e) {
+ self.onMessageReceived_(e);
+ });
+ },
+
+ loadPaymentFrame: function(deviceInfo) {
+ if (deviceInfo) {
+ this.deviceInfo_ = deviceInfo;
+
+ // HACK(zelidrag): Remove the next line for real testing.
+ this.deviceInfo_.payment_url = 'http://link.to/mobile_activation.html';
+
+ $(this.frame_name_).contentWindow.location.href =
+ this.deviceInfo_.payment_url;
+ }
+ },
+
+ onMessageReceived_: function(e) {
+ if (e.origin !=
+ this.deviceInfo_.payment_url.substring(0, e.origin.length))
+ return;
+
+ if (e.data.type == 'requestDeviceInfoMsg') {
+ this.sendDeviceInfo_();
+ } else if (e.data.type == 'reportTransactionStatusMsg') {
+ chrome.send('setTransactionStatus', [e.data.status]);
+ }
+ },
+
+ sendDeviceInfo_ : function() {
+ var msg = {
+ type: 'deviceInfoMsg',
+ domain: document.location,
+ payload: {
+ 'carrier': this.deviceInfo_.carrier,
+ 'MEID': this.deviceInfo_.MEID,
+ 'IMEI': this.deviceInfo_.IMEI,
+ 'IMSI': this.deviceInfo_.IMSI,
+ 'ESN': this.deviceInfo_.ESN,
+ 'MDN': this.deviceInfo_.MDN
+ }
+ };
+ $(this.frame_name_).contentWindow.postMessage(msg,
+ this.deviceInfo_.payment_url);
+ }
+ };
+
+ MobileSetup.getDeviceInfoCallback = function(deviceInfo) {
+ MobileSetup.getInstance().loadPaymentFrame(deviceInfo);
+ };
+
+ // Export
+ return {
+ MobileSetup: MobileSetup
+ };
+
+});
+
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 3afa15c..0d57944 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -451,8 +451,12 @@
'browser/chromeos/dom_ui/language_options_util.h',
'browser/chromeos/dom_ui/language_pinyin_options_handler.cc',
'browser/chromeos/dom_ui/language_pinyin_options_handler.h',
+ 'browser/chromeos/dom_ui/mobile_setup_ui.cc',
+ 'browser/chromeos/dom_ui/mobile_setup_ui.h',
'browser/chromeos/dom_ui/proxy_handler.cc',
'browser/chromeos/dom_ui/proxy_handler.h',
+ 'browser/chromeos/dom_ui/register_page_ui.cc',
+ 'browser/chromeos/dom_ui/register_page_ui.h',
'browser/chromeos/dom_ui/system_info_ui.cc',
'browser/chromeos/dom_ui/system_info_ui.h',
'browser/chromeos/dom_ui/system_options_handler.cc',
@@ -1298,8 +1302,6 @@
'browser/dom_ui/options_ui.h',
'browser/dom_ui/plugins_ui.cc',
'browser/dom_ui/plugins_ui.h',
- 'browser/dom_ui/register_page_ui.cc',
- 'browser/dom_ui/register_page_ui.h',
'browser/dom_ui/remoting_ui.cc',
'browser/dom_ui/remoting_ui.h',
'browser/dom_ui/shared_resources_data_source.cc',
diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc
index 8a119f9..5b31d9c 100644
--- a/chrome/common/url_constants.cc
+++ b/chrome/common/url_constants.cc
@@ -74,21 +74,25 @@ const char kChromeUIDevToolsURL[] = "chrome://devtools/";
const char kChromeUIDownloadsURL[] = "chrome://downloads/";
const char kChromeUIExtensionsURL[] = "chrome://extensions/";
const char kChromeUIFavIconURL[] = "chrome://favicon/";
-const char kChromeUIFileBrowseURL[] = "chrome://filebrowse/";
const char kChromeUIHistory2URL[] = "chrome://history2/";
const char kChromeUIHistoryURL[] = "chrome://history/";
-const char kChromeUIImageBurnerURL[] = "chrome://imageburner/";
const char kChromeUIIPCURL[] = "chrome://about/ipc";
const char kChromeUIKeyboardURL[] = "chrome://keyboard/";
const char kChromeUILabsURL[] = "chrome://labs/";
-const char kChromeUIMediaplayerURL[] = "chrome://mediaplayer/";
const char kChromeUINewTabURL[] = "chrome://newtab";
const char kChromeUIPluginsURL[] = "chrome://plugins/";
const char kChromeUIPrintURL[] = "chrome://print/";
-const char kChromeUIRegisterPageURL[] = "chrome://register/";
const char kChromeUISettingsURL[] = "chrome://settings/";
+
+#if defined(OS_CHROMEOS)
+const char kChromeUIFileBrowseURL[] = "chrome://filebrowse/";
+const char kChromeUIImageBurnerURL[] = "chrome://imageburner/";
+const char kChromeUIMediaplayerURL[] = "chrome://mediaplayer/";
+const char kChromeUIMobileSetupURL[] = "chrome://mobilesetup/";
+const char kChromeUIRegisterPageURL[] = "chrome://register/";
const char kChromeUISlideshowURL[] = "chrome://slideshow/";
const char kChromeUISystemInfoURL[] = "chrome://system/";
+#endif
const char kChromeUIBookmarksHost[] = "bookmarks";
const char kChromeUIBugReportHost[] = "bugreport";
@@ -97,30 +101,34 @@ const char kChromeUIDialogHost[] = "dialog";
const char kChromeUIDownloadsHost[] = "downloads";
const char kChromeUIExtensionsHost[] = "extensions";
const char kChromeUIFavIconHost[] = "favicon";
-const char kChromeUIFileBrowseHost[] = "filebrowse";
const char kChromeUIHistoryHost[] = "history";
const char kChromeUIHistory2Host[] = "history2";
-const char kChromeUIImageBurnerHost[] = "imageburner";
const char kChromeUIInspectorHost[] = "inspector";
const char kChromeUIKeyboardHost[] = "keyboard";
const char kChromeUILabsHost[] = "labs";
-const char kChromeUIMediaplayerHost[] = "mediaplayer";
const char kChromeUINetInternalsHost[] = "net-internals";
const char kChromeUINewTabHost[] = "newtab";
const char kChromeUIPluginsHost[] = "plugins";
const char kChromeUIPrintHost[] = "print";
-const char kChromeUIRegisterPageHost[] = "register";
const char kChromeUIRemotingHost[] = "remoting";
const char kChromeUIResourcesHost[] = "resources";
const char kChromeUISettingsHost[] = "settings";
-const char kChromeUISlideshowHost[] = "slideshow";
const char kChromeUISyncResourcesHost[] = "syncresources";
-const char kChromeUISystemInfoHost[] = "system";
const char kChromeUIRemotingResourcesHost[] = "remotingresources";
const char kChromeUIThemePath[] = "theme";
const char kChromeUIScreenshotPath[] = "screenshots";
const char kChromeUIThumbnailPath[] = "thumb";
+#if defined(OS_CHROMEOS)
+const char kChromeUIFileBrowseHost[] = "filebrowse";
+const char kChromeUIImageBurnerHost[] = "imageburner";
+const char kChromeUIMediaplayerHost[] = "mediaplayer";
+const char kChromeUIMobileSetupHost[] = "mobilesetup";
+const char kChromeUIRegisterPageHost[] = "register";
+const char kChromeUISlideshowHost[] = "slideshow";
+const char kChromeUISystemInfoHost[] = "system";
+#endif
+
const char kAppCacheViewInternalsURL[] = "chrome://appcache-internals/";
const char kCloudPrintResourcesURL[] = "chrome://cloudprintresources/";
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h
index b665550..5b3ce0b 100644
--- a/chrome/common/url_constants.h
+++ b/chrome/common/url_constants.h
@@ -67,21 +67,25 @@ extern const char kChromeUIDevToolsURL[];
extern const char kChromeUIDownloadsURL[];
extern const char kChromeUIExtensionsURL[];
extern const char kChromeUIFavIconURL[];
-extern const char kChromeUIFileBrowseURL[];
extern const char kChromeUIHistory2URL[];
extern const char kChromeUIHistoryURL[];
-extern const char kChromeUIImageBurnerURL[];
extern const char kChromeUIIPCURL[];
extern const char kChromeUIKeyboardURL[];
extern const char kChromeUILabsURL[];
-extern const char kChromeUIMediaplayerURL[];
extern const char kChromeUINewTabURL[];
extern const char kChromeUIPluginsURL[];
extern const char kChromeUIPrintURL[];
-extern const char kChromeUIRegisterPageURL[];
extern const char kChromeUISettingsURL[];
+
+#if defined(OS_CHROMEOS)
+extern const char kChromeUIFileBrowseURL[];
+extern const char kChromeUIImageBurnerURL[];
+extern const char kChromeUIMediaplayerURL[];
+extern const char kChromeUIMobileSetupURL[];
+extern const char kChromeUIRegisterPageURL[];
extern const char kChromeUISlideshowURL[];
extern const char kChromeUISystemInfoURL[];
+#endif
// chrome components of URLs. Should be kept in sync with the full URLs
// above.
@@ -92,30 +96,34 @@ extern const char kChromeUIDialogHost[];
extern const char kChromeUIDownloadsHost[];
extern const char kChromeUIExtensionsHost[];
extern const char kChromeUIFavIconHost[];
-extern const char kChromeUIFileBrowseHost[];
extern const char kChromeUIHistory2Host[];
extern const char kChromeUIHistoryHost[];
-extern const char kChromeUIImageBurnerHost[];
extern const char kChromeUIInspectorHost[];
extern const char kChromeUIKeyboardHost[];
extern const char kChromeUILabsHost[];
-extern const char kChromeUIMediaplayerHost[];
extern const char kChromeUINetInternalsHost[];
extern const char kChromeUINewTabHost[];
extern const char kChromeUIPluginsHost[];
extern const char kChromeUIPrintHost[];
-extern const char kChromeUIRegisterPageHost[];
extern const char kChromeUIRemotingHost[];
extern const char kChromeUIRemotingResourcesHost[];
extern const char kChromeUIResourcesHost[];
extern const char kChromeUIScreenshotPath[];
extern const char kChromeUISettingsHost[];
-extern const char kChromeUISlideshowHost[];
extern const char kChromeUISyncResourcesHost[];
-extern const char kChromeUISystemInfoHost[];
extern const char kChromeUIThemePath[];
extern const char kChromeUIThumbnailPath[];
+#if defined(OS_CHROMEOS)
+extern const char kChromeUIFileBrowseHost[];
+extern const char kChromeUIImageBurnerHost[];
+extern const char kChromeUIMediaplayerHost[];
+extern const char kChromeUIMobileSetupHost[];
+extern const char kChromeUIRegisterPageHost[];
+extern const char kChromeUISlideshowHost[];
+extern const char kChromeUISystemInfoHost[];
+#endif
+
// AppCache related URL.
extern const char kAppCacheViewInternalsURL[];
diff --git a/chrome/test/data/chromeos/mobile_activation.html b/chrome/test/data/chromeos/mobile_activation.html
new file mode 100755
index 0000000..8d44f4e
--- /dev/null
+++ b/chrome/test/data/chromeos/mobile_activation.html
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Mobile activation testing page</title>
+
+<style>
+body {
+ background: -webkit-gradient(linear, left top, left bottom,
+ from(#EBEBEB), to(#CFCFCF));
+ font-family: 'Lucida Grande', Helvetica, sans-serif;
+ font-size: 10px;
+ height: 300px;
+ overflow: hidden;
+}
+</style>
+
+<script src="connection_manager.js"></script>
+<script>
+function $(id) {
+ return document.getElementById(id);
+}
+
+chromeos.connectionManager.getDeviceInfo(function(device) {
+ $('device-info').innerHTML =
+ 'carrier = ' + device.carrier + '<br>' +
+ 'MEID = ' + device.MEID + '<br>' +
+ 'IMEI = ' + device.IMEI + '<br>' +
+ 'IMSI = ' + device.IMSI + '<br>' +
+ 'ESN = ' + device.ESN + '<br>' +
+ 'MDN = ' + device.MDN;
+});
+
+function sendStatus(status) {
+ chromeos.connectionManager.setTransactionStatus(status,
+ function() {});
+}
+
+</script>
+
+</head>
+<body>
+<h2>Plan Payment Page<h2>
+<div>Press a button below to signal transaction status back to the browser</div>
+<div id='buttons'>
+<button id='ok-btn' onclick="sendStatus('OK')">OK</button>
+<button id='fail-btn' onclick="sendStatus('FAILED')">Failed</button>
+</div>
+<div>
+Device Information:
+<div id="device-info"></div>
+</div>
+</body>
+</html>
+