| OLD | NEW |
| 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/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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 LocationBarView* location_bar_view = browser_view->GetLocationBarView(); | 383 LocationBarView* location_bar_view = browser_view->GetLocationBarView(); |
| 384 reference_view = location_bar_view; | 384 reference_view = location_bar_view; |
| 385 DCHECK(reference_view); | 385 DCHECK(reference_view); |
| 386 } | 386 } |
| 387 | 387 |
| 388 // Default case. | 388 // Default case. |
| 389 if (reference_view == NULL) | 389 if (reference_view == NULL) |
| 390 reference_view = browser_view->GetToolbarView()->app_menu(); | 390 reference_view = browser_view->GetToolbarView()->app_menu(); |
| 391 set_anchor_view(reference_view); | 391 set_anchor_view(reference_view); |
| 392 | 392 |
| 393 set_arrow_location(type_ == OMNIBOX_KEYWORD ? views::BubbleBorder::TOP_LEFT : |
| 394 views::BubbleBorder::TOP_RIGHT); |
| 393 SetLayoutManager(new views::FillLayout()); | 395 SetLayoutManager(new views::FillLayout()); |
| 394 AddChildView( | 396 AddChildView( |
| 395 new InstalledBubbleContent(browser_, extension_, type_, &icon_, this)); | 397 new InstalledBubbleContent(browser_, extension_, type_, &icon_, this)); |
| 396 browser::CreateViewsBubble(this); | 398 browser::CreateViewsBubble(this); |
| 397 StartFade(true); | 399 StartFade(true); |
| 398 } | 400 } |
| 399 | 401 |
| 400 gfx::Rect ExtensionInstalledBubble::GetAnchorRect() { | 402 gfx::Rect ExtensionInstalledBubble::GetAnchorRect() { |
| 401 // For omnibox keyword bubbles, move the arrow to point to the left edge | 403 // For omnibox keyword bubbles, move the arrow to point to the left edge |
| 402 // of the omnibox, just to the right of the icon. | 404 // of the omnibox, just to the right of the icon. |
| 403 if (type_ == OMNIBOX_KEYWORD) { | 405 if (type_ == OMNIBOX_KEYWORD) { |
| 404 LocationBarView* location_bar_view = | 406 LocationBarView* location_bar_view = |
| 405 BrowserView::GetBrowserViewForBrowser(browser_)->GetLocationBarView(); | 407 BrowserView::GetBrowserViewForBrowser(browser_)->GetLocationBarView(); |
| 406 return gfx::Rect(location_bar_view->GetLocationEntryOrigin().Add( | 408 return gfx::Rect(location_bar_view->GetLocationEntryOrigin(), |
| 407 gfx::Point(0, location_bar_view->location_entry_view()->height())), | 409 gfx::Size(0, location_bar_view->location_entry_view()->height())); |
| 408 gfx::Size()); | |
| 409 } | 410 } |
| 410 return views::BubbleDelegateView::GetAnchorRect(); | 411 return views::BubbleDelegateView::GetAnchorRect(); |
| 411 } | 412 } |
| 412 | 413 |
| 413 views::BubbleBorder::ArrowLocation | |
| 414 ExtensionInstalledBubble::GetArrowLocation() const { | |
| 415 return type_ == OMNIBOX_KEYWORD ? views::BubbleBorder::TOP_LEFT : | |
| 416 views::BubbleBorder::TOP_RIGHT; | |
| 417 } | |
| 418 | |
| 419 void ExtensionInstalledBubble::WindowClosing() { | 414 void ExtensionInstalledBubble::WindowClosing() { |
| 420 if (extension_ && type_ == PAGE_ACTION) { | 415 if (extension_ && type_ == PAGE_ACTION) { |
| 421 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); | 416 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); |
| 422 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( | 417 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( |
| 423 extension_->page_action(), | 418 extension_->page_action(), |
| 424 false); // preview_enabled | 419 false); // preview_enabled |
| 425 } | 420 } |
| 426 } | 421 } |
| OLD | NEW |