summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-19 18:27:09 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-19 18:27:09 +0000
commit810e622b58b4da015c11e8b6c71f3e95b23afe1b (patch)
tree56c0cf5e6ab1e6ea3f0a4a5cc8c26d0cd651d24f
parentf38b16fd2753b2d603e0a2a137227a132c77057b (diff)
downloadchromium_src-810e622b58b4da015c11e8b6c71f3e95b23afe1b.zip
chromium_src-810e622b58b4da015c11e8b6c71f3e95b23afe1b.tar.gz
chromium_src-810e622b58b4da015c11e8b6c71f3e95b23afe1b.tar.bz2
Fix inspection of extensions.
As a bonus, debugging of extensions now works. Go OOP inspector team! Inspection code was calling RVHD::GetProfile(), which was not implemented by ExtensionHost. Looking into this, it seems better to just remove the method from the interface since Profile is already accessible by way of RVH. The only caller to RVHD::GetProfile() besides the inspector was HWNDHtmlView which is itself dead code, so I removed it too. Review URL: http://codereview.chromium.org/115501 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16392 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/debugger/devtools_manager.cc16
-rw-r--r--chrome/browser/extensions/extension_host.cc4
-rw-r--r--chrome/browser/extensions/extension_host.h2
-rw-r--r--chrome/browser/extensions/extensions_ui.cc3
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h3
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc4
-rw-r--r--chrome/browser/tab_contents/interstitial_page.h1
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc4
-rw-r--r--chrome/browser/tab_contents/tab_contents.h1
-rw-r--r--chrome/browser/views/browser_views.vcproj8
-rw-r--r--chrome/browser/views/hwnd_html_view.cc108
-rw-r--r--chrome/browser/views/hwnd_html_view.h81
-rw-r--r--chrome/chrome.gyp2
-rw-r--r--chrome/common/temp_scaffolding_stubs.h13
14 files changed, 10 insertions, 240 deletions
diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc
index 3510df5..f3c485d 100644
--- a/chrome/browser/debugger/devtools_manager.cc
+++ b/chrome/browser/debugger/devtools_manager.cc
@@ -7,9 +7,7 @@
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/debugger/devtools_client_host.h"
#include "chrome/browser/renderer_host/render_view_host.h"
-#include "chrome/browser/tab_contents/navigation_controller.h"
-#include "chrome/browser/tab_contents/navigation_entry.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents/site_instance.h"
#include "chrome/common/devtools_messages.h"
#include "googleurl/src/gurl.h"
@@ -89,16 +87,12 @@ void DevToolsManager::ForwardToDevToolsClient(RenderViewHost* inspected_rvh,
void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh) {
DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh);
if (!host) {
- host = DevToolsWindow::Create(inspected_rvh->delegate()->GetProfile());
+ host = DevToolsWindow::Create(
+ inspected_rvh->site_instance()->browsing_instance()->profile());
RegisterDevToolsClientHostFor(inspected_rvh, host);
}
- TabContents* tab_contents = inspected_rvh->delegate()->GetAsTabContents();
- if (tab_contents) {
- NavigationEntry* entry = tab_contents->controller().GetActiveEntry();
- if (entry) {
- host->SetInspectedTabUrl(entry->url().possibly_invalid_spec());
- }
- }
+ host->SetInspectedTabUrl(
+ inspected_rvh->delegate()->GetURL().possibly_invalid_spec());
DevToolsWindow* window = host->AsDevToolsWindow();
if (window)
window->Show();
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index a38fdd5..61f7a41 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -7,6 +7,8 @@
#include "app/resource_bundle.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/extensions/extension.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/extensions/extension_view.h"
@@ -140,7 +142,7 @@ void ExtensionHost::ShowCreatedWidget(int route_id,
void ExtensionHost::ShowContextMenu(const ContextMenuParams& params) {
// TODO(erikkay) - This is a temporary hack. Show a menu here instead.
- render_view_host()->InspectElementAt(params.x, params.y);
+ g_browser_process->devtools_manager()->OpenDevToolsWindow(render_view_host());
}
void ExtensionHost::StartDragging(const WebDropData& drop_data) {
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index a6e19d9..fc5e0ca 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -40,8 +40,6 @@ class ExtensionHost : public RenderViewHostDelegate,
void CreateRenderView(const GURL& url, RenderWidgetHostView* host_view);
// RenderViewHostDelegate
- // TODO(mpcomplete): GetProfile is unused.
- virtual Profile* GetProfile() const { return NULL; }
virtual const GURL& GetURL() const { return url_; }
virtual WebPreferences GetWebkitPrefs();
virtual void RunJavaScriptMessage(
diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc
index d05e39a..e150840 100644
--- a/chrome/browser/extensions/extensions_ui.cc
+++ b/chrome/browser/extensions/extensions_ui.cc
@@ -9,6 +9,7 @@
#include "base/string_util.h"
#include "base/thread.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/extensions/extension.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/extensions/extensions_service.h"
@@ -114,7 +115,7 @@ void ExtensionsDOMHandler::HandleInspectMessage(const Value* value) {
return;
}
- host->InspectElementAt(0, 0);
+ g_browser_process->devtools_manager()->OpenDevToolsWindow(host);
}
static void CreateScriptFileDetailValue(
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index ca6edde..75a80d4 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -154,9 +154,6 @@ class RenderViewHostDelegate {
virtual View* GetViewDelegate() const { return NULL; }
virtual Save* GetSaveDelegate() const { return NULL; }
- // Retrieves the profile to be used.
- virtual Profile* GetProfile() const = 0;
-
// Gets the URL that is currently being displayed, if there is one.
virtual const GURL& GetURL() const = 0;
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc
index f697488..2f644e9 100644
--- a/chrome/browser/tab_contents/interstitial_page.cc
+++ b/chrome/browser/tab_contents/interstitial_page.cc
@@ -366,10 +366,6 @@ void InterstitialPage::SetInitialFocus(bool reverse) {
render_view_host_->SetInitialFocus(reverse);
}
-Profile* InterstitialPage::GetProfile() const {
- return tab_->profile();
-}
-
void InterstitialPage::DidNavigate(
RenderViewHost* render_view_host,
const ViewHostMsg_FrameNavigate_Params& params) {
diff --git a/chrome/browser/tab_contents/interstitial_page.h b/chrome/browser/tab_contents/interstitial_page.h
index c5f4afe..5ce1e9e 100644
--- a/chrome/browser/tab_contents/interstitial_page.h
+++ b/chrome/browser/tab_contents/interstitial_page.h
@@ -90,7 +90,6 @@ class InterstitialPage : public NotificationObserver,
const NotificationDetails& details);
// RenderViewHostDelegate implementation:
- virtual Profile* GetProfile() const;
virtual const GURL& GetURL() const { return url_; }
virtual WebPreferences GetWebkitPrefs() {
return WebPreferences();
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 9e74eaf..c136625 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -1598,10 +1598,6 @@ RenderViewHostDelegate::Save* TabContents::GetSaveDelegate() const {
return save_package_.get(); // May be NULL, but we can return NULL.
}
-Profile* TabContents::GetProfile() const {
- return profile();
-}
-
ExtensionFunctionDispatcher* TabContents::CreateExtensionFunctionDispatcher(
RenderViewHost* render_view_host,
const std::string& extension_id) {
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 3b749e6..9667c70 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -732,7 +732,6 @@ class TabContents : public PageNavigator,
virtual RenderViewHostDelegate::View* GetViewDelegate() const;
virtual RenderViewHostDelegate::Save* GetSaveDelegate() const;
- virtual Profile* GetProfile() const;
virtual ExtensionFunctionDispatcher *CreateExtensionFunctionDispatcher(
RenderViewHost* render_view_host,
const std::string& extension_id);
diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj
index 4a19a49..0542cbe 100644
--- a/chrome/browser/views/browser_views.vcproj
+++ b/chrome/browser/views/browser_views.vcproj
@@ -654,14 +654,6 @@
>
</File>
<File
- RelativePath=".\hwnd_html_view.cc"
- >
- </File>
- <File
- RelativePath=".\hwnd_html_view.h"
- >
- </File>
- <File
RelativePath=".\importer_lock_view.cc"
>
</File>
diff --git a/chrome/browser/views/hwnd_html_view.cc b/chrome/browser/views/hwnd_html_view.cc
deleted file mode 100644
index bbda2c3..0000000
--- a/chrome/browser/views/hwnd_html_view.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/views/hwnd_html_view.h"
-
-#include "chrome/browser/renderer_host/render_view_host.h"
-#include "chrome/browser/renderer_host/render_widget_host_view_win.h"
-#include "chrome/browser/renderer_host/render_view_host_delegate.h"
-#include "chrome/browser/tab_contents/site_instance.h"
-#include "views/widget/widget.h"
-#include "views/widget/widget_win.h"
-
-HWNDHtmlView::HWNDHtmlView(const GURL& content_url,
- RenderViewHostDelegate* delegate,
- bool allow_dom_ui_bindings, SiteInstance* instance)
- : render_view_host_(NULL),
- content_url_(content_url),
- allow_dom_ui_bindings_(allow_dom_ui_bindings),
- delegate_(delegate),
- initialized_(false),
- site_instance_(instance) {
- if (!site_instance_)
- site_instance_ = SiteInstance::CreateSiteInstance(delegate_->GetProfile());
-}
-
-HWNDHtmlView::~HWNDHtmlView() {
- if (render_view_host_) {
- Detach();
- render_view_host_->Shutdown();
- render_view_host_ = NULL;
- }
-}
-
-void HWNDHtmlView::SetVisible(bool is_visible) {
- HWNDView::SetVisible(is_visible);
-
- // Also tell RenderWidgetHostView the new visibility. Despite its name, it is
- // not part of the View heirarchy and does not know about the change unless we
- // tell it.
- if (render_view_host() && render_view_host()->view()) {
- if (is_visible)
- render_view_host()->view()->Show();
- else
- render_view_host()->view()->Hide();
- }
-}
-
-void HWNDHtmlView::DidChangeBounds(const gfx::Rect& previous,
- const gfx::Rect& current) {
- // Propagate the new size to RenderWidgetHostView.
- // We can't send size zero because RenderWidget DCHECKs that.
- if (render_view_host() && render_view_host()->view() && !current.IsEmpty())
- render_view_host()->view()->SetSize(gfx::Size(width(), height()));
-}
-
-void HWNDHtmlView::SetBackground(const SkBitmap& background) {
- if (initialized_) {
- DCHECK(render_view_host_);
- render_view_host_->view()->SetBackground(background);
- } else {
- pending_background_ = background;
- }
-}
-
-void HWNDHtmlView::InitHidden() {
- // TODO(mpcomplete): make it possible to create a RenderView without an HWND.
- views::WidgetWin* win = new views::WidgetWin;
- win->Init(NULL, gfx::Rect(), true);
- win->SetContentsView(this);
-}
-
-void HWNDHtmlView::Init(HWND parent_hwnd) {
- DCHECK(!render_view_host_) << "Already initialized.";
- RenderViewHost* rvh = new RenderViewHost(
- site_instance_, delegate_, MSG_ROUTING_NONE, NULL);
- render_view_host_ = rvh;
-
- RenderWidgetHostViewWin* view = new RenderWidgetHostViewWin(rvh);
- rvh->set_view(view);
-
- // Create the HWND. Note:
- // RenderWidgetHostHWND supports windowed plugins, but if we ever also wanted
- // to support constrained windows with this, we would need an additional
- // HWND to parent off of because windowed plugin HWNDs cannot exist in the
- // same z-order as constrained windows.
- HWND hwnd = view->Create(parent_hwnd);
- view->ShowWindow(SW_SHOW);
- views::HWNDView::Attach(hwnd);
-
- // Start up the renderer.
- if (allow_dom_ui_bindings_)
- rvh->AllowDOMUIBindings();
- CreatingRenderer();
- rvh->CreateRenderView();
- if (!pending_background_.empty()) {
- rvh->view()->SetBackground(pending_background_);
- pending_background_.reset();
- }
- rvh->NavigateToURL(content_url_);
- initialized_ = true;
-}
-
-void HWNDHtmlView::ViewHierarchyChanged(bool is_add, View* parent,
- View* child) {
- if (is_add && GetWidget() && !initialized_)
- Init(GetWidget()->GetNativeView());
-}
diff --git a/chrome/browser/views/hwnd_html_view.h b/chrome/browser/views/hwnd_html_view.h
deleted file mode 100644
index 5cd9dee..0000000
--- a/chrome/browser/views/hwnd_html_view.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_VIEWS_HWND_HTML_VIEW_H_
-#define CHROME_BROWSER_VIEWS_HWND_HTML_VIEW_H_
-
-#include "googleurl/src/gurl.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "views/controls/hwnd_view.h"
-
-class RenderViewHost;
-class RenderViewHostDelegate;
-class SiteInstance;
-
-// A simple view that wraps a RenderViewHost in an HWNDView to facilitate
-// rendering HTML as arbitrary browser views.
-// TODO(timsteele): (bug 1317303). This should replace DOMView.
-class HWNDHtmlView : public views::HWNDView {
- public:
- HWNDHtmlView(const GURL& content_url, RenderViewHostDelegate* delegate,
- bool allow_dom_ui_bindings, SiteInstance* instance);
- virtual ~HWNDHtmlView();
-
- // View
- virtual void SetVisible(bool is_visible);
-
- virtual void DidChangeBounds(const gfx::Rect& previous,
- const gfx::Rect& current);
-
- // HWNDHtmlView
- RenderViewHost* render_view_host() { return render_view_host_; }
-
- // Initialize the view without a parent window. Used for extensions that
- // don't display UI.
- void InitHidden();
-
- // Set a custom background for the view. The background will be tiled.
- virtual void SetBackground(const SkBitmap& background);
-
- protected:
- // View overrides.
- virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child);
-
- // Called just before we create the RenderView, to give subclasses an
- // opportunity to do some setup.
- virtual void CreatingRenderer() {}
-
- SiteInstance* site_instance() { return site_instance_; }
-
- private:
- // Initialize the view, parented to |parent|, and show it.
- void Init(HWND parent);
-
- // The URL of the HTML content to render and show in this view.
- GURL content_url_;
-
- // Our HTML rendering component.
- RenderViewHost* render_view_host_;
-
- // The site instance that the renderer belongs to.
- SiteInstance* site_instance_;
-
- // Whether or not the rendered content is permitted to send messages back to
- // the view, through |delegate_| via ProcessDOMUIMessage.
- bool allow_dom_ui_bindings_;
-
- // True after Init() has completed.
- bool initialized_;
-
- // The delegate for our render_view_host.
- RenderViewHostDelegate* delegate_;
-
- // The background the view should have once it is initialized. This is set
- // when the view has a custom background, but hasn't been inititalized yet.
- SkBitmap pending_background_;
-
- DISALLOW_EVIL_CONSTRUCTORS(HWNDHtmlView);
-};
-
-#endif // CHROME_BROWSER_VIEWS_HWND_HTML_VIEW_H_
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index be84b6a..e1e7559 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1369,8 +1369,6 @@
'browser/views/html_dialog_view.cc',
'browser/views/html_dialog_view.h',
'browser/views/hung_renderer_view.cc',
- 'browser/views/hwnd_html_view.cc',
- 'browser/views/hwnd_html_view.h',
'browser/views/importer_lock_view.cc',
'browser/views/importer_lock_view.h',
'browser/views/importer_view.cc',
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index 1b6ae9c..ac62d3c1 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -508,17 +508,4 @@ class HWNDView {
};
} // namespace views
-class HWNDHtmlView : public views::HWNDView {
- public:
- HWNDHtmlView(const GURL& content_url, RenderViewHostDelegate* delegate,
- bool allow_dom_ui_bindings, SiteInstance* instance) {
- NOTIMPLEMENTED();
- }
- virtual ~HWNDHtmlView() {}
-
- RenderViewHost* render_view_host() { NOTIMPLEMENTED(); return NULL; }
- SiteInstance* site_instance() { NOTIMPLEMENTED(); return NULL; }
-};
-
-
#endif // CHROME_COMMON_TEMP_SCAFFOLDING_STUBS_H_