| 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" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/extensions/extension_install_ui.h" | 14 #include "chrome/browser/extensions/extension_install_ui.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/views/browser_actions_container.h" | 18 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 19 #include "chrome/browser/ui/views/frame/browser_view.h" | 19 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 20 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 20 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 21 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 21 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 22 #include "chrome/browser/ui/views/toolbar_view.h" | 22 #include "chrome/browser/ui/views/toolbar_view.h" |
| 23 #include "chrome/browser/ui/views/window.h" |
| 23 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/extensions/extension_action.h" | 26 #include "chrome/common/extensions/extension_action.h" |
| 26 #include "content/public/browser/notification_details.h" | 27 #include "content/public/browser/notification_details.h" |
| 27 #include "content/public/browser/notification_source.h" | 28 #include "content/public/browser/notification_source.h" |
| 28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 29 #include "grit/theme_resources_standard.h" | 30 #include "grit/theme_resources_standard.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 32 #include "ui/views/controls/button/image_button.h" | 33 #include "ui/views/controls/button/image_button.h" |
| 33 #include "ui/views/controls/image_view.h" | 34 #include "ui/views/controls/image_view.h" |
| 34 #include "ui/views/controls/label.h" | 35 #include "ui/views/controls/label.h" |
| 35 #include "ui/views/controls/link.h" | 36 #include "ui/views/controls/link.h" |
| 36 #include "ui/views/controls/link_listener.h" | 37 #include "ui/views/controls/link_listener.h" |
| 37 #include "ui/views/layout/fill_layout.h" | 38 #include "ui/views/layout/fill_layout.h" |
| 38 #include "ui/views/layout/layout_constants.h" | 39 #include "ui/views/layout/layout_constants.h" |
| 39 #include "ui/views/view.h" | |
| 40 | 40 |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| 43 const int kIconSize = 43; | 43 const int kIconSize = 43; |
| 44 | 44 |
| 45 const int kRightColumnWidth = 285; | 45 const int kRightColumnWidth = 285; |
| 46 | 46 |
| 47 // The Bubble uses a BubbleBorder which adds about 6 pixels of whitespace | 47 // The Bubble uses a BubbleBorder which adds about 6 pixels of whitespace |
| 48 // around the content view. We compensate by reducing our outer borders by this | 48 // around the content view. We compensate by reducing our outer borders by this |
| 49 // amount + 4px. | 49 // amount + 4px. |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 } | 384 } |
| 385 | 385 |
| 386 // Default case. | 386 // Default case. |
| 387 if (reference_view == NULL) | 387 if (reference_view == NULL) |
| 388 reference_view = browser_view->GetToolbarView()->app_menu(); | 388 reference_view = browser_view->GetToolbarView()->app_menu(); |
| 389 set_anchor_view(reference_view); | 389 set_anchor_view(reference_view); |
| 390 | 390 |
| 391 SetLayoutManager(new views::FillLayout()); | 391 SetLayoutManager(new views::FillLayout()); |
| 392 AddChildView( | 392 AddChildView( |
| 393 new InstalledBubbleContent(browser_, extension_, type_, &icon_, this)); | 393 new InstalledBubbleContent(browser_, extension_, type_, &icon_, this)); |
| 394 views::BubbleDelegateView::CreateBubble(this); | 394 browser::CreateViewsBubble(this); |
| 395 StartFade(true); | 395 StartFade(true); |
| 396 } | 396 } |
| 397 | 397 |
| 398 gfx::Point ExtensionInstalledBubble::GetAnchorPoint() { | 398 gfx::Point ExtensionInstalledBubble::GetAnchorPoint() { |
| 399 // For omnibox keyword bubbles, move the arrow to point to the left edge | 399 // For omnibox keyword bubbles, move the arrow to point to the left edge |
| 400 // of the omnibox, just to the right of the icon. | 400 // of the omnibox, just to the right of the icon. |
| 401 if (type_ == OMNIBOX_KEYWORD) { | 401 if (type_ == OMNIBOX_KEYWORD) { |
| 402 LocationBarView* location_bar_view = | 402 LocationBarView* location_bar_view = |
| 403 BrowserView::GetBrowserViewForBrowser(browser_)->GetLocationBarView(); | 403 BrowserView::GetBrowserViewForBrowser(browser_)->GetLocationBarView(); |
| 404 return location_bar_view->GetLocationEntryOrigin().Add( | 404 return location_bar_view->GetLocationEntryOrigin().Add( |
| 405 gfx::Point(0, location_bar_view->location_entry_view()->height())); | 405 gfx::Point(0, location_bar_view->location_entry_view()->height())); |
| 406 } | 406 } |
| 407 return views::BubbleDelegateView::GetAnchorPoint(); | 407 return views::BubbleDelegateView::GetAnchorPoint(); |
| 408 } | 408 } |
| 409 | 409 |
| 410 views::BubbleBorder::ArrowLocation | 410 views::BubbleBorder::ArrowLocation |
| 411 ExtensionInstalledBubble::GetArrowLocation() const { | 411 ExtensionInstalledBubble::GetArrowLocation() const { |
| 412 return type_ == OMNIBOX_KEYWORD ? views::BubbleBorder::TOP_LEFT : | 412 return type_ == OMNIBOX_KEYWORD ? views::BubbleBorder::TOP_LEFT : |
| 413 views::BubbleBorder::TOP_RIGHT; | 413 views::BubbleBorder::TOP_RIGHT; |
| 414 } | 414 } |
| 415 | 415 |
| 416 void ExtensionInstalledBubble::WindowClosing() { | 416 void ExtensionInstalledBubble::WindowClosing() { |
| 417 if (extension_ && type_ == PAGE_ACTION) { | 417 if (extension_ && type_ == PAGE_ACTION) { |
| 418 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); | 418 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); |
| 419 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( | 419 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( |
| 420 extension_->page_action(), | 420 extension_->page_action(), |
| 421 false); // preview_enabled | 421 false); // preview_enabled |
| 422 } | 422 } |
| 423 } | 423 } |
| OLD | NEW |