Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc

Issue 10832148: Send e-mail to the verizon portal. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/chromeos/mobile_setup_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/mobile_setup_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/ref_counted_memory.h" 16 #include "base/memory/ref_counted_memory.h"
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
19 #include "base/string_piece.h" 19 #include "base/string_piece.h"
20 #include "base/string_util.h" 20 #include "base/string_util.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #include "base/values.h" 22 #include "base/values.h"
23 #include "chrome/browser/chromeos/cros/cros_library.h" 23 #include "chrome/browser/chromeos/cros/cros_library.h"
24 #include "chrome/browser/chromeos/cros/network_library.h" 24 #include "chrome/browser/chromeos/cros/network_library.h"
25 #include "chrome/browser/chromeos/login/user_manager.h"
25 #include "chrome/browser/chromeos/mobile/mobile_activator.h" 26 #include "chrome/browser/chromeos/mobile/mobile_activator.h"
26 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/ui/browser_list.h" 28 #include "chrome/browser/ui/browser_list.h"
28 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 29 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
29 #include "chrome/common/jstemplate_builder.h" 30 #include "chrome/common/jstemplate_builder.h"
30 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
31 #include "chrome/common/render_messages.h" 32 #include "chrome/common/render_messages.h"
32 #include "chrome/common/url_constants.h" 33 #include "chrome/common/url_constants.h"
33 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/render_view_host_observer.h" 35 #include "content/public/browser/render_view_host_observer.h"
35 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
36 #include "content/public/browser/web_ui.h" 37 #include "content/public/browser/web_ui.h"
37 #include "content/public/browser/web_ui_message_handler.h" 38 #include "content/public/browser/web_ui_message_handler.h"
38 #include "googleurl/src/gurl.h" 39 #include "googleurl/src/gurl.h"
40 #include "googleurl/src/url_util.h"
39 #include "grit/browser_resources.h" 41 #include "grit/browser_resources.h"
40 #include "grit/chromium_strings.h" 42 #include "grit/chromium_strings.h"
41 #include "grit/generated_resources.h" 43 #include "grit/generated_resources.h"
42 #include "grit/locale_settings.h" 44 #include "grit/locale_settings.h"
43 #include "ui/base/l10n/l10n_util.h" 45 #include "ui/base/l10n/l10n_util.h"
44 #include "ui/base/layout.h" 46 #include "ui/base/layout.h"
45 #include "ui/base/resource/resource_bundle.h" 47 #include "ui/base/resource/resource_bundle.h"
46 48
47 using chromeos::CellularNetwork; 49 using chromeos::CellularNetwork;
48 using chromeos::CrosLibrary; 50 using chromeos::CrosLibrary;
(...skipping 11 matching lines...) Expand all
60 const char kJsApiPaymentPortalLoad[] = "paymentPortalLoad"; 62 const char kJsApiPaymentPortalLoad[] = "paymentPortalLoad";
61 const char kJsApiResultOK[] = "ok"; 63 const char kJsApiResultOK[] = "ok";
62 64
63 const char kJsDeviceStatusChangedCallback[] = 65 const char kJsDeviceStatusChangedCallback[] =
64 "mobile.MobileSetup.deviceStateChanged"; 66 "mobile.MobileSetup.deviceStateChanged";
65 const char kJsPortalFrameLoadFailedCallback[] = 67 const char kJsPortalFrameLoadFailedCallback[] =
66 "mobile.MobileSetup.portalFrameLoadError"; 68 "mobile.MobileSetup.portalFrameLoadError";
67 const char kJsPortalFrameLoadCompletedCallback[] = 69 const char kJsPortalFrameLoadCompletedCallback[] =
68 "mobile.MobileSetup.portalFrameLoadCompleted"; 70 "mobile.MobileSetup.portalFrameLoadCompleted";
69 71
72 const char kEmailParam[] = "&email=";
73
70 } // namespace 74 } // namespace
71 75
72 // Observes IPC messages from the rederer and notifies JS if frame loading error 76 // Observes IPC messages from the rederer and notifies JS if frame loading error
73 // appears. 77 // appears.
74 class PortalFrameLoadObserver : public content::RenderViewHostObserver { 78 class PortalFrameLoadObserver : public content::RenderViewHostObserver {
75 public: 79 public:
76 PortalFrameLoadObserver(const base::WeakPtr<MobileSetupUI>& parent, 80 PortalFrameLoadObserver(const base::WeakPtr<MobileSetupUI>& parent,
77 RenderViewHost* host) 81 RenderViewHost* host)
78 : content::RenderViewHostObserver(host), parent_(parent) { 82 : content::RenderViewHostObserver(host), parent_(parent) {
79 Send(new ChromeViewMsg_StartFrameSniffer(routing_id(), 83 Send(new ChromeViewMsg_StartFrameSniffer(routing_id(),
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 311
308 void MobileSetupHandler::GetDeviceInfo(CellularNetwork* network, 312 void MobileSetupHandler::GetDeviceInfo(CellularNetwork* network,
309 DictionaryValue* value) { 313 DictionaryValue* value) {
310 DCHECK(network); 314 DCHECK(network);
311 chromeos::NetworkLibrary* cros = 315 chromeos::NetworkLibrary* cros =
312 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); 316 chromeos::CrosLibrary::Get()->GetNetworkLibrary();
313 if (!cros) 317 if (!cros)
314 return; 318 return;
315 value->SetString("carrier", network->name()); 319 value->SetString("carrier", network->name());
316 value->SetString("payment_url", network->payment_url()); 320 value->SetString("payment_url", network->payment_url());
317 if (network->using_post() && network->post_data().length()) 321 if (network->using_post() && network->post_data().length()) {
318 value->SetString("post_data", network->post_data()); 322 std::string post_data = network->post_data();
323 // Append the current e-mail address to the post data to allow Verizon
324 // to pre-populate it on their form.
325 chromeos::UserManager* manager = chromeos::UserManager::Get();
326 if (manager->IsUserLoggedIn()) {
327 url_canon::RawCanonOutputT<char> output;
328 std::string email = manager->GetLoggedInUser().display_email();
329 url_util::EncodeURIComponent(email.c_str(), email.length(), &output);
330 std::string escaped_email(output.data(), output.length());
331
332 post_data.append(kEmailParam).append(escaped_email);
333 }
334
335 value->SetString("post_data", post_data);
336 }
319 337
320 const chromeos::NetworkDevice* device = 338 const chromeos::NetworkDevice* device =
321 cros->FindNetworkDeviceByPath(network->device_path()); 339 cros->FindNetworkDeviceByPath(network->device_path());
322 if (device) { 340 if (device) {
323 value->SetString("MEID", device->meid()); 341 value->SetString("MEID", device->meid());
324 value->SetString("IMEI", device->imei()); 342 value->SetString("IMEI", device->imei());
325 value->SetString("MDN", device->mdn()); 343 value->SetString("MDN", device->mdn());
326 } 344 }
327 } 345 }
328 346
(...skipping 10 matching lines...) Expand all
339 357
340 // Set up the chrome://mobilesetup/ source. 358 // Set up the chrome://mobilesetup/ source.
341 Profile* profile = Profile::FromWebUI(web_ui); 359 Profile* profile = Profile::FromWebUI(web_ui);
342 ChromeURLDataManager::AddDataSource(profile, html_source); 360 ChromeURLDataManager::AddDataSource(profile, html_source);
343 } 361 }
344 362
345 void MobileSetupUI::RenderViewCreated(RenderViewHost* host) { 363 void MobileSetupUI::RenderViewCreated(RenderViewHost* host) {
346 // Destroyed by the corresponding RenderViewHost 364 // Destroyed by the corresponding RenderViewHost
347 new PortalFrameLoadObserver(AsWeakPtr(), host); 365 new PortalFrameLoadObserver(AsWeakPtr(), host);
348 } 366 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698