Chromium Code Reviews| Index: chrome/browser/profile_resetter/automatic_profile_resetter.h |
| diff --git a/chrome/browser/profile_resetter/automatic_profile_resetter.h b/chrome/browser/profile_resetter/automatic_profile_resetter.h |
| index 602971e2d681a43dcb57c41a2b116566e949a208..9a27e21bec926e46c2ab4fc6f901c3bf04f84153 100644 |
| --- a/chrome/browser/profile_resetter/automatic_profile_resetter.h |
| +++ b/chrome/browser/profile_resetter/automatic_profile_resetter.h |
| @@ -36,6 +36,33 @@ class ListValue; |
| // otherwise. |
| class AutomaticProfileResetter : public BrowserContextKeyedService { |
| public: |
| + // Enumeration of the possible outcomes of showing the profile reset prompt. |
| + enum PromptResult { |
| + // Prompt was not shown because only a dry-run was performed. |
| + PROMPT_NOT_SHOWN, |
| + PROMPT_ACTION_RESET, |
| + PROMPT_ACTION_NO_RESET, |
| + // The prompt was shown, but the user dismissed the reset bubble without |
| + // taking definitive action (selecting either "Reset" or "No, thanks"). |
| + // Deprecated in favor of the following three items. |
| + PROMPT_DISMISSED, |
| + // The reset bubble was still shown; or dismissed without taking definitive |
| + // action when Chrome was closed. |
| + PROMPT_IGNORED, |
| + // The reset bubble was shown, then dismissed without taking definitive |
| + // action. Then, however, the user initiated or refrained from (resp.) doing |
|
MAD
2013/11/11 13:26:11
resp. ???
engedy
2013/11/13 00:40:44
Done.
|
| + // a reset from the conventional, WebUI-based reset dialog. |
| + PROMPT_FOLLOWED_BY_WEBUI_RESET, |
| + PROMPT_FOLLOWED_BY_WEBUI_NO_RESET, |
| + // The reset bubble was suppressed (not shown) because another bubble was |
| + // already being shown at the time. Regardless, however, the user initiated |
| + // or refrained from (resp.) doing a reset from the conventional, WebUI- |
| + // based reset dialog. |
| + PROMPT_SUPPRESSED_BUT_HAD_WEBUI_RESET, |
| + PROMPT_SUPPRESSED_BUT_HAD_WEBUI_NO_RESET, |
| + PROMPT_RESULT_MAX |
| + }; |
| + |
| explicit AutomaticProfileResetter(Profile* profile); |
| virtual ~AutomaticProfileResetter(); |
| @@ -50,6 +77,44 @@ class AutomaticProfileResetter : public BrowserContextKeyedService { |
| // Called by the AutomaticProfileResetterFactory. |
| void Activate(); |
| + // Called by ProfileResetGlobalError in case the user chooses to reset their |
|
MAD
2013/11/11 13:26:11
Not sure if we should document here who calls this
engedy
2013/11/13 00:40:44
Removed, also 4 in instances below.
|
| + // profile settings from inside the reset bubble. Will trigger the reset, |
| + // optionally |send_feedback|, and conclude the reset prompt flow. |
| + void TriggerProfileReset(bool send_feedback); |
| + |
| + // Called by ProfileResetGlobalError in case the user chooses from inside the |
| + // reset bubble that they do not want to reset their profile settings. |
| + // Will conclude the reset prompt flow without setting off the reset. |
| + void SkipProfileReset(); |
| + |
| + // Returns whether or not the profile reset prompt flow is currently active. |
| + // See BeginResetPromptFlow() for a description of what this means. |
| + bool IsResetPromptActive() const; |
| + |
| + // Called by ProfileResetGlobalError to give notice that the reset bubble has |
| + // actually been shown. |
| + void NotifyDidShowResetBubble(); |
| + |
| + // Called by ResetProfileSettingsHandler to give notice that the conventional, |
| + // WebUI-based settings reset dialog has been opened. This will already |
| + // dismiss the menu item in the wrench menu. This should be always followed by |
|
MAD
2013/11/11 13:26:11
Not sure we need the word "already" here... and I
engedy
2013/11/13 00:40:44
Done.
|
| + // a corresponding NotifyDidCloseWebUIResetDialog() call. |
| + void NotifyDidOpenWebUIResetDialog(); |
| + |
| + // Called by ResetProfileSettingsHandler to give notice that the conventional, |
| + // WebUI-based settings reset dialog has been closed, with |performed_reset| |
| + // indicating whether or not a reset was requested. This is required so that |
| + // we can record the appropriate PromptResult, and conclude the reset prompt |
| + // flow early without setting off any more resets in the future. |
| + void NotifyDidCloseWebUIResetDialog(bool performed_reset); |
| + |
| + base::WeakPtr<AutomaticProfileResetter> AsWeakPtr() { |
| + return weak_ptr_factory_.GetWeakPtr(); |
| + } |
| + |
| + // BrowserContextKeyedService: |
| + virtual void Shutdown() OVERRIDE; |
| + |
| // Should be called before Activate(). |
| void SetProgramForTesting(const std::string& program); |
| @@ -74,7 +139,9 @@ class AutomaticProfileResetter : public BrowserContextKeyedService { |
| STATE_DISABLED, |
| STATE_WAITING_ON_DEPENDENCIES, |
| STATE_READY, |
| - STATE_WORKING, |
| + STATE_EVALUATING_CONDITIONS, |
| + STATE_AWAITING_USER_CHOICE, |
| + STATE_PERFORMING_RESET, |
| STATE_DONE |
| }; |
| @@ -119,28 +186,55 @@ class AutomaticProfileResetter : public BrowserContextKeyedService { |
| const std::string& program, |
| scoped_ptr<base::DictionaryValue> program_input); |
| - // Called back when EvaluateConditionsOnWorkerPoolThread completes executing |
| - // the program with |results|. Finishes the evaluation flow, and, based on the |
| - // result, will potentially show the reset prompt. |
| - void FinishEvaluationFlow(scoped_ptr<EvaluationResults> results); |
| - |
| // Reports the given metrics through UMA. Virtual, so it can be mocked out in |
| // tests to verify that the correct value are being reported. |
| virtual void ReportStatistics(uint32 satisfied_criteria_mask, |
| uint32 combined_status_mask); |
| - // BrowserContextKeyedService: |
| - virtual void Shutdown() OVERRIDE; |
| + // Called back when EvaluateConditionsOnWorkerPoolThread completes executing |
| + // the program with |results|. Finishes the evaluation flow, and, based on the |
| + // result, potentially initiates the reset prompt flow. |
| + void FinishEvaluationFlow(scoped_ptr<EvaluationResults> results); |
| + |
| + // Begins the reset prompt flow by triggering the reset prompt, which consists |
| + // of two parts: (1.) the profile reset (pop-up) bubble, and (2.) a menu item |
| + // in the wrench menu. |
| + // The flow is considered to be "active" until we receive a clear indication |
| + // from the user about whether or not they wish to reset their settings. This |
| + // indication can come in a variety of flavors: |
| + // * taking definitive action (i.e. selecting either "Reset" or "No, thanks") |
| + // in the pop-up reset bubble itself, |
| + // * dismissing the bubble, but then selecting the wrench menu item, which |
| + // takes them to the WebUI reset dialog in chrome://settings, and then |
| + // making their choice there, |
| + // * going to the WebUI reset dialog by themselves. |
| + void BeginResetPromptFlow(); |
| + |
| + // Called back by the ProfileResetter once resetting the profile settings has |
| + // been completed, when requested by the user from inside the reset bubble. |
| + // Will conclude the reset prompt flow. |
| + void OnProfileSettingsResetCompleted(); |
| + |
| + // Reports the result of showing the prompt through UMA. Virtual, so it can be |
| + // mocked out in tests to verify that the correct value is being reported. |
| + virtual void ReportPromptResult(PromptResult result); |
| + |
| + // Concludes the reset prompt flow with |prompt_result|, and persists the |
| + // memento values returned by the evaluator program to disk. |
| + void FinishResetPromptFlow(PromptResult prompt_result); |
| Profile* profile_; |
| State state_; |
| bool enumeration_of_loaded_modules_ready_; |
| bool template_url_service_ready_; |
| + bool has_shown_bubble_; |
| std::string hash_seed_; |
| std::string program_; |
| + scoped_ptr<EvaluationResults> evaluation_results_; |
| + |
| PreferenceHostedPromptMemento memento_in_prefs_; |
| LocalStateHostedPromptMemento memento_in_local_state_; |
| FileHostedPromptMemento memento_in_file_; |