Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7617)

Unified Diff: chrome/browser/extensions/extension_host.cc

Issue 10913243: extensions: Add ExtensionView interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: weak Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/extensions/extension_host_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_host.cc
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 492455eadc89686f50491b7056e59f436d5bd13c..3e16f45b256dc3a77c2a993c4d1b6c91c8cb281d 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_tab_util.h"
+#include "chrome/browser/extensions/extension_view.h"
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/file_select_helper.h"
#include "chrome/browser/profiles/profile.h"
@@ -169,22 +170,20 @@ ExtensionHost::~ExtensionHost() {
ProcessCreationQueue::GetInstance()->Remove(this);
}
+void ExtensionHost::SetExtensionView(ExtensionView* view) {
+ extension_view_.reset(view);
+}
+
+const ExtensionView* ExtensionHost::GetExtensionView() const {
+ return extension_view_.get();
+}
+
+ExtensionView* ExtensionHost::GetExtensionView() {
+ return extension_view_.get();
+}
+
void ExtensionHost::CreateView(Browser* browser) {
-#if defined(TOOLKIT_VIEWS)
- view_.reset(new ExtensionViewViews(this, browser));
- // We own |view_|, so don't auto delete when it's removed from the view
- // hierarchy.
- view_->set_owned_by_client();
-#elif defined(OS_MACOSX)
- view_.reset(new ExtensionViewMac(this, browser));
- view_->Init();
-#elif defined(TOOLKIT_GTK)
- view_.reset(new ExtensionViewGtk(this, browser));
- view_->Init();
-#else
- // TODO(port)
- NOTREACHED();
-#endif
+ extension_view_.reset(ExtensionView::Create(this, browser));
}
WebContents* ExtensionHost::GetAssociatedWebContents() const {
@@ -234,8 +233,8 @@ void ExtensionHost::CreateRenderViewNow() {
extensions::WindowController*
ExtensionHost::GetExtensionWindowController() const {
- return view() && view()->browser() ?
- view()->browser()->extension_window_controller() : NULL;
+ return GetExtensionView() && GetExtensionView()->GetBrowser() ?
+ GetExtensionView()->GetBrowser()->extension_window_controller() : NULL;
}
const GURL& ExtensionHost::GetURL() const {
@@ -296,8 +295,8 @@ void ExtensionHost::Observe(int type,
void ExtensionHost::ResizeDueToAutoResize(WebContents* source,
const gfx::Size& new_size) {
- if (view())
- view()->ResizeDueToAutoResize(new_size);
+ if (GetExtensionView())
+ GetExtensionView()->ResizeDueToAutoResize(new_size);
}
void ExtensionHost::RenderViewGone(base::TerminationStatus status) {
@@ -343,8 +342,8 @@ void ExtensionHost::DidStopLoading(content::RenderViewHost* render_view_host) {
extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR ||
extension_host_type_ == chrome::VIEW_TYPE_PANEL) {
#if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX)
- if (view())
- view()->DidStopLoading();
+ if (GetExtensionView())
+ GetExtensionView()->DidStopLoading();
#endif
}
if (notify) {
@@ -413,9 +412,9 @@ void ExtensionHost::OnStartDownload(
content::WebContents* source, content::DownloadItem* download) {
// If |source| is in the context of a Browser, show the DownloadShelf on that
// Browser.
- if (!view() || !view()->browser())
+ if (!GetExtensionView() || !GetExtensionView()->GetBrowser())
return;
- static_cast<content::WebContentsDelegate*>(view()->browser())->
+ static_cast<content::WebContentsDelegate*>(GetExtensionView()->GetBrowser())->
OnStartDownload(source, download);
}
@@ -425,12 +424,13 @@ void ExtensionHost::WebIntentDispatch(
#if !defined(OS_ANDROID)
scoped_ptr<content::WebIntentsDispatcher> dispatcher(intents_dispatcher);
- Browser* browser = view() ? view()->browser()
+ Browser* browser = GetExtensionView() ? GetExtensionView()->GetBrowser()
: browser::FindBrowserWithWebContents(web_contents);
- // For background scripts/pages, there will be no view(). In this case, we
- // want to treat the intent as a browser-initiated one and deliver it into the
- // current browser. It probably came from a context menu click or similar.
+ // For background scripts/pages, there will be no GetExtensionView(). In this
+ // case, we want to treat the intent as a browser-initiated one and deliver it
+ // into the current browser. It probably came from a context menu click or
+ // similar.
if (!browser)
browser = web_intents::GetBrowserForBackgroundWebIntentDelivery(profile());
@@ -468,7 +468,8 @@ WebContents* ExtensionHost::OpenURLFromTab(WebContents* source,
case OFF_THE_RECORD: {
// Only allow these from hosts that are bound to a browser (e.g. popups).
// Otherwise they are not driven by a user gesture.
- Browser* browser = view() ? view()->browser() : NULL;
+ Browser* browser = GetExtensionView() ?
+ GetExtensionView()->GetBrowser() : NULL;
return browser ? browser->OpenURL(params) : NULL;
}
default:
@@ -488,7 +489,8 @@ bool ExtensionHost::PreHandleKeyboardEvent(WebContents* source,
}
// Handle higher priority browser shortcuts such as Ctrl-w.
- Browser* browser = view() ? view()->browser() : NULL;
+ Browser* browser = GetExtensionView() ?
+ GetExtensionView()->GetBrowser() : NULL;
if (browser)
return browser->PreHandleKeyboardEvent(source, event, is_keyboard_shortcut);
@@ -550,7 +552,8 @@ void ExtensionHost::OnDecrementLazyKeepaliveCount() {
void ExtensionHost::UnhandledKeyboardEvent(
WebContents* source,
const content::NativeWebKeyboardEvent& event) {
- Browser* browser = view() ? view()->browser() : NULL;
+ Browser* browser = GetExtensionView() ?
+ GetExtensionView()->GetBrowser() : NULL;
if (browser) {
// Handle lower priority browser shortcuts such as Ctrl-f.
return browser->HandleKeyboardEvent(source, event);
@@ -560,8 +563,8 @@ void ExtensionHost::UnhandledKeyboardEvent(
// ExtensionViewViews to handle acceleratos. The view's FocusManager does
// not know anything about Browser accelerators, but might know others such
// as Ash's.
- if (view())
- view()->HandleKeyboardEvent(event);
+ if (GetExtensionView())
+ GetExtensionView()->HandleKeyboardEvent(event);
#endif
}
}
@@ -569,8 +572,8 @@ void ExtensionHost::UnhandledKeyboardEvent(
void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) {
render_view_host_ = render_view_host;
- if (view())
- view()->RenderViewCreated();
+ if (GetExtensionView())
+ GetExtensionView()->RenderViewCreated();
// If the host is bound to a window, then extract its id. Extensions hosted
// in ExternalTabContainer objects may not have an associated window.
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/extensions/extension_host_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698