| OLD | NEW |
| 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/gtk/extensions/extension_popup_gtk.h" | 5 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); | 168 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); |
| 169 | 169 |
| 170 // Only one instance should be showing at a time. Get rid of the old one, if | 170 // Only one instance should be showing at a time. Get rid of the old one, if |
| 171 // any. Typically, |current_extension_popup_| will be NULL, but it can be | 171 // any. Typically, |current_extension_popup_| will be NULL, but it can be |
| 172 // non-NULL if a browser action button is clicked while another extension | 172 // non-NULL if a browser action button is clicked while another extension |
| 173 // popup's extension host is still loading. | 173 // popup's extension host is still loading. |
| 174 if (current_extension_popup_) | 174 if (current_extension_popup_) |
| 175 current_extension_popup_->DestroyPopup(); | 175 current_extension_popup_->DestroyPopup(); |
| 176 current_extension_popup_ = this; | 176 current_extension_popup_ = this; |
| 177 | 177 |
| 178 GtkWidget* border_box = gtk_alignment_new(0, 0, 1.0, 1.0); |
| 179 // This border is necessary so the bubble's corners do not get cut off by the |
| 180 // render view. |
| 181 gtk_container_set_border_width(GTK_CONTAINER(border_box), 2); |
| 182 gtk_container_add(GTK_CONTAINER(border_box), host_->view()->native_view()); |
| 183 |
| 178 // We'll be in the upper-right corner of the window for LTR languages, so we | 184 // We'll be in the upper-right corner of the window for LTR languages, so we |
| 179 // want to put the arrow at the upper-right corner of the bubble to match the | 185 // want to put the arrow at the upper-right corner of the bubble to match the |
| 180 // page and app menus. | 186 // page and app menus. |
| 181 BubbleGtk::ArrowLocationGtk arrow_location = | 187 BubbleGtk::ArrowLocationGtk arrow_location = |
| 182 !base::i18n::IsRTL() ? | 188 !base::i18n::IsRTL() ? |
| 183 BubbleGtk::ARROW_LOCATION_TOP_RIGHT : | 189 BubbleGtk::ARROW_LOCATION_TOP_RIGHT : |
| 184 BubbleGtk::ARROW_LOCATION_TOP_LEFT; | 190 BubbleGtk::ARROW_LOCATION_TOP_LEFT; |
| 185 bubble_ = BubbleGtk::Show(anchor_, | 191 bubble_ = BubbleGtk::Show(anchor_, |
| 186 NULL, | 192 NULL, |
| 187 host_->view()->native_view(), | 193 border_box, |
| 188 arrow_location, | 194 arrow_location, |
| 189 being_inspected_ ? 0 : | 195 being_inspected_ ? 0 : |
| 190 BubbleGtk::POPUP_WINDOW | BubbleGtk::GRAB_INPUT, | 196 BubbleGtk::POPUP_WINDOW | BubbleGtk::GRAB_INPUT, |
| 191 GtkThemeService::GetFrom(browser_->profile()), | 197 GtkThemeService::GetFrom(browser_->profile()), |
| 192 this); | 198 this); |
| 193 } | 199 } |
| 194 | 200 |
| 195 void ExtensionPopupGtk::DestroyPopupWithoutResult() { | 201 void ExtensionPopupGtk::DestroyPopupWithoutResult() { |
| 196 DestroyPopup(); | 202 DestroyPopup(); |
| 197 } | 203 } |
| 198 | 204 |
| 199 gfx::Rect ExtensionPopupGtk::GetViewBounds() { | 205 gfx::Rect ExtensionPopupGtk::GetViewBounds() { |
| 200 GtkAllocation allocation; | 206 GtkAllocation allocation; |
| 201 gtk_widget_get_allocation(host_->view()->native_view(), &allocation); | 207 gtk_widget_get_allocation(host_->view()->native_view(), &allocation); |
| 202 return gfx::Rect(allocation); | 208 return gfx::Rect(allocation); |
| 203 } | 209 } |
| OLD | NEW |