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

Side by Side Diff: chrome/browser/chromeos/offline/offline_load_page.cc

Issue 349073004: Cleanup: Remove deprecated Profile::GetExtensionService(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 6 years, 5 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
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/chromeos/offline/offline_load_page.h" 5 #include "chrome/browser/chromeos/offline/offline_load_page.h"
6 6
7 #include "apps/launcher.h" 7 #include "apps/launcher.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_delegate.h" 9 #include "ash/shell_delegate.h"
10 #include "ash/system/tray/system_tray_delegate.h" 10 #include "ash/system/tray/system_tray_delegate.h"
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/renderer_preferences_util.h" 21 #include "chrome/browser/renderer_preferences_util.h"
23 #include "chrome/browser/tab_contents/tab_util.h" 22 #include "chrome/browser/tab_contents/tab_util.h"
24 #include "chrome/common/extensions/extension_constants.h" 23 #include "chrome/common/extensions/extension_constants.h"
25 #include "chrome/common/localized_error.h" 24 #include "chrome/common/localized_error.h"
26 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
28 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/interstitial_page.h" 28 #include "content/public/browser/interstitial_page.h"
30 #include "content/public/browser/notification_types.h" 29 #include "content/public/browser/notification_types.h"
31 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "extensions/browser/extension_registry.h"
32 #include "extensions/browser/extension_system.h" 32 #include "extensions/browser/extension_system.h"
33 #include "extensions/common/extension.h" 33 #include "extensions/common/extension.h"
34 #include "extensions/common/extension_icon_set.h" 34 #include "extensions/common/extension_icon_set.h"
35 #include "extensions/common/manifest_handlers/icons_handler.h" 35 #include "extensions/common/manifest_handlers/icons_handler.h"
36 #include "grit/browser_resources.h" 36 #include "grit/browser_resources.h"
37 #include "grit/chromium_strings.h" 37 #include "grit/chromium_strings.h"
38 #include "grit/generated_resources.h" 38 #include "grit/generated_resources.h"
39 #include "grit/google_chrome_strings.h" 39 #include "grit/google_chrome_strings.h"
40 #include "grit/theme_resources.h" 40 #include "grit/theme_resources.h"
41 #include "net/base/escape.h" 41 #include "net/base/escape.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 std::string OfflineLoadPage::GetHTMLContents() { 74 std::string OfflineLoadPage::GetHTMLContents() {
75 // Use a local error page. 75 // Use a local error page.
76 int resource_id; 76 int resource_id;
77 base::DictionaryValue error_strings; 77 base::DictionaryValue error_strings;
78 78
79 // The offline page for app has icons and slightly different message. 79 // The offline page for app has icons and slightly different message.
80 Profile* profile = Profile::FromBrowserContext( 80 Profile* profile = Profile::FromBrowserContext(
81 web_contents_->GetBrowserContext()); 81 web_contents_->GetBrowserContext());
82 DCHECK(profile); 82 DCHECK(profile);
83 const extensions::Extension* extension = NULL; 83 const extensions::Extension* extension = extensions::ExtensionRegistry::Get(
84 ExtensionService* extensions_service = 84 profile)->enabled_extensions().GetHostedAppByURL(url_);
85 extensions::ExtensionSystem::Get(profile)->extension_service();
86
87 // Extension service does not exist in test.
88 if (extensions_service)
89 extension = extensions_service->extensions()->GetHostedAppByURL(url_);
90
91 if (extension && !extension->from_bookmark()) { 85 if (extension && !extension->from_bookmark()) {
92 LocalizedError::GetAppErrorStrings(url_, extension, &error_strings); 86 LocalizedError::GetAppErrorStrings(url_, extension, &error_strings);
93 resource_id = IDR_OFFLINE_APP_LOAD_HTML; 87 resource_id = IDR_OFFLINE_APP_LOAD_HTML;
94 } else { 88 } else {
95 const std::string locale = g_browser_process->GetApplicationLocale(); 89 const std::string locale = g_browser_process->GetApplicationLocale();
96 const std::string accept_languages = 90 const std::string accept_languages =
97 profile->GetPrefs()->GetString(prefs::kAcceptLanguages); 91 profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
98 LocalizedError::GetStrings(net::ERR_INTERNET_DISCONNECTED, 92 LocalizedError::GetStrings(net::ERR_INTERNET_DISCONNECTED,
99 net::kErrorDomain, url_, false, false, locale, 93 net::kErrorDomain, url_, false, false, locale,
100 accept_languages, 94 accept_languages,
101 scoped_ptr<LocalizedError::ErrorPageParams>(), 95 scoped_ptr<LocalizedError::ErrorPageParams>(),
102 &error_strings); 96 &error_strings);
103 resource_id = IDR_OFFLINE_NET_LOAD_HTML; 97 resource_id = IDR_OFFLINE_NET_LOAD_HTML;
104 } 98 }
105 99
106 const base::StringPiece template_html( 100 const base::StringPiece template_html(
107 ResourceBundle::GetSharedInstance().GetRawDataResource( 101 ResourceBundle::GetSharedInstance().GetRawDataResource(
108 resource_id)); 102 resource_id));
109 // "t" is the id of the templates root node. 103 // "t" is the id of the templates root node.
110 return webui::GetTemplatesHtml(template_html, &error_strings, "t"); 104 return webui::GetTemplatesHtml(template_html, &error_strings, "t");
111 } 105 }
112 106
113 void OfflineLoadPage::OverrideRendererPrefs( 107 void OfflineLoadPage::OverrideRendererPrefs(
114 content::RendererPreferences* prefs) { 108 content::RendererPreferences* prefs) {
115 Profile* profile = Profile::FromBrowserContext( 109 Profile* profile = Profile::FromBrowserContext(
116 web_contents_->GetBrowserContext()); 110 web_contents_->GetBrowserContext());
117 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); 111 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile);
118 } 112 }
119 113
120 void OfflineLoadPage::OnProceed() { 114 void OfflineLoadPage::OnProceed() {
121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
122 proceeded_ = true; 116 proceeded_ = true;
123 NotifyBlockingPageComplete(true); 117 NotifyBlockingPageComplete(true);
124 } 118 }
(...skipping 11 matching lines...) Expand all
136 // The Jasonified response has quotes, remove them. 130 // The Jasonified response has quotes, remove them.
137 if (command.length() > 1 && command[0] == '"') { 131 if (command.length() > 1 && command[0] == '"') {
138 command = command.substr(1, command.length() - 2); 132 command = command.substr(1, command.length() - 2);
139 } 133 }
140 // TODO(oshima): record action for metrics. 134 // TODO(oshima): record action for metrics.
141 if (command == "open_network_settings") { 135 if (command == "open_network_settings") {
142 ash::Shell::GetInstance()->system_tray_delegate()->ShowNetworkSettings(""); 136 ash::Shell::GetInstance()->system_tray_delegate()->ShowNetworkSettings("");
143 } else if (command == "open_connectivity_diagnostics") { 137 } else if (command == "open_connectivity_diagnostics") {
144 Profile* profile = Profile::FromBrowserContext( 138 Profile* profile = Profile::FromBrowserContext(
145 web_contents_->GetBrowserContext()); 139 web_contents_->GetBrowserContext());
146 const extensions::Extension* extension = profile->GetExtensionService()-> 140 const extensions::Extension* extension =
147 GetInstalledExtension("kodldpbjkkmmnilagfdheibampofhaom"); 141 extensions::ExtensionRegistry::Get(profile)->GetExtensionById(
142 "kodldpbjkkmmnilagfdheibampofhaom",
143 extensions::ExtensionRegistry::EVERYTHING);
148 apps::LaunchPlatformAppWithUrl(profile, extension, "", 144 apps::LaunchPlatformAppWithUrl(profile, extension, "",
149 GURL::EmptyGURL(), GURL::EmptyGURL()); 145 GURL::EmptyGURL(), GURL::EmptyGURL());
150 146
151 } else { 147 } else {
152 LOG(WARNING) << "Unknown command:" << cmd; 148 LOG(WARNING) << "Unknown command:" << cmd;
153 } 149 }
154 } 150 }
155 151
156 void OfflineLoadPage::NotifyBlockingPageComplete(bool proceed) { 152 void OfflineLoadPage::NotifyBlockingPageComplete(bool proceed) {
157 BrowserThread::PostTask( 153 BrowserThread::PostTask(
158 BrowserThread::IO, FROM_HERE, base::Bind(callback_, proceed)); 154 BrowserThread::IO, FROM_HERE, base::Bind(callback_, proceed));
159 } 155 }
160 156
161 void OfflineLoadPage::OnConnectionTypeChanged( 157 void OfflineLoadPage::OnConnectionTypeChanged(
162 net::NetworkChangeNotifier::ConnectionType type) { 158 net::NetworkChangeNotifier::ConnectionType type) {
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
164 const bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE; 160 const bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE;
165 DVLOG(1) << "ConnectionTypeObserver notification received: state=" 161 DVLOG(1) << "ConnectionTypeObserver notification received: state="
166 << (online ? "online" : "offline"); 162 << (online ? "online" : "offline");
167 if (online) { 163 if (online) {
168 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); 164 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
169 interstitial_page_->Proceed(); 165 interstitial_page_->Proceed();
170 } 166 }
171 } 167 }
172 168
173 } // namespace chromeos 169 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_manager/file_tasks.cc ('k') | chrome/browser/profiles/off_the_record_profile_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698