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

Side by Side Diff: chrome/browser/ui/views/uninstall_view.cc

Issue 1803143002: Replace BrowserProces::AddRefModule/RemoveModule by ScopedKeepAlive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/views/uninstall_view.h" 5 #include "chrome/browser/ui/views/uninstall_view.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/process/launch.h" 8 #include "base/process/launch.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/lifetime/keep_alive_types.h"
11 #include "chrome/browser/lifetime/scoped_keep_alive.h"
11 #include "chrome/browser/shell_integration.h" 12 #include "chrome/browser/shell_integration.h"
12 #include "chrome/browser/ui/uninstall_browser_prompt.h" 13 #include "chrome/browser/ui/uninstall_browser_prompt.h"
13 #include "chrome/common/chrome_result_codes.h" 14 #include "chrome/common/chrome_result_codes.h"
14 #include "chrome/grit/chromium_strings.h" 15 #include "chrome/grit/chromium_strings.h"
15 #include "chrome/installer/util/browser_distribution.h" 16 #include "chrome/installer/util/browser_distribution.h"
16 #include "chrome/installer/util/shell_util.h" 17 #include "chrome/installer/util/shell_util.h"
17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/views/controls/button/checkbox.h" 19 #include "ui/views/controls/button/checkbox.h"
19 #include "ui/views/controls/combobox/combobox.h" 20 #include "ui/views/controls/combobox/combobox.h"
20 #include "ui/views/controls/label.h" 21 #include "ui/views/controls/label.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 std::advance(i, index); 160 std::advance(i, index);
160 return i->first; 161 return i->first;
161 } 162 }
162 163
163 namespace chrome { 164 namespace chrome {
164 165
165 int ShowUninstallBrowserPrompt() { 166 int ShowUninstallBrowserPrompt() {
166 DCHECK(base::MessageLoopForUI::IsCurrent()); 167 DCHECK(base::MessageLoopForUI::IsCurrent());
167 int result = content::RESULT_CODE_NORMAL_EXIT; 168 int result = content::RESULT_CODE_NORMAL_EXIT;
168 169
169 // Take a reference on g_browser_process while showing the dialog. This is 170 // Register a KeepAlive while showing the dialog. This is done because the
170 // done because the dialog uses the views framework which may increment 171 // dialog uses the views framework which may take and release a KeepAlive
171 // and decrement the module ref count during the course of displaying UI and 172 // during the course of displaying UI and this code can be called while
172 // this code can be called while the module refcount is still at 0. 173 // there is no registered KeepAlive.
173 // Note that this reference is never released, as this code is shown on a path 174 // Note that this reference is never released, as this code is shown on a path
174 // that immediately exits Chrome anyway. 175 // that immediately exits Chrome anyway.
175 // See http://crbug.com/241366 for details. 176 // See http://crbug.com/241366 for details.
176 g_browser_process->AddRefModule(); 177 new ScopedKeepAlive(KeepAliveOrigin::LEAKED_UNINSTALL_VIEW,
178 KeepAliveRestartOption::DISABLED);
177 179
178 base::RunLoop run_loop; 180 base::RunLoop run_loop;
179 UninstallView* view = new UninstallView(&result, 181 UninstallView* view = new UninstallView(&result,
180 run_loop.QuitClosure()); 182 run_loop.QuitClosure());
181 views::DialogDelegate::CreateDialogWidget(view, NULL, NULL)->Show(); 183 views::DialogDelegate::CreateDialogWidget(view, NULL, NULL)->Show();
182 run_loop.Run(); 184 run_loop.Run();
183 return result; 185 return result;
184 } 186 }
185 187
186 } // namespace chrome 188 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/chrome_views_delegate.cc ('k') | chrome/test/base/testing_browser_process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698