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

Side by Side Diff: chrome/browser/ui/views/profiles/user_manager_view.cc

Issue 1708343002: Add ScopedKeepAlive to c/b/lifetime (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/profiles/user_manager_view.h" 5 #include "chrome/browser/ui/views/profiles/user_manager_view.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/lifetime/application_lifetime.h" 12 #include "chrome/browser/lifetime/keep_alive_options.h"
13 #include "chrome/browser/lifetime/scoped_keep_alive.h"
13 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 14 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
14 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/browser/profiles/profile_metrics.h" 16 #include "chrome/browser/profiles/profile_metrics.h"
16 #include "chrome/browser/profiles/profile_window.h" 17 #include "chrome/browser/profiles/profile_window.h"
17 #include "chrome/browser/profiles/profiles_state.h" 18 #include "chrome/browser/profiles/profiles_state.h"
18 #include "chrome/browser/signin/signin_promo.h" 19 #include "chrome/browser/signin/signin_promo.h"
19 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_dialogs.h" 21 #include "chrome/browser/ui/browser_dialogs.h"
21 #include "chrome/browser/ui/browser_finder.h" 22 #include "chrome/browser/ui/browser_finder.h"
22 #include "chrome/browser/ui/browser_window.h" 23 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/browser/ui/user_manager.h" 24 #include "chrome/browser/ui/user_manager.h"
24 #include "chrome/browser/ui/views/auto_keep_alive.h"
25 #include "chrome/browser/ui/views/browser_dialogs.h" 25 #include "chrome/browser/ui/views/browser_dialogs.h"
26 #include "chrome/grit/chromium_strings.h" 26 #include "chrome/grit/chromium_strings.h"
27 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
28 #include "components/guest_view/browser/guest_view_manager.h" 28 #include "components/guest_view/browser/guest_view_manager.h"
29 #include "content/public/browser/navigation_details.h" 29 #include "content/public/browser/navigation_details.h"
30 #include "content/public/browser/render_widget_host_view.h" 30 #include "content/public/browser/render_widget_host_view.h"
31 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
32 #include "google_apis/gaia/gaia_urls.h" 32 #include "google_apis/gaia/gaia_urls.h"
33 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/gfx/screen.h" 34 #include "ui/gfx/screen.h"
(...skipping 11 matching lines...) Expand all
46 #endif 46 #endif
47 47
48 #if defined(USE_ASH) 48 #if defined(USE_ASH)
49 #include "ash/shelf/shelf_util.h" 49 #include "ash/shelf/shelf_util.h"
50 #include "ash/wm/window_util.h" 50 #include "ash/wm/window_util.h"
51 #include "grit/ash_resources.h" 51 #include "grit/ash_resources.h"
52 #endif 52 #endif
53 53
54 namespace { 54 namespace {
55 55
56 const KeepAliveOptions kKeepAliveOptions = {"UserManagerView"};
57
56 // An open User Manager window. There can only be one open at a time. This 58 // An open User Manager window. There can only be one open at a time. This
57 // is reset to NULL when the window is closed. 59 // is reset to NULL when the window is closed.
58 UserManagerView* instance_ = NULL; 60 UserManagerView* instance_ = NULL;
59 bool instance_under_construction_ = false; 61 bool instance_under_construction_ = false;
60 62
61 class ReauthDelegate : public views::DialogDelegateView, 63 class ReauthDelegate : public views::DialogDelegateView,
62 public UserManager::ReauthDialogObserver { 64 public UserManager::ReauthDialogObserver {
63 public: 65 public:
64 ReauthDelegate(views::WebView* web_view, 66 ReauthDelegate(views::WebView* web_view,
65 const std::string& email_address); 67 const std::string& email_address);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 new ReauthDelegate(new views::WebView(browser_context), email); 229 new ReauthDelegate(new views::WebView(browser_context), email);
228 gfx::NativeView parent = instance_->GetWidget()->GetNativeView(); 230 gfx::NativeView parent = instance_->GetWidget()->GetNativeView();
229 views::DialogDelegate::CreateDialogWidget(delegate, nullptr, parent); 231 views::DialogDelegate::CreateDialogWidget(delegate, nullptr, parent);
230 delegate->GetWidget()->Show(); 232 delegate->GetWidget()->Show();
231 } 233 }
232 234
233 // UserManagerView ------------------------------------------------------------- 235 // UserManagerView -------------------------------------------------------------
234 236
235 UserManagerView::UserManagerView() 237 UserManagerView::UserManagerView()
236 : web_view_(NULL), 238 : web_view_(NULL),
237 keep_alive_(new AutoKeepAlive(NULL)),
238 user_manager_started_showing_(base::Time()) { 239 user_manager_started_showing_(base::Time()) {
240 keep_alive_.reset(new ScopedKeepAlive(&kKeepAliveOptions));
239 } 241 }
240 242
241 UserManagerView::~UserManagerView() { 243 UserManagerView::~UserManagerView() {
242 } 244 }
243 245
244 // static 246 // static
245 void UserManagerView::OnSystemProfileCreated( 247 void UserManagerView::OnSystemProfileCreated(
246 scoped_ptr<UserManagerView> instance, 248 scoped_ptr<UserManagerView> instance,
247 base::AutoReset<bool>* pending, 249 base::AutoReset<bool>* pending,
248 Profile* system_profile, 250 Profile* system_profile,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // Now that the window is closed, we can allow a new one to be opened. 377 // Now that the window is closed, we can allow a new one to be opened.
376 // (WindowClosing comes in asynchronously from the call to Close() and we 378 // (WindowClosing comes in asynchronously from the call to Close() and we
377 // may have already opened a new instance). 379 // may have already opened a new instance).
378 if (instance_ == this) 380 if (instance_ == this)
379 instance_ = NULL; 381 instance_ = NULL;
380 } 382 }
381 383
382 bool UserManagerView::UseNewStyleForThisDialog() const { 384 bool UserManagerView::UseNewStyleForThisDialog() const {
383 return false; 385 return false;
384 } 386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698