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

Unified Diff: chrome/browser/ui/webui/options/advanced_options_handler.cc

Issue 7554008: Removal of Profile from content part 6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Profile helper function, rebase Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/advanced_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/advanced_options_handler.cc b/chrome/browser/ui/webui/options/advanced_options_handler.cc
index e447169c5158e441983b39261fa5959f021eb144..fa0f0997b961124eafb021f241ba8457d042c501 100644
--- a/chrome/browser/ui/webui/options/advanced_options_handler.cc
+++ b/chrome/browser/ui/webui/options/advanced_options_handler.cc
@@ -225,7 +225,7 @@ WebUIMessageHandler* AdvancedOptionsHandler::Attach(WebUI* web_ui) {
// Register for preferences that we need to observe manually. These have
// special behaviors that aren't handled by the standard prefs UI.
DCHECK(web_ui_);
- PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
+ PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs();
#if !defined(OS_CHROMEOS)
enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled,
g_browser_process->local_state(), this);
@@ -332,7 +332,7 @@ void AdvancedOptionsHandler::Observe(int type,
void AdvancedOptionsHandler::HandleSelectDownloadLocation(
const ListValue* args) {
- PrefService* pref_service = web_ui_->GetProfile()->GetPrefs();
+ PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs();
select_folder_dialog_ = SelectFileDialog::Create(this);
select_folder_dialog_->SelectFile(
SelectFileDialog::SELECT_FOLDER,
@@ -364,7 +364,8 @@ void AdvancedOptionsHandler::OnCloudPrintSetupClosed() {
void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) {
UserMetrics::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles"));
- DownloadManager* manager = web_ui_->GetProfile()->GetDownloadManager();
+ DownloadManager* manager =
+ web_ui_->tab_contents()->browser_context()->GetDownloadManager();
if (manager)
manager->download_prefs()->ResetAutoOpen();
}
@@ -429,8 +430,9 @@ void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) {
void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) {
UserMetrics::RecordAction(UserMetricsAction("Options_ManageCloudPrinters"));
// Open a new tab in the current window for the management page.
+ Profile* profile = Profile::FromWebUI(web_ui_);
web_ui_->tab_contents()->OpenURL(
- CloudPrintURL(web_ui_->GetProfile()).GetCloudPrintServiceManageURL(),
+ CloudPrintURL(profile).GetCloudPrintServiceManageURL(),
GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
}
@@ -438,10 +440,10 @@ void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) {
void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) {
UserMetrics::RecordAction(UserMetricsAction("Options_EnableCloudPrintProxy"));
// Open the connector enable page in the current tab.
+ Profile* profile = Profile::FromWebUI(web_ui_);
web_ui_->tab_contents()->OpenURL(
- CloudPrintURL(web_ui_->GetProfile()).GetCloudPrintServiceEnableURL(
- CloudPrintProxyServiceFactory::GetForProfile(
- web_ui_->GetProfile())->proxy_id()),
+ CloudPrintURL(profile).GetCloudPrintServiceEnableURL(
+ CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()),
GURL(), CURRENT_TAB, PageTransition::LINK);
}
@@ -449,19 +451,20 @@ void AdvancedOptionsHandler::HandleDisableCloudPrintProxy(
const ListValue* args) {
UserMetrics::RecordAction(
UserMetricsAction("Options_DisableCloudPrintProxy"));
- CloudPrintProxyServiceFactory::GetForProfile(web_ui_->GetProfile())->
+ CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui_))->
DisableForUser();
}
void AdvancedOptionsHandler::RefreshCloudPrintStatusFromService() {
DCHECK(web_ui_);
if (cloud_print_proxy_ui_enabled_)
- CloudPrintProxyServiceFactory::GetForProfile(web_ui_->GetProfile())->
+ CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui_))->
RefreshStatusFromService();
}
void AdvancedOptionsHandler::SetupCloudPrintProxySection() {
- if (!CloudPrintProxyServiceFactory::GetForProfile(web_ui_->GetProfile())) {
+ Profile* profile = Profile::FromWebUI(web_ui_);
+ if (!CloudPrintProxyServiceFactory::GetForProfile(profile)) {
cloud_print_proxy_ui_enabled_ = false;
RemoveCloudPrintProxySection();
return;
@@ -473,10 +476,9 @@ void AdvancedOptionsHandler::SetupCloudPrintProxySection() {
FundamentalValue allowed(cloud_print_proxy_allowed);
std::string email;
- if (web_ui_->GetProfile()->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) &&
+ if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) &&
cloud_print_proxy_allowed) {
- email = web_ui_->GetProfile()->GetPrefs()->GetString(
- prefs::kCloudPrintEmail);
+ email = profile->GetPrefs()->GetString(prefs::kCloudPrintEmail);
}
FundamentalValue disabled(email.empty());
@@ -556,7 +558,8 @@ void AdvancedOptionsHandler::SetupPromptForDownload() {
void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() {
// Set the enabled state for the AutoOpenFileTypesResetToDefault button.
// We enable the button if the user has any auto-open file types registered.
- DownloadManager* manager = web_ui_->GetProfile()->GetDownloadManager();
+ DownloadManager* manager =
+ web_ui_->tab_contents()->browser_context()->GetDownloadManager();
bool disabled = !(manager && manager->download_prefs()->IsAutoOpenUsed());
FundamentalValue value(disabled);
web_ui_->CallJavascriptFunction(
@@ -566,7 +569,7 @@ void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() {
void AdvancedOptionsHandler::SetupProxySettingsSection() {
// Disable the button if proxy settings are managed by a sysadmin or
// overridden by an extension.
- PrefService* pref_service = web_ui_->GetProfile()->GetPrefs();
+ PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs();
const PrefService::Preference* proxy_config =
pref_service->FindPreference(prefs::kProxy);
bool is_extension_controlled = (proxy_config &&
« no previous file with comments | « chrome/browser/ui/webui/ntp/shown_sections_handler.cc ('k') | chrome/browser/ui/webui/options/autofill_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698