OLD | NEW |
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 |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/chromeos/cros/cros_library.h" | 25 #include "chrome/browser/chromeos/cros/cros_library.h" |
26 #include "chrome/browser/chromeos/cros/network_library.h" | 26 #include "chrome/browser/chromeos/cros/network_library.h" |
27 #include "chrome/browser/prefs/pref_service.h" | 27 #include "chrome/browser/prefs/pref_service.h" |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/ui/browser_list.h" | 29 #include "chrome/browser/ui/browser_list.h" |
30 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 30 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
31 #include "chrome/common/jstemplate_builder.h" | 31 #include "chrome/common/jstemplate_builder.h" |
32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
33 #include "chrome/common/render_messages.h" | 33 #include "chrome/common/render_messages.h" |
34 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
| 35 #include "content/browser/webui/web_ui.h" |
35 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
36 #include "content/public/browser/render_view_host_observer.h" | 37 #include "content/public/browser/render_view_host_observer.h" |
37 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
38 #include "content/public/browser/web_ui_message_handler.h" | 39 #include "content/public/browser/web_ui_message_handler.h" |
39 #include "googleurl/src/gurl.h" | 40 #include "googleurl/src/gurl.h" |
40 #include "grit/browser_resources.h" | 41 #include "grit/browser_resources.h" |
41 #include "grit/chromium_strings.h" | 42 #include "grit/chromium_strings.h" |
42 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
43 #include "grit/locale_settings.h" | 44 #include "grit/locale_settings.h" |
44 #include "ui/base/l10n/l10n_util.h" | 45 #include "ui/base/l10n/l10n_util.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 IPC_END_MESSAGE_MAP() | 150 IPC_END_MESSAGE_MAP() |
150 return handled; | 151 return handled; |
151 } | 152 } |
152 | 153 |
153 private: | 154 private: |
154 void OnFrameLoadError(int error) { | 155 void OnFrameLoadError(int error) { |
155 if (!parent_.get()) | 156 if (!parent_.get()) |
156 return; | 157 return; |
157 | 158 |
158 base::FundamentalValue result_value(error); | 159 base::FundamentalValue result_value(error); |
159 parent_->CallJavascriptFunction(kJsPortalFrameLoadFailedCallback, | 160 parent_->web_ui()->CallJavascriptFunction(kJsPortalFrameLoadFailedCallback, |
160 result_value); | 161 result_value); |
161 } | 162 } |
162 | 163 |
163 void OnFrameLoadCompleted() { | 164 void OnFrameLoadCompleted() { |
164 if (!parent_.get()) | 165 if (!parent_.get()) |
165 return; | 166 return; |
166 | 167 |
167 parent_->CallJavascriptFunction(kJsPortalFrameLoadCompletedCallback); | 168 parent_->web_ui()->CallJavascriptFunction( |
| 169 kJsPortalFrameLoadCompletedCallback); |
168 } | 170 } |
169 | 171 |
170 base::WeakPtr<MobileSetupUI> parent_; | 172 base::WeakPtr<MobileSetupUI> parent_; |
171 DISALLOW_COPY_AND_ASSIGN(PortalFrameLoadObserver); | 173 DISALLOW_COPY_AND_ASSIGN(PortalFrameLoadObserver); |
172 }; | 174 }; |
173 | 175 |
174 class CellularConfigDocument | 176 class CellularConfigDocument |
175 : public base::RefCountedThreadSafe<CellularConfigDocument> { | 177 : public base::RefCountedThreadSafe<CellularConfigDocument> { |
176 public: | 178 public: |
177 CellularConfigDocument() {} | 179 CellularConfigDocument() {} |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 | 1384 |
1383 StartActivation(); | 1385 StartActivation(); |
1384 } | 1386 } |
1385 | 1387 |
1386 //////////////////////////////////////////////////////////////////////////////// | 1388 //////////////////////////////////////////////////////////////////////////////// |
1387 // | 1389 // |
1388 // MobileSetupUI | 1390 // MobileSetupUI |
1389 // | 1391 // |
1390 //////////////////////////////////////////////////////////////////////////////// | 1392 //////////////////////////////////////////////////////////////////////////////// |
1391 | 1393 |
1392 MobileSetupUI::MobileSetupUI(WebContents* contents) | 1394 MobileSetupUI::MobileSetupUI(WebUI* web_ui) |
1393 : WebUI(contents, this), | 1395 : WebUIController(web_ui), |
1394 frame_load_observer_(NULL) { | 1396 frame_load_observer_(NULL) { |
1395 chromeos::CellularNetwork* network = GetCellularNetwork(); | 1397 chromeos::CellularNetwork* network = GetCellularNetwork(); |
1396 std::string service_path = network ? network->service_path() : std::string(); | 1398 std::string service_path = network ? network->service_path() : std::string(); |
1397 AddMessageHandler(new MobileSetupHandler(service_path)); | 1399 web_ui->AddMessageHandler(new MobileSetupHandler(service_path)); |
1398 MobileSetupUIHTMLSource* html_source = | 1400 MobileSetupUIHTMLSource* html_source = |
1399 new MobileSetupUIHTMLSource(service_path); | 1401 new MobileSetupUIHTMLSource(service_path); |
1400 | 1402 |
1401 // Set up the chrome://mobilesetup/ source. | 1403 // Set up the chrome://mobilesetup/ source. |
1402 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 1404 Profile* profile = Profile::FromBrowserContext( |
| 1405 web_ui->web_contents()->GetBrowserContext()); |
1403 profile->GetChromeURLDataManager()->AddDataSource(html_source); | 1406 profile->GetChromeURLDataManager()->AddDataSource(html_source); |
1404 } | 1407 } |
1405 | 1408 |
1406 void MobileSetupUI::RenderViewCreated(RenderViewHost* host) { | 1409 void MobileSetupUI::RenderViewCreated(RenderViewHost* host) { |
1407 // Destroyed by the corresponding RenderViewHost. | 1410 // Destroyed by the corresponding RenderViewHost. |
1408 frame_load_observer_ = | 1411 frame_load_observer_ = |
1409 new PortalFrameLoadObserver(AsWeakPtr(), host); | 1412 new PortalFrameLoadObserver(AsWeakPtr(), host); |
1410 } | 1413 } |
OLD | NEW |