| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/extension_popup_gtk.h" | 5 #include "chrome/browser/gtk/extension_popup_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" |
| 9 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
| 10 #include "chrome/browser/browser_window.h" | 11 #include "chrome/browser/browser_window.h" |
| 11 #include "chrome/browser/profile.h" | 12 #include "chrome/browser/profile.h" |
| 12 #include "chrome/browser/extensions/extension_host.h" | 13 #include "chrome/browser/extensions/extension_host.h" |
| 13 #include "chrome/browser/extensions/extension_process_manager.h" | 14 #include "chrome/browser/extensions/extension_process_manager.h" |
| 14 #include "chrome/browser/gtk/gtk_theme_provider.h" | 15 #include "chrome/browser/gtk/gtk_theme_provider.h" |
| 15 #include "chrome/common/notification_service.h" | 16 #include "chrome/common/notification_service.h" |
| 16 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 17 | 18 |
| 18 ExtensionPopupGtk::ExtensionPopupGtk(Browser* browser, | 19 ExtensionPopupGtk::ExtensionPopupGtk(Browser* browser, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 NOTREACHED() << "Received unexpected notification"; | 54 NOTREACHED() << "Received unexpected notification"; |
| 54 } | 55 } |
| 55 } | 56 } |
| 56 | 57 |
| 57 void ExtensionPopupGtk::ShowPopup() { | 58 void ExtensionPopupGtk::ShowPopup() { |
| 58 if (bubble_) { | 59 if (bubble_) { |
| 59 NOTREACHED(); | 60 NOTREACHED(); |
| 60 return; | 61 return; |
| 61 } | 62 } |
| 62 | 63 |
| 64 // We'll be in the upper-right corner of the window for LTR languages, so we |
| 65 // want to put the arrow at the upper-right corner of the bubble to match the |
| 66 // page and app menus. |
| 67 InfoBubbleGtk::ArrowLocationGtk arrow_location = |
| 68 (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) ? |
| 69 InfoBubbleGtk::ARROW_LOCATION_TOP_RIGHT : |
| 70 InfoBubbleGtk::ARROW_LOCATION_TOP_LEFT; |
| 63 bubble_ = InfoBubbleGtk::Show(browser_->window()->GetNativeHandle(), | 71 bubble_ = InfoBubbleGtk::Show(browser_->window()->GetNativeHandle(), |
| 64 relative_to_, host_->view()->native_view(), | 72 relative_to_, |
| 73 host_->view()->native_view(), |
| 74 arrow_location, |
| 65 GtkThemeProvider::GetFrom(browser_->profile()), | 75 GtkThemeProvider::GetFrom(browser_->profile()), |
| 66 this); | 76 this); |
| 67 } | 77 } |
| 68 | 78 |
| 69 void ExtensionPopupGtk::DestroyPopup() { | 79 void ExtensionPopupGtk::DestroyPopup() { |
| 70 if (!bubble_) { | 80 if (!bubble_) { |
| 71 NOTREACHED(); | 81 NOTREACHED(); |
| 72 return; | 82 return; |
| 73 } | 83 } |
| 74 | 84 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 86 ExtensionProcessManager* manager = | 96 ExtensionProcessManager* manager = |
| 87 browser->profile()->GetExtensionProcessManager(); | 97 browser->profile()->GetExtensionProcessManager(); |
| 88 DCHECK(manager); | 98 DCHECK(manager); |
| 89 if (!manager) | 99 if (!manager) |
| 90 return; | 100 return; |
| 91 | 101 |
| 92 ExtensionHost* host = manager->CreatePopup(url, browser); | 102 ExtensionHost* host = manager->CreatePopup(url, browser); |
| 93 // This object will delete itself when the info bubble is closed. | 103 // This object will delete itself when the info bubble is closed. |
| 94 new ExtensionPopupGtk(browser, host, relative_to); | 104 new ExtensionPopupGtk(browser, host, relative_to); |
| 95 } | 105 } |
| OLD | NEW |