| 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/chromeos/offline/offline_load_page.h" | 5 #include "chrome/browser/chromeos/offline/offline_load_page.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
| 9 #include "ash/system/tray/system_tray_delegate.h" | 9 #include "ash/system/tray/system_tray_delegate.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
| 13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/extension_system.h" | 20 #include "chrome/browser/extensions/extension_system.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/renderer_preferences_util.h" | 22 #include "chrome/browser/renderer_preferences_util.h" |
| 22 #include "chrome/browser/tab_contents/tab_util.h" | 23 #include "chrome/browser/tab_contents/tab_util.h" |
| 23 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 24 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
| 25 #include "chrome/common/extensions/extension_icon_set.h" | 26 #include "chrome/common/extensions/extension_icon_set.h" |
| 26 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | 27 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
| 27 #include "chrome/common/localized_error.h" | 28 #include "chrome/common/localized_error.h" |
| 29 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 29 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/browser/interstitial_page.h" | 32 #include "content/public/browser/interstitial_page.h" |
| 31 #include "content/public/browser/notification_types.h" | 33 #include "content/public/browser/notification_types.h" |
| 32 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 33 #include "grit/browser_resources.h" | 35 #include "grit/browser_resources.h" |
| 34 #include "grit/chromium_strings.h" | 36 #include "grit/chromium_strings.h" |
| 35 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
| 36 #include "grit/google_chrome_strings.h" | 38 #include "grit/google_chrome_strings.h" |
| 37 #include "grit/theme_resources.h" | 39 #include "grit/theme_resources.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 97 |
| 96 // Extension service does not exist in test. | 98 // Extension service does not exist in test. |
| 97 if (extensions_service) | 99 if (extensions_service) |
| 98 extension = extensions_service->extensions()->GetHostedAppByURL(url_); | 100 extension = extensions_service->extensions()->GetHostedAppByURL(url_); |
| 99 | 101 |
| 100 if (extension && !extension->from_bookmark()) { | 102 if (extension && !extension->from_bookmark()) { |
| 101 LocalizedError::GetAppErrorStrings(url_, extension, &error_strings); | 103 LocalizedError::GetAppErrorStrings(url_, extension, &error_strings); |
| 102 resource_id = IDR_OFFLINE_APP_LOAD_HTML; | 104 resource_id = IDR_OFFLINE_APP_LOAD_HTML; |
| 103 } else { | 105 } else { |
| 104 const std::string locale = g_browser_process->GetApplicationLocale(); | 106 const std::string locale = g_browser_process->GetApplicationLocale(); |
| 107 const std::string accept_languages = |
| 108 profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
| 105 LocalizedError::GetStrings(net::ERR_INTERNET_DISCONNECTED, | 109 LocalizedError::GetStrings(net::ERR_INTERNET_DISCONNECTED, |
| 106 net::kErrorDomain, url_, false, locale, | 110 net::kErrorDomain, url_, false, locale, |
| 107 &error_strings); | 111 accept_languages, &error_strings); |
| 108 resource_id = IDR_OFFLINE_NET_LOAD_HTML; | 112 resource_id = IDR_OFFLINE_NET_LOAD_HTML; |
| 109 } | 113 } |
| 110 | 114 |
| 111 const base::StringPiece template_html( | 115 const base::StringPiece template_html( |
| 112 ResourceBundle::GetSharedInstance().GetRawDataResource( | 116 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 113 resource_id)); | 117 resource_id)); |
| 114 // "t" is the id of the templates root node. | 118 // "t" is the id of the templates root node. |
| 115 return webui::GetTemplatesHtml(template_html, &error_strings, "t"); | 119 return webui::GetTemplatesHtml(template_html, &error_strings, "t"); |
| 116 } | 120 } |
| 117 | 121 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 const bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE; | 165 const bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE; |
| 162 DVLOG(1) << "ConnectionTypeObserver notification received: state=" | 166 DVLOG(1) << "ConnectionTypeObserver notification received: state=" |
| 163 << (online ? "online" : "offline"); | 167 << (online ? "online" : "offline"); |
| 164 if (online) { | 168 if (online) { |
| 165 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 169 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
| 166 interstitial_page_->Proceed(); | 170 interstitial_page_->Proceed(); |
| 167 } | 171 } |
| 168 } | 172 } |
| 169 | 173 |
| 170 } // namespace chromeos | 174 } // namespace chromeos |
| OLD | NEW |