| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_view.h" | 5 #include "chrome/browser/ui/views/extensions/extension_installed_bubble_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 ExtensionInstalledBubbleView::ExtensionInstalledBubbleView( | 520 ExtensionInstalledBubbleView::ExtensionInstalledBubbleView( |
| 521 const Extension* extension, Browser *browser, const SkBitmap& icon) | 521 const Extension* extension, Browser *browser, const SkBitmap& icon) |
| 522 : bubble_(this, extension, browser, icon) { | 522 : bubble_(this, extension, browser, icon) { |
| 523 } | 523 } |
| 524 | 524 |
| 525 ExtensionInstalledBubbleView::~ExtensionInstalledBubbleView() {} | 525 ExtensionInstalledBubbleView::~ExtensionInstalledBubbleView() {} |
| 526 | 526 |
| 527 bool ExtensionInstalledBubbleView::MaybeShowNow() { | 527 bool ExtensionInstalledBubbleView::MaybeShowNow() { |
| 528 BrowserView* browser_view = | 528 BrowserView* browser_view = |
| 529 BrowserView::GetBrowserViewForBrowser(bubble_.browser()); | 529 BrowserView::GetBrowserViewForBrowser(bubble_.browser()); |
| 530 extensions::ExtensionActionManager* extension_action_manager = | |
| 531 extensions::ExtensionActionManager::Get(bubble_.browser()->profile()); | |
| 532 | 530 |
| 533 views::View* reference_view = NULL; | 531 views::View* reference_view = NULL; |
| 534 if (bubble_.type() == bubble_.BROWSER_ACTION) { | 532 if (bubble_.type() == bubble_.BROWSER_ACTION) { |
| 535 BrowserActionsContainer* container = | 533 BrowserActionsContainer* container = |
| 536 browser_view->GetToolbarView()->browser_actions(); | 534 browser_view->GetToolbarView()->browser_actions(); |
| 537 if (container->animating()) | 535 if (container->animating()) |
| 538 return false; | 536 return false; |
| 539 | 537 |
| 540 reference_view = container->GetBrowserActionView( | 538 reference_view = container->GetViewForExtension(bubble_.extension()); |
| 541 extension_action_manager->GetBrowserAction(*bubble_.extension())); | |
| 542 // If the view is not visible then it is in the chevron, so point the | 539 // If the view is not visible then it is in the chevron, so point the |
| 543 // install bubble to the chevron instead. If this is an incognito window, | 540 // install bubble to the chevron instead. If this is an incognito window, |
| 544 // both could be invisible. | 541 // both could be invisible. |
| 545 if (!reference_view || !reference_view->visible()) { | 542 if (!reference_view || !reference_view->visible()) { |
| 546 reference_view = container->chevron(); | 543 reference_view = container->chevron(); |
| 547 if (!reference_view || !reference_view->visible()) | 544 if (!reference_view || !reference_view->visible()) |
| 548 reference_view = NULL; // fall back to app menu below. | 545 reference_view = NULL; // fall back to app menu below. |
| 549 } | 546 } |
| 550 } else if (bubble_.type() == bubble_.PAGE_ACTION) { | 547 } else if (bubble_.type() == bubble_.PAGE_ACTION) { |
| 551 LocationBarView* location_bar_view = browser_view->GetLocationBarView(); | 548 LocationBarView* location_bar_view = browser_view->GetLocationBarView(); |
| 552 ExtensionAction* page_action = | 549 ExtensionAction* page_action = |
| 553 extension_action_manager->GetPageAction(*bubble_.extension()); | 550 extensions::ExtensionActionManager::Get(bubble_.browser()->profile())-> |
| 551 GetPageAction(*bubble_.extension()); |
| 554 location_bar_view->SetPreviewEnabledPageAction(page_action, | 552 location_bar_view->SetPreviewEnabledPageAction(page_action, |
| 555 true); // preview_enabled | 553 true); // preview_enabled |
| 556 reference_view = location_bar_view->GetPageActionView(page_action); | 554 reference_view = location_bar_view->GetPageActionView(page_action); |
| 557 DCHECK(reference_view); | 555 DCHECK(reference_view); |
| 558 } else if (bubble_.type() == bubble_.OMNIBOX_KEYWORD) { | 556 } else if (bubble_.type() == bubble_.OMNIBOX_KEYWORD) { |
| 559 LocationBarView* location_bar_view = browser_view->GetLocationBarView(); | 557 LocationBarView* location_bar_view = browser_view->GetLocationBarView(); |
| 560 reference_view = location_bar_view; | 558 reference_view = location_bar_view; |
| 561 DCHECK(reference_view); | 559 DCHECK(reference_view); |
| 562 } | 560 } |
| 563 | 561 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 void ExtensionInstalledBubbleView::WindowClosing() { | 597 void ExtensionInstalledBubbleView::WindowClosing() { |
| 600 if (bubble_.extension() && bubble_.type() == bubble_.PAGE_ACTION) { | 598 if (bubble_.extension() && bubble_.type() == bubble_.PAGE_ACTION) { |
| 601 BrowserView* browser_view = | 599 BrowserView* browser_view = |
| 602 BrowserView::GetBrowserViewForBrowser(bubble_.browser()); | 600 BrowserView::GetBrowserViewForBrowser(bubble_.browser()); |
| 603 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( | 601 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( |
| 604 extensions::ExtensionActionManager::Get(bubble_.browser()->profile())-> | 602 extensions::ExtensionActionManager::Get(bubble_.browser()->profile())-> |
| 605 GetPageAction(*bubble_.extension()), | 603 GetPageAction(*bubble_.extension()), |
| 606 false); // preview_enabled | 604 false); // preview_enabled |
| 607 } | 605 } |
| 608 } | 606 } |
| OLD | NEW |