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

Side by Side Diff: chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.cc

Issue 2764033004: Settings reset prompt: the dialog should have focus when shown. (Closed)
Patch Set: remove unused header include Created 3 years, 9 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
« no previous file with comments | « no previous file | 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/safe_browsing/settings_reset_prompt/settings_reset_prom pt_controller.h" 5 #include "chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prom pt_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/metrics/user_metrics.h" 14 #include "base/metrics/user_metrics.h"
15 #include "base/metrics/user_metrics_action.h" 15 #include "base/metrics/user_metrics_action.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prom pt_config.h" 18 #include "chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prom pt_config.h"
19 #include "chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prom pt_model.h" 19 #include "chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prom pt_model.h"
20 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_finder.h" 21 #include "chrome/browser/ui/browser_finder.h"
22 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 22 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/grit/chromium_strings.h" 23 #include "chrome/grit/chromium_strings.h"
24 #include "chrome/grit/generated_resources.h" 24 #include "chrome/grit/generated_resources.h"
25 #include "components/url_formatter/elide_url.h" 25 #include "components/url_formatter/elide_url.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
28 #include "url/gurl.h" 28 #include "url/gurl.h"
29 29
30 namespace safe_browsing { 30 namespace safe_browsing {
31 31
32 namespace { 32 namespace {
(...skipping 28 matching lines...) Expand all
61 61
62 model->ReportUmaMetrics(); 62 model->ReportUmaMetrics();
63 63
64 if (!model->ShouldPromptForReset()) 64 if (!model->ShouldPromptForReset())
65 return; 65 return;
66 66
67 Profile* profile = model->profile(); 67 Profile* profile = model->profile();
68 68
69 // Ensure that there is at least one non-incognito browser open for the 69 // Ensure that there is at least one non-incognito browser open for the
70 // profile before attempting to show the dialog. 70 // profile before attempting to show the dialog.
71 if (!chrome::FindTabbedBrowser(profile, /*match_original_profiles=*/false)) 71 Browser* browser =
72 chrome::FindTabbedBrowser(profile, /*match_original_profiles=*/false);
73 if (!browser)
72 return; 74 return;
73 75
74 chrome::ScopedTabbedBrowserDisplayer displayer(profile); 76 // First, show the browser window, and only then show the dialog so that the
77 // dialog will have focus.
78 if (browser->window()->IsMinimized())
79 browser->window()->Restore();
80 browser->window()->Show();
81
75 // The |SettingsResetPromptController| object will delete itself after the 82 // The |SettingsResetPromptController| object will delete itself after the
76 // reset prompt dialog has been closed. 83 // reset prompt dialog has been closed.
77 SettingsResetPromptController::ShowSettingsResetPrompt( 84 SettingsResetPromptController::ShowSettingsResetPrompt(
78 displayer.browser(), new SettingsResetPromptController(std::move(model))); 85 browser, new SettingsResetPromptController(std::move(model)));
79 } 86 }
80 87
81 void MaybeShowSettingsResetPrompt( 88 void MaybeShowSettingsResetPrompt(
82 std::unique_ptr<SettingsResetPromptConfig> config) { 89 std::unique_ptr<SettingsResetPromptConfig> config) {
83 DCHECK(config); 90 DCHECK(config);
84 91
85 Browser* browser = chrome::FindLastActive(); 92 Browser* browser = chrome::FindLastActive();
86 if (!browser) 93 if (!browser)
87 return; 94 return;
88 95
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (!config) 241 if (!config)
235 return; 242 return;
236 243
237 base::TimeDelta delay = config->delay_before_prompt(); 244 base::TimeDelta delay = config->delay_before_prompt();
238 content::BrowserThread::PostDelayedTask( 245 content::BrowserThread::PostDelayedTask(
239 content::BrowserThread::UI, FROM_HERE, 246 content::BrowserThread::UI, FROM_HERE,
240 base::Bind(MaybeShowSettingsResetPrompt, base::Passed(&config)), delay); 247 base::Bind(MaybeShowSettingsResetPrompt, base::Passed(&config)), delay);
241 } 248 }
242 249
243 } // namespace safe_browsing 250 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698