diff options
author | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-07 19:53:24 +0000 |
---|---|---|
committer | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-07 19:53:24 +0000 |
commit | 02f91a77225e01e8d737ab33e93c14a6fda1630b (patch) | |
tree | f938362dc8e6c9d237486cdf38d3ab0dbdd03bc8 | |
parent | 2052778b5be7bfd53d702a4e6e1615dc23f3acc5 (diff) | |
download | chromium_src-02f91a77225e01e8d737ab33e93c14a6fda1630b.zip chromium_src-02f91a77225e01e8d737ab33e93c14a6fda1630b.tar.gz chromium_src-02f91a77225e01e8d737ab33e93c14a6fda1630b.tar.bz2 |
Add link to activate verizon in offline page.
This CL also update the page itself to match new mock from kenmoore.
Fix a crash when reloading offline page. It calls DontProceed when reloaded, so I shouldn't have Release reference on OnRequestClosed.
There are a couple of difference between the page and mock and will continue working on it for R12, but this should be good enough for R11. (or we can do minor update in the branch)
BUG=chromium-os:12286
TEST=manual: on chromeos, disconnect network and load www.google.com. Offline page now has a link to activate verizon 3g.
Review URL: http://codereview.chromium.org/6625020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77172 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 22 | ||||
-rw-r--r-- | chrome/browser/chromeos/offline/offline_load_page.cc | 37 | ||||
-rw-r--r-- | chrome/browser/chromeos/offline/offline_load_page.h | 4 | ||||
-rw-r--r-- | chrome/browser/renderer_host/offline_resource_handler.cc | 12 | ||||
-rw-r--r-- | chrome/browser/renderer_host/offline_resource_handler.h | 3 | ||||
-rw-r--r-- | chrome/browser/resources/activate_broadband_info.png | bin | 0 -> 1751 bytes | |||
-rw-r--r-- | chrome/browser/resources/offline_load.html | 141 |
7 files changed, 147 insertions, 72 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 929c73d..6dbf1e3 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -7791,24 +7791,28 @@ Keep your key file in a safe place. You will need it to create new versions of y <!-- Offline page --> <if expr="pp_ifdef('chromeos')"> <message name="IDS_OFFLINE_LOAD_HEADLINE" desc="Offline Page HTML headline"> - Your device is offline. + Your device is offline </message> <message name="IDS_SITE_OFFLINE_LOAD_DESCRIPTION" desc="offline site"> The webpage at <ph name="HOST_NAME"><strong>$1<ex>www.offline.com</ex></strong></ph> cannot be reached because your network connection is down. The page will be loaded when the network connection is restored. <br> - Try reconnecting, connecting to another network or proceeding with loading anyway. </message> <message name="IDS_APP_OFFLINE_LOAD_DESCRIPTION" desc="offline app"> The app at <ph name="HOST_NAME"><strong>$1<ex>www.offline.com</ex></strong></ph> cannot be reached because your network connection is down. The page will be loaded when the network connection is restored. <br> - Try reconnecting, connecting to another network or proceeding with loading anyway. </message> - <message name="IDS_OFFLINE_LOAD_BUTTON"> - Load Anyway - </message> - <message name="IDS_OFFLINE_CANCEL_BUTTON"> - Cancel + <message name="IDS_OFFLINE_TRY_LOADING"> + Try loading the page anyway </message> <message name="IDS_OFFLINE_NETWORK_SETTINGS"> - Network Settings ... + Network settings + </message> + <message name="IDS_OFFLINE_ACTIVATION_HEADLINE"> + Free Data from Verizon Wireless + </message> + <message name="IDS_OFFLINE_ACTIVATION_MESSAGE"> + As a Cr-48 pilot user you get 100MB free from Verizon Wireless every 30 days for 2 years. Just sign up and you're online! + </message> + <message name="IDS_OFFLINE_ACTIVATION_BUTTON"> + Connect to Verizon Wireless </message> </if> diff --git a/chrome/browser/chromeos/offline/offline_load_page.cc b/chrome/browser/chromeos/offline/offline_load_page.cc index e9457b8..5e95496 100644 --- a/chrome/browser/chromeos/offline/offline_load_page.cc +++ b/chrome/browser/chromeos/offline/offline_load_page.cc @@ -15,6 +15,8 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/chromeos/cros/cros_library.h" +#include "chrome/browser/chromeos/cros/network_library.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/notification_service.h" @@ -75,10 +77,6 @@ OfflineLoadPage::OfflineLoadPage(TabContents* tab_contents, std::string OfflineLoadPage::GetHTMLContents() { DictionaryValue strings; - // Toggle Cancel button. - strings.SetString("display_cancel", - tab()->controller().CanGoBack() ? "inline" : "none"); - int64 time_to_wait = std::max( static_cast<int64>(0), kMaxBlankPeriod - @@ -86,12 +84,17 @@ std::string OfflineLoadPage::GetHTMLContents() { // Set the timeout to show the page. strings.SetInteger("timeToWait", static_cast<int>(time_to_wait)); // Button labels - SetString(&strings, "load_button", IDS_OFFLINE_LOAD_BUTTON); - SetString(&strings, "cancel_button", IDS_OFFLINE_CANCEL_BUTTON); - SetString(&strings, "heading", IDS_OFFLINE_LOAD_HEADLINE); + SetString(&strings, "try_loading", IDS_OFFLINE_TRY_LOADING); SetString(&strings, "network_settings", IDS_OFFLINE_NETWORK_SETTINGS); + // Activation + SetString(&strings, "activation_heading", IDS_OFFLINE_ACTIVATION_HEADLINE); + SetString(&strings, "activation_msg", IDS_OFFLINE_ACTIVATION_MESSAGE); + SetString(&strings, "activation_button", IDS_OFFLINE_ACTIVATION_BUTTON); + strings.SetString("display_activation", + ShowActivationMessage() ? "block" : "none"); + bool rtl = base::i18n::IsRTL(); strings.SetString("textdirection", rtl ? "rtl" : "ltr"); @@ -173,6 +176,10 @@ void OfflineLoadPage::CommandReceived(const std::string& cmd) { Browser* browser = BrowserList::GetLastActive(); DCHECK(browser); browser->ShowOptionsTab(chrome::kInternetOptionsSubPage); + } else if (command == "open_activate_broadband") { + Browser* browser = BrowserList::GetLastActive(); + DCHECK(browser); + browser->OpenMobilePlanTabAndActivate(); } else { LOG(WARNING) << "Unknown command:" << cmd; } @@ -212,4 +219,20 @@ void OfflineLoadPage::Observe(NotificationType type, } } +bool OfflineLoadPage::ShowActivationMessage() { + CrosLibrary* cros = CrosLibrary::Get(); + if (!cros || !cros->GetNetworkLibrary()->cellular_available()) + return false; + + const CellularNetworkVector& cell_networks = + cros->GetNetworkLibrary()->cellular_networks(); + for (size_t i = 0; i < cell_networks.size(); ++i) { + chromeos::ActivationState activation_state = + cell_networks[i]->activation_state(); + if (activation_state == ACTIVATION_STATE_ACTIVATED) + return false; + } + return true; +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/offline/offline_load_page.h b/chrome/browser/chromeos/offline/offline_load_page.h index 1223a52..bf70d4d 100644 --- a/chrome/browser/chromeos/offline/offline_load_page.h +++ b/chrome/browser/chromeos/offline/offline_load_page.h @@ -73,6 +73,10 @@ class OfflineLoadPage : public InterstitialPage { void GetNormalOfflineStrings(const string16& faield_url, DictionaryValue* strings) const; + // True if there is a mobile network is available but + // has not been activated. + bool ShowActivationMessage(); + Delegate* delegate_; NotificationRegistrar registrar_; diff --git a/chrome/browser/renderer_host/offline_resource_handler.cc b/chrome/browser/renderer_host/offline_resource_handler.cc index 19f5aee..f7e13d3 100644 --- a/chrome/browser/renderer_host/offline_resource_handler.cc +++ b/chrome/browser/renderer_host/offline_resource_handler.cc @@ -32,8 +32,7 @@ OfflineResourceHandler::OfflineResourceHandler( render_view_id_(route_id), rdh_(rdh), request_(request), - deferred_request_id_(-1), - offline_page_shown_(false) { + deferred_request_id_(-1) { } OfflineResourceHandler::~OfflineResourceHandler() { @@ -71,11 +70,6 @@ void OfflineResourceHandler::OnRequestClosed() { appcache_completion_callback_->Cancel(); appcache_completion_callback_.release(); Release(); // Balanced with OnWillStart - } else if (offline_page_shown_) { - offline_page_shown_ = false; - // Interstitial page is already closed, so we need - // |Release| to balance with OnWillStart. - Release(); } next_handler_->OnRequestClosed(); } @@ -94,7 +88,6 @@ void OfflineResourceHandler::OnCanHandleOfflineComplete(int rv) { Release(); // Balanced with OnWillStart } else { // Skipping AddRef/Release because they're redundant. - offline_page_shown_ = true; BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, NewRunnableMethod(this, &OfflineResourceHandler::ShowOfflinePage)); @@ -150,9 +143,6 @@ void OfflineResourceHandler::OnBlockingPageComplete(bool proceed) { NOTREACHED(); return; } - DCHECK(offline_page_shown_); - offline_page_shown_ = false; - if (proceed) { Resume(); } else { diff --git a/chrome/browser/renderer_host/offline_resource_handler.h b/chrome/browser/renderer_host/offline_resource_handler.h index 33e4549..6fa17a0 100644 --- a/chrome/browser/renderer_host/offline_resource_handler.h +++ b/chrome/browser/renderer_host/offline_resource_handler.h @@ -76,9 +76,6 @@ class OfflineResourceHandler : public ResourceHandler, int deferred_request_id_; GURL deferred_url_; - // If the offline page has been requested to show. - bool offline_page_shown_; - scoped_refptr<net::CancelableCompletionCallback<OfflineResourceHandler> > appcache_completion_callback_; diff --git a/chrome/browser/resources/activate_broadband_info.png b/chrome/browser/resources/activate_broadband_info.png Binary files differnew file mode 100644 index 0000000..07a9f43 --- /dev/null +++ b/chrome/browser/resources/activate_broadband_info.png diff --git a/chrome/browser/resources/offline_load.html b/chrome/browser/resources/offline_load.html index 9a06022..0a03c45 100644 --- a/chrome/browser/resources/offline_load.html +++ b/chrome/browser/resources/offline_load.html @@ -8,6 +8,7 @@ html { height: 100%; } body { + border: green 1px solid; color: #000; font-family: Helvetica, Arial, sans-serif; background-image: -webkit-linear-gradient(white 50%, rgb(236, 244, 255)); @@ -15,38 +16,84 @@ body { padding: 0; margin: 0; display: -webkit-box; - -webkit-box-orient: horizontal; + -webkit-box-orient: vertical; -webkit-box-pack: center; - visibility: hidden; + -webkit-box-align: center; +} + +.upper { + width: 60%; + height: 50%; } -#error { - margin-top: 150px; - font-size: 16px; +.upper_main { + position: relative; + width: 100%; + bottom: -35%; +} + +.lower { + height: 50%; + width: 100%; display: -webkit-box; - width : 800px; - max-width: 80%; + -webkit-box-pack: center; -webkit-box-orient: horizontal; } -#error img { - vertical-align: middle; - width: 96px; - height: 96px; - -webkit-margin-end: 10px; - -webkit-box-flex: 0; +.lower_left { + height: 100%; + width: 24%; + background-image: -webkit-linear-gradient(-100deg, rgb(230, 230, 230), rgb(230, 230, 230) 3px, rgb(240, 240, 240) 3px, rgba(240, 240, 240, 0) 20%); +} + +.lower_right { + height: 100%; + width: 24%; + background-image: -webkit-linear-gradient(-80deg, rgb(230, 230, 230), rgb(230, 230, 230) 3px, rgb(240, 240, 240) 3px, rgba(240, 240, 240, 0) 20%); +} + +.lower_main { + position: relative; + height: 100%; + width: 50%; + padding-top: 20px; + background-image: -webkit-linear-gradient(rgb(230, 230, 230), rgb(230, 230, 230) 3px, rgb(240, 240, 240) 3px, rgba(240, 240, 240, 0) 20%); } -#error #msg_box { - vertical-align: middle; - -webkit-box-flex: 1; +.icon { + float: left; + margin: 15px; + overflow: visible; +} + +.title { + float: left; + height: 10%; + width: 80%; + font-family: Sans-serif; + font-size: 120%; + font-weight: bold; + padding: 3px; +} + +.message { + float: left; + margin-top: 10px; +} + +.link { + float: left; + clear: both; + padding: 3px; +} + +.activation_button { + float: left; + clear both; } </style> -<script src="shared/js/local_strings.js"></script> <script> -var localStrings = new LocalStrings(); - function sendCommand(cmd) { window.domAutomationController.setAutomationId(1); window.domAutomationController.send(cmd); @@ -55,32 +102,42 @@ function sendCommand(cmd) { function showPage() { document.body.style.visibility = 'visible'; } -document.addEventListener('DOMContentLoaded', function() { - var timeToWait = localStrings.getString('timeToWait'); - window.setTimeout(showPage, timeToWait); -}); +// Start the timer to show the page. +function startTimer(time) { + // wait 2.5 seconds before showing 'load now', 'go back' button. + setTimeout('showPage()', time); +} </script> -</head> <body oncontextmenu="return false;"> -<div id="error" i18n-values=".title:url"> - <img i18n-values=".src:icon;.style.display:display_icon"> - <div id="msg_box"> - <h3 i18n-content="heading"></h3> - <div id="msg" i18n-values=".innerHTML:msg"></div> - - <button id="continue_button" i18n-content="load_button" - onclick="sendCommand('proceed')"> - </button> - <button id="cancel_button" i18n-content="cancel_button" - i18n-values=".style.display:display_cancel" - onclick="sendCommand('dontproceed')"> - </button> - <a href="chrome://settings/internet" - onclick="sendCommand('open_network_settings')" - i18n-content="network_settings"> - </a> + <div class="upper" i18n-values=".title:url"> + <div class="upper_main"> + <div class="icon" i18n-values=".src:icon;.style.display:display_icon"></div> + <div class="title" i18n-content="heading"> </div> + <div class="message" i18n-values=".innerHTML:msg"> </div> + <div class="link"><a href="chrome://settings/internet" + onclick="sendCommand('proceed')" + i18n-content="try_loading"> + </a> </div> + <div class="link"> + <a href="chrome://settings/internet" + onclick="sendCommand('open_network_settings')" + i18n-content="network_settings"> + </a> + </div> + </div> + </div> + <div class="lower" i18n-values=".style.display:display_activation"> + <div class="lower_left"> </div> + <div class="lower_main"> + <img class="icon" src="activate_broadband_info.png"></img> + <div class="title" i18n-content="activation_heading"></div> + <div class="message" i18n-content="activation_msg"></div> + <button class="activation_button" i18n-content="activation_button" + onclick="sendCommand('open_activate_broadband')"> + </button> + </div> + <div class="lower_right"> </div> </div> -</div> </body> </html> |