Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 if (!chrome::FindTabbedBrowser(profile, /*match_original_profiles=*/false)) |
| 72 return; | 72 return; |
| 73 | 73 |
| 74 chrome::ScopedTabbedBrowserDisplayer displayer(profile); | 74 // First, find a browser window and show it, and only then show the dialog so |
| 75 // that the dialog will have focus. | |
| 76 Browser* browser = nullptr; | |
| 77 { | |
| 78 chrome::ScopedTabbedBrowserDisplayer displayer(profile); | |
|
sky
2017/03/21 20:36:01
If a new browser is created by ScopedTabbedBrowser
alito2
2017/03/21 20:44:17
Just above this line, I do make sure that there is
sky
2017/03/21 20:52:18
Indeed. In that case you should use the return val
alito
2017/03/21 21:02:42
Done.
| |
| 79 browser = displayer.browser(); | |
| 80 } | |
| 75 // The |SettingsResetPromptController| object will delete itself after the | 81 // The |SettingsResetPromptController| object will delete itself after the |
| 76 // reset prompt dialog has been closed. | 82 // reset prompt dialog has been closed. |
| 77 SettingsResetPromptController::ShowSettingsResetPrompt( | 83 SettingsResetPromptController::ShowSettingsResetPrompt( |
| 78 displayer.browser(), new SettingsResetPromptController(std::move(model))); | 84 browser, new SettingsResetPromptController(std::move(model))); |
| 79 } | 85 } |
| 80 | 86 |
| 81 void MaybeShowSettingsResetPrompt( | 87 void MaybeShowSettingsResetPrompt( |
| 82 std::unique_ptr<SettingsResetPromptConfig> config) { | 88 std::unique_ptr<SettingsResetPromptConfig> config) { |
| 83 DCHECK(config); | 89 DCHECK(config); |
| 84 | 90 |
| 85 Browser* browser = chrome::FindLastActive(); | 91 Browser* browser = chrome::FindLastActive(); |
| 86 if (!browser) | 92 if (!browser) |
| 87 return; | 93 return; |
| 88 | 94 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 if (!config) | 240 if (!config) |
| 235 return; | 241 return; |
| 236 | 242 |
| 237 base::TimeDelta delay = config->delay_before_prompt(); | 243 base::TimeDelta delay = config->delay_before_prompt(); |
| 238 content::BrowserThread::PostDelayedTask( | 244 content::BrowserThread::PostDelayedTask( |
| 239 content::BrowserThread::UI, FROM_HERE, | 245 content::BrowserThread::UI, FROM_HERE, |
| 240 base::Bind(MaybeShowSettingsResetPrompt, base::Passed(&config)), delay); | 246 base::Bind(MaybeShowSettingsResetPrompt, base::Passed(&config)), delay); |
| 241 } | 247 } |
| 242 | 248 |
| 243 } // namespace safe_browsing | 249 } // namespace safe_browsing |
| OLD | NEW |