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

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

Issue 8301022: ui/views: Migrate usages of ScopedRunnableMethodFactory to base::WeakPtrFactory/base::Bind pair. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/first_run_bubble.h" 5 #include "chrome/browser/ui/views/first_run_bubble.h"
6 6
7 #include "base/bind.h"
7 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/first_run/first_run.h" 9 #include "chrome/browser/first_run/first_run.h"
9 #include "chrome/browser/search_engines/util.h" 10 #include "chrome/browser/search_engines/util.h"
10 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_list.h" 12 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
13 #include "content/browser/user_metrics.h" 14 #include "content/browser/user_metrics.h"
14 #include "grit/chromium_strings.h" 15 #include "grit/chromium_strings.h"
15 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
16 #include "grit/locale_settings.h" 17 #include "grit/locale_settings.h"
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 return bubble; 516 return bubble;
516 } 517 }
517 518
518 FirstRunBubble::FirstRunBubble() 519 FirstRunBubble::FirstRunBubble()
519 : has_been_activated_(false), 520 : has_been_activated_(false),
520 ALLOW_THIS_IN_INITIALIZER_LIST(enable_window_method_factory_(this)), 521 ALLOW_THIS_IN_INITIALIZER_LIST(enable_window_method_factory_(this)),
521 view_(NULL) { 522 view_(NULL) {
522 } 523 }
523 524
524 FirstRunBubble::~FirstRunBubble() { 525 FirstRunBubble::~FirstRunBubble() {
525 enable_window_method_factory_.RevokeAll(); 526 enable_window_method_factory_.InvalidateWeakPtrs();
526 GetWidget()->GetFocusManager()->RemoveFocusChangeListener(view_); 527 GetWidget()->GetFocusManager()->RemoveFocusChangeListener(view_);
527 } 528 }
528 529
529 void FirstRunBubble::EnableParent() { 530 void FirstRunBubble::EnableParent() {
530 ::EnableWindow(GetParent(), true); 531 ::EnableWindow(GetParent(), true);
531 // The EnableWindow() call above causes the parent to become active, which 532 // The EnableWindow() call above causes the parent to become active, which
532 // resets the flag set by Bubble's call to DisableInactiveRendering(), so we 533 // resets the flag set by Bubble's call to DisableInactiveRendering(), so we
533 // have to call it again before activating the bubble to prevent the parent 534 // have to call it again before activating the bubble to prevent the parent
534 // window from rendering inactive. 535 // window from rendering inactive.
535 // TODO(beng): this only works in custom-frame mode, not glass-frame mode. 536 // TODO(beng): this only works in custom-frame mode, not glass-frame mode.
(...skipping 13 matching lines...) Expand all
549 const int kLingerTime = 3000; 550 const int kLingerTime = 3000;
550 551
551 // We might get re-enabled right before we are closed (sequence is: we get 552 // We might get re-enabled right before we are closed (sequence is: we get
552 // deactivated, we call close, before we are actually closed we get 553 // deactivated, we call close, before we are actually closed we get
553 // reactivated). Don't do the disabling of the parent in such cases. 554 // reactivated). Don't do the disabling of the parent in such cases.
554 if (action == WA_ACTIVE && !has_been_activated_) { 555 if (action == WA_ACTIVE && !has_been_activated_) {
555 has_been_activated_ = true; 556 has_been_activated_ = true;
556 557
557 ::EnableWindow(GetParent(), false); 558 ::EnableWindow(GetParent(), false);
558 559
559 MessageLoop::current()->PostDelayedTask(FROM_HERE, 560 MessageLoop::current()->PostDelayedTask(
560 enable_window_method_factory_.NewRunnableMethod( 561 FROM_HERE,
561 &FirstRunBubble::EnableParent), 562 base::Bind(&FirstRunBubble::EnableParent,
563 enable_window_method_factory_.GetWeakPtr()),
562 kLingerTime); 564 kLingerTime);
563 return; 565 return;
564 } 566 }
565 567
566 // Keep window from automatically closing until kLingerTime has passed. 568 // Keep window from automatically closing until kLingerTime has passed.
567 if (::IsWindowEnabled(GetParent())) 569 if (::IsWindowEnabled(GetParent()))
568 Bubble::OnActivate(action, minimized, window); 570 Bubble::OnActivate(action, minimized, window);
569 } 571 }
570 #endif 572 #endif
571 573
572 void FirstRunBubble::BubbleClosing(Bubble* bubble, bool closed_by_escape) { 574 void FirstRunBubble::BubbleClosing(Bubble* bubble, bool closed_by_escape) {
573 // Make sure our parent window is re-enabled. 575 // Make sure our parent window is re-enabled.
574 if (!IsWindowEnabled(GetParent())) 576 if (!IsWindowEnabled(GetParent()))
575 ::EnableWindow(GetParent(), true); 577 ::EnableWindow(GetParent(), true);
576 } 578 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/first_run_bubble.h ('k') | chrome/browser/ui/views/notifications/balloon_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698