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

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

Issue 2659753002: Convert MobileSetupUI to use the new navigation callbacks. (Closed)
Patch Set: nit Created 3 years, 11 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
« no previous file with comments | « chrome/browser/ui/webui/chromeos/mobile_setup_ui.h ('k') | 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 22 matching lines...) Expand all
33 #include "chrome/grit/generated_resources.h" 33 #include "chrome/grit/generated_resources.h"
34 #include "chrome/grit/locale_settings.h" 34 #include "chrome/grit/locale_settings.h"
35 #include "chromeos/network/device_state.h" 35 #include "chromeos/network/device_state.h"
36 #include "chromeos/network/network_configuration_handler.h" 36 #include "chromeos/network/network_configuration_handler.h"
37 #include "chromeos/network/network_event_log.h" 37 #include "chromeos/network/network_event_log.h"
38 #include "chromeos/network/network_state.h" 38 #include "chromeos/network/network_state.h"
39 #include "chromeos/network/network_state_handler.h" 39 #include "chromeos/network/network_state_handler.h"
40 #include "chromeos/network/network_state_handler_observer.h" 40 #include "chromeos/network/network_state_handler_observer.h"
41 #include "components/strings/grit/components_strings.h" 41 #include "components/strings/grit/components_strings.h"
42 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
43 #include "content/public/browser/navigation_handle.h"
43 #include "content/public/browser/render_frame_host.h" 44 #include "content/public/browser/render_frame_host.h"
44 #include "content/public/browser/url_data_source.h" 45 #include "content/public/browser/url_data_source.h"
45 #include "content/public/browser/web_contents.h" 46 #include "content/public/browser/web_contents.h"
46 #include "content/public/browser/web_ui.h" 47 #include "content/public/browser/web_ui.h"
47 #include "content/public/browser/web_ui_message_handler.h" 48 #include "content/public/browser/web_ui_message_handler.h"
48 #include "third_party/cros_system_api/dbus/service_constants.h" 49 #include "third_party/cros_system_api/dbus/service_constants.h"
49 #include "ui/base/l10n/l10n_util.h" 50 #include "ui/base/l10n/l10n_util.h"
50 #include "ui/base/resource/resource_bundle.h" 51 #include "ui/base/resource/resource_bundle.h"
51 #include "ui/base/webui/jstemplate_builder.h" 52 #include "ui/base/webui/jstemplate_builder.h"
52 #include "ui/base/webui/web_ui_util.h" 53 #include "ui/base/webui/web_ui_util.h"
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 web_ui->AddMessageHandler(base::MakeUnique<MobileSetupHandler>()); 622 web_ui->AddMessageHandler(base::MakeUnique<MobileSetupHandler>());
622 MobileSetupUIHTMLSource* html_source = new MobileSetupUIHTMLSource(); 623 MobileSetupUIHTMLSource* html_source = new MobileSetupUIHTMLSource();
623 624
624 // Set up the chrome://mobilesetup/ source. 625 // Set up the chrome://mobilesetup/ source.
625 Profile* profile = Profile::FromWebUI(web_ui); 626 Profile* profile = Profile::FromWebUI(web_ui);
626 content::URLDataSource::Add(profile, html_source); 627 content::URLDataSource::Add(profile, html_source);
627 628
628 content::WebContentsObserver::Observe(web_ui->GetWebContents()); 629 content::WebContentsObserver::Observe(web_ui->GetWebContents());
629 } 630 }
630 631
631 void MobileSetupUI::DidCommitProvisionalLoadForFrame( 632 void MobileSetupUI::DidFinishNavigation(
632 content::RenderFrameHost* render_frame_host, 633 content::NavigationHandle* navigation_handle) {
633 const GURL& url, 634 if (!navigation_handle->HasCommitted() ||
634 ui::PageTransition transition_type) { 635 navigation_handle->GetRenderFrameHost()->GetFrameName() !=
635 if (render_frame_host->GetFrameName() != "paymentForm") 636 "paymentForm") {
636 return; 637 return;
638 }
639
640 if (navigation_handle->IsErrorPage()) {
641 base::FundamentalValue result_value(-navigation_handle->GetNetErrorCode());
642 web_ui()->CallJavascriptFunctionUnsafe(kJsPortalFrameLoadFailedCallback,
643 result_value);
644 return;
645 }
637 646
638 web_ui()->CallJavascriptFunctionUnsafe(kJsPortalFrameLoadCompletedCallback); 647 web_ui()->CallJavascriptFunctionUnsafe(kJsPortalFrameLoadCompletedCallback);
639 } 648 }
640
641 void MobileSetupUI::DidFailProvisionalLoad(
642 content::RenderFrameHost* render_frame_host,
643 const GURL& validated_url,
644 int error_code,
645 const base::string16& error_description,
646 bool was_ignored_by_handler) {
647 if (render_frame_host->GetFrameName() != "paymentForm")
648 return;
649
650 base::FundamentalValue result_value(-error_code);
651 web_ui()->CallJavascriptFunctionUnsafe(kJsPortalFrameLoadFailedCallback,
652 result_value);
653 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/mobile_setup_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698