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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_installed_bubble.cc

Issue 14307023: chrome: Use base::MessageLoop. (Part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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) 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/extensions/extension_installed_bubble.h" 5 #include "chrome/browser/ui/views/extensions/extension_installed_bubble.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 void ExtensionInstalledBubble::Observe( 571 void ExtensionInstalledBubble::Observe(
572 int type, 572 int type,
573 const content::NotificationSource& source, 573 const content::NotificationSource& source,
574 const content::NotificationDetails& details) { 574 const content::NotificationDetails& details) {
575 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { 575 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
576 const Extension* extension = 576 const Extension* extension =
577 content::Details<const Extension>(details).ptr(); 577 content::Details<const Extension>(details).ptr();
578 if (extension == extension_) { 578 if (extension == extension_) {
579 animation_wait_retries_ = 0; 579 animation_wait_retries_ = 0;
580 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. 580 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run.
581 MessageLoopForUI::current()->PostTask( 581 base::MessageLoopForUI::current()->PostTask(
582 FROM_HERE, 582 FROM_HERE,
583 base::Bind(&ExtensionInstalledBubble::ShowInternal, 583 base::Bind(&ExtensionInstalledBubble::ShowInternal,
584 weak_factory_.GetWeakPtr())); 584 weak_factory_.GetWeakPtr()));
585 } 585 }
586 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { 586 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
587 const Extension* extension = 587 const Extension* extension =
588 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; 588 content::Details<extensions::UnloadedExtensionInfo>(details)->extension;
589 if (extension == extension_) 589 if (extension == extension_)
590 extension_ = NULL; 590 extension_ = NULL;
591 } else if (type == chrome::NOTIFICATION_BROWSER_CLOSING) { 591 } else if (type == chrome::NOTIFICATION_BROWSER_CLOSING) {
592 delete this; 592 delete this;
593 } else { 593 } else {
594 NOTREACHED() << L"Received unexpected notification"; 594 NOTREACHED() << L"Received unexpected notification";
595 } 595 }
596 } 596 }
597 597
598 void ExtensionInstalledBubble::ShowInternal() { 598 void ExtensionInstalledBubble::ShowInternal() {
599 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); 599 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
600 extensions::ExtensionActionManager* extension_action_manager = 600 extensions::ExtensionActionManager* extension_action_manager =
601 extensions::ExtensionActionManager::Get(browser_->profile()); 601 extensions::ExtensionActionManager::Get(browser_->profile());
602 602
603 views::View* reference_view = NULL; 603 views::View* reference_view = NULL;
604 if (type_ == BROWSER_ACTION) { 604 if (type_ == BROWSER_ACTION) {
605 BrowserActionsContainer* container = 605 BrowserActionsContainer* container =
606 browser_view->GetToolbarView()->browser_actions(); 606 browser_view->GetToolbarView()->browser_actions();
607 if (container->animating() && 607 if (container->animating() &&
608 animation_wait_retries_++ < kAnimationWaitMaxRetry) { 608 animation_wait_retries_++ < kAnimationWaitMaxRetry) {
609 // We don't know where the view will be until the container has stopped 609 // We don't know where the view will be until the container has stopped
610 // animating, so check back in a little while. 610 // animating, so check back in a little while.
611 MessageLoopForUI::current()->PostDelayedTask( 611 base::MessageLoopForUI::current()->PostDelayedTask(
612 FROM_HERE, 612 FROM_HERE,
613 base::Bind(&ExtensionInstalledBubble::ShowInternal, 613 base::Bind(&ExtensionInstalledBubble::ShowInternal,
614 weak_factory_.GetWeakPtr()), 614 weak_factory_.GetWeakPtr()),
615 base::TimeDelta::FromMilliseconds(kAnimationWaitTime)); 615 base::TimeDelta::FromMilliseconds(kAnimationWaitTime));
616 return; 616 return;
617 } 617 }
618 reference_view = container->GetBrowserActionView( 618 reference_view = container->GetBrowserActionView(
619 extension_action_manager->GetBrowserAction(*extension_)); 619 extension_action_manager->GetBrowserAction(*extension_));
620 // If the view is not visible then it is in the chevron, so point the 620 // If the view is not visible then it is in the chevron, so point the
621 // install bubble to the chevron instead. If this is an incognito window, 621 // install bubble to the chevron instead. If this is an incognito window,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 673
674 void ExtensionInstalledBubble::WindowClosing() { 674 void ExtensionInstalledBubble::WindowClosing() {
675 if (extension_ && type_ == PAGE_ACTION) { 675 if (extension_ && type_ == PAGE_ACTION) {
676 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); 676 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
677 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( 677 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction(
678 extensions::ExtensionActionManager::Get(browser_->profile())-> 678 extensions::ExtensionActionManager::Get(browser_->profile())->
679 GetPageAction(*extension_), 679 GetPageAction(*extension_),
680 false); // preview_enabled 680 false); // preview_enabled
681 } 681 }
682 } 682 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698