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

Side by Side Diff: chrome/browser/ui/webui/options/reset_profile_settings_handler.cc

Issue 62193002: Integrate UI and reset logic into AutomaticProfileResetter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Win compile error introduce by rebase. Created 7 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/webui/options/reset_profile_settings_handler.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/options/reset_profile_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/reset_profile_settings_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/google/google_util.h" 13 #include "chrome/browser/google/google_util.h"
14 #include "chrome/browser/profile_resetter/automatic_profile_resetter.h"
15 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
14 #include "chrome/browser/profile_resetter/brandcode_config_fetcher.h" 16 #include "chrome/browser/profile_resetter/brandcode_config_fetcher.h"
15 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" 17 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h"
16 #include "chrome/browser/profile_resetter/profile_resetter.h" 18 #include "chrome/browser/profile_resetter/profile_resetter.h"
17 #include "chrome/browser/profile_resetter/resettable_settings_snapshot.h" 19 #include "chrome/browser/profile_resetter/resettable_settings_snapshot.h"
18 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
20 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
21 #include "content/public/browser/user_metrics.h" 23 #include "content/public/browser/user_metrics.h"
22 #include "content/public/browser/web_ui.h" 24 #include "content/public/browser/web_ui.h"
23 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
24 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
25 27
26 namespace options { 28 namespace options {
27 29
28 ResetProfileSettingsHandler::ResetProfileSettingsHandler() { 30 ResetProfileSettingsHandler::ResetProfileSettingsHandler()
31 : automatic_profile_resetter_(NULL), has_shown_confirmation_dialog_(false) {
29 google_util::GetBrand(&brandcode_); 32 google_util::GetBrand(&brandcode_);
30 } 33 }
31 34
32 ResetProfileSettingsHandler::~ResetProfileSettingsHandler() { 35 ResetProfileSettingsHandler::~ResetProfileSettingsHandler() {}
33 }
34 36
35 void ResetProfileSettingsHandler::InitializeHandler() { 37 void ResetProfileSettingsHandler::InitializeHandler() {
36 Profile* profile = Profile::FromWebUI(web_ui()); 38 Profile* profile = Profile::FromWebUI(web_ui());
37 resetter_.reset(new ProfileResetter(profile)); 39 resetter_.reset(new ProfileResetter(profile));
40 automatic_profile_resetter_ =
41 AutomaticProfileResetterFactory::GetForBrowserContext(profile);
42 DCHECK(automatic_profile_resetter_);
38 } 43 }
39 44
40 void ResetProfileSettingsHandler::InitializePage() { 45 void ResetProfileSettingsHandler::InitializePage() {
41 web_ui()->CallJavascriptFunction( 46 web_ui()->CallJavascriptFunction(
42 "ResetProfileSettingsOverlay.setResettingState", 47 "ResetProfileSettingsOverlay.setResettingState",
43 base::FundamentalValue(resetter_->IsActive())); 48 base::FundamentalValue(resetter_->IsActive()));
44 } 49 }
45 50
51 void ResetProfileSettingsHandler::Uninitialize() {
52 if (has_shown_confirmation_dialog_) {
53 DCHECK(automatic_profile_resetter_);
54 automatic_profile_resetter_->NotifyDidCloseWebUIResetDialog(
55 false /*performed_reset*/);
56 }
57 }
58
46 void ResetProfileSettingsHandler::GetLocalizedValues( 59 void ResetProfileSettingsHandler::GetLocalizedValues(
47 DictionaryValue* localized_strings) { 60 DictionaryValue* localized_strings) {
48 DCHECK(localized_strings); 61 DCHECK(localized_strings);
49 62
50 static OptionsStringResource resources[] = { 63 static OptionsStringResource resources[] = {
51 { "resetProfileSettingsCommit", IDS_RESET_PROFILE_SETTINGS_COMMIT_BUTTON }, 64 { "resetProfileSettingsCommit", IDS_RESET_PROFILE_SETTINGS_COMMIT_BUTTON },
52 { "resetProfileSettingsExplanation", 65 { "resetProfileSettingsExplanation",
53 IDS_RESET_PROFILE_SETTINGS_EXPLANATION}, 66 IDS_RESET_PROFILE_SETTINGS_EXPLANATION},
54 { "resetProfileSettingsFeedback", IDS_RESET_PROFILE_SETTINGS_FEEDBACK } 67 { "resetProfileSettingsFeedback", IDS_RESET_PROFILE_SETTINGS_FEEDBACK }
55 }; 68 };
(...skipping 28 matching lines...) Expand all
84 config_fetcher_->SetCallback( 97 config_fetcher_->SetCallback(
85 base::Bind(&ResetProfileSettingsHandler::ResetProfile, 98 base::Bind(&ResetProfileSettingsHandler::ResetProfile,
86 Unretained(this), 99 Unretained(this),
87 send_settings)); 100 send_settings));
88 } else { 101 } else {
89 ResetProfile(send_settings); 102 ResetProfile(send_settings);
90 } 103 }
91 } 104 }
92 105
93 void ResetProfileSettingsHandler::OnResetProfileSettingsDone() { 106 void ResetProfileSettingsHandler::OnResetProfileSettingsDone() {
107 DCHECK(automatic_profile_resetter_);
94 web_ui()->CallJavascriptFunction("ResetProfileSettingsOverlay.doneResetting"); 108 web_ui()->CallJavascriptFunction("ResetProfileSettingsOverlay.doneResetting");
95 if (setting_snapshot_) { 109 if (setting_snapshot_) {
96 Profile* profile = Profile::FromWebUI(web_ui()); 110 Profile* profile = Profile::FromWebUI(web_ui());
97 ResettableSettingsSnapshot current_snapshot(profile); 111 ResettableSettingsSnapshot current_snapshot(profile);
98 int difference = setting_snapshot_->FindDifferentFields(current_snapshot); 112 int difference = setting_snapshot_->FindDifferentFields(current_snapshot);
99 if (difference) { 113 if (difference) {
100 setting_snapshot_->Subtract(current_snapshot); 114 setting_snapshot_->Subtract(current_snapshot);
101 std::string report = SerializeSettingsReport(*setting_snapshot_, 115 std::string report = SerializeSettingsReport(*setting_snapshot_,
102 difference); 116 difference);
103 SendSettingsFeedback(report, profile, PROFILE_RESET_WEBUI); 117 bool is_reset_prompt_active =
118 automatic_profile_resetter_->IsResetPromptFlowActive();
119 SendSettingsFeedback(report, profile, is_reset_prompt_active ?
120 PROFILE_RESET_PROMPT : PROFILE_RESET_WEBUI);
104 } 121 }
105 setting_snapshot_.reset(); 122 setting_snapshot_.reset();
106 } 123 }
124 automatic_profile_resetter_->NotifyDidCloseWebUIResetDialog(
125 true /*performed_reset*/);
107 } 126 }
108 127
109 void ResetProfileSettingsHandler::OnShowResetProfileDialog(const ListValue*) { 128 void ResetProfileSettingsHandler::OnShowResetProfileDialog(const ListValue*) {
110 DictionaryValue flashInfo; 129 DictionaryValue flashInfo;
111 flashInfo.Set("feedbackInfo", GetReadableFeedback( 130 flashInfo.Set("feedbackInfo", GetReadableFeedback(
112 Profile::FromWebUI(web_ui()))); 131 Profile::FromWebUI(web_ui())));
113 web_ui()->CallJavascriptFunction( 132 web_ui()->CallJavascriptFunction(
114 "ResetProfileSettingsOverlay.setFeedbackInfo", 133 "ResetProfileSettingsOverlay.setFeedbackInfo",
115 flashInfo); 134 flashInfo);
116 135
136 automatic_profile_resetter_->NotifyDidOpenWebUIResetDialog();
137 has_shown_confirmation_dialog_ = true;
138
117 if (brandcode_.empty()) 139 if (brandcode_.empty())
118 return; 140 return;
119 config_fetcher_.reset(new BrandcodeConfigFetcher( 141 config_fetcher_.reset(new BrandcodeConfigFetcher(
120 base::Bind(&ResetProfileSettingsHandler::OnSettingsFetched, 142 base::Bind(&ResetProfileSettingsHandler::OnSettingsFetched,
121 Unretained(this)), 143 Unretained(this)),
122 GURL("https://tools.google.com/service/update2"), 144 GURL("https://tools.google.com/service/update2"),
123 brandcode_)); 145 brandcode_));
124 } 146 }
125 147
126 void ResetProfileSettingsHandler::OnSettingsFetched() { 148 void ResetProfileSettingsHandler::OnSettingsFetched() {
(...skipping 25 matching lines...) Expand all
152 resetter_->Reset( 174 resetter_->Reset(
153 ProfileResetter::ALL, 175 ProfileResetter::ALL,
154 default_settings.Pass(), 176 default_settings.Pass(),
155 base::Bind(&ResetProfileSettingsHandler::OnResetProfileSettingsDone, 177 base::Bind(&ResetProfileSettingsHandler::OnResetProfileSettingsDone,
156 AsWeakPtr())); 178 AsWeakPtr()));
157 content::RecordAction(content::UserMetricsAction("ResetProfile")); 179 content::RecordAction(content::UserMetricsAction("ResetProfile"));
158 UMA_HISTOGRAM_BOOLEAN("ProfileReset.SendFeedback", send_settings); 180 UMA_HISTOGRAM_BOOLEAN("ProfileReset.SendFeedback", send_settings);
159 } 181 }
160 182
161 } // namespace options 183 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/reset_profile_settings_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698