| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/devtools/devtools_window.h" | 17 #include "chrome/browser/devtools/devtools_window.h" |
| 18 #include "chrome/browser/extensions/extension_host.h" | 18 #include "chrome/browser/extensions/extension_host.h" |
| 19 #include "chrome/browser/extensions/extension_process_manager.h" | 19 #include "chrome/browser/extensions/extension_host_factory.h" |
| 20 #include "chrome/browser/extensions/extension_system.h" | |
| 21 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 24 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 23 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 25 #include "content/public/browser/devtools_agent_host.h" | 24 #include "content/public/browser/devtools_agent_host.h" |
| 26 #include "content/public/browser/devtools_manager.h" | 25 #include "content/public/browser/devtools_manager.h" |
| 27 #include "content/public/browser/notification_details.h" | 26 #include "content/public/browser/notification_details.h" |
| 28 #include "content/public/browser/notification_source.h" | 27 #include "content/public/browser/notification_source.h" |
| 29 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
| 30 #include "content/public/browser/render_widget_host_view.h" | 29 #include "content/public/browser/render_widget_host_view.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 71 } |
| 73 | 72 |
| 74 ExtensionPopupGtk::~ExtensionPopupGtk() { | 73 ExtensionPopupGtk::~ExtensionPopupGtk() { |
| 75 content::DevToolsManager::GetInstance()->RemoveAgentStateCallback( | 74 content::DevToolsManager::GetInstance()->RemoveAgentStateCallback( |
| 76 devtools_callback_); | 75 devtools_callback_); |
| 77 } | 76 } |
| 78 | 77 |
| 79 // static | 78 // static |
| 80 void ExtensionPopupGtk::Show(const GURL& url, Browser* browser, | 79 void ExtensionPopupGtk::Show(const GURL& url, Browser* browser, |
| 81 GtkWidget* anchor, ShowAction show_action) { | 80 GtkWidget* anchor, ShowAction show_action) { |
| 82 ExtensionProcessManager* manager = | 81 extensions::ExtensionHost* host = |
| 83 extensions::ExtensionSystem::Get(browser->profile())->process_manager(); | 82 extensions::ExtensionHostFactory::CreatePopupHost(url, browser); |
| 84 DCHECK(manager); | |
| 85 if (!manager) | |
| 86 return; | |
| 87 | |
| 88 extensions::ExtensionHost* host = manager->CreatePopupHost(url, browser); | |
| 89 // This object will delete itself when the bubble is closed. | 83 // This object will delete itself when the bubble is closed. |
| 90 new ExtensionPopupGtk(browser, host, anchor, show_action); | 84 new ExtensionPopupGtk(browser, host, anchor, show_action); |
| 91 } | 85 } |
| 92 | 86 |
| 93 void ExtensionPopupGtk::Observe(int type, | 87 void ExtensionPopupGtk::Observe(int type, |
| 94 const content::NotificationSource& source, | 88 const content::NotificationSource& source, |
| 95 const content::NotificationDetails& details) { | 89 const content::NotificationDetails& details) { |
| 96 switch (type) { | 90 switch (type) { |
| 97 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: | 91 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: |
| 98 if (content::Details<extensions::ExtensionHost>(host_.get()) == details) | 92 if (content::Details<extensions::ExtensionHost>(host_.get()) == details) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 187 |
| 194 void ExtensionPopupGtk::DestroyPopupWithoutResult() { | 188 void ExtensionPopupGtk::DestroyPopupWithoutResult() { |
| 195 DestroyPopup(); | 189 DestroyPopup(); |
| 196 } | 190 } |
| 197 | 191 |
| 198 gfx::Rect ExtensionPopupGtk::GetViewBounds() { | 192 gfx::Rect ExtensionPopupGtk::GetViewBounds() { |
| 199 GtkAllocation allocation; | 193 GtkAllocation allocation; |
| 200 gtk_widget_get_allocation(host_->view()->native_view(), &allocation); | 194 gtk_widget_get_allocation(host_->view()->native_view(), &allocation); |
| 201 return gfx::Rect(allocation); | 195 return gfx::Rect(allocation); |
| 202 } | 196 } |
| OLD | NEW |