summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-06 06:35:37 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-06 06:35:37 +0000
commitee162d84652bb1dc914b12621722a9a3b706978f (patch)
tree273af9476a53d00545df00cd72c4efd85e27af4d /chrome/browser/extensions
parent63b328fe08abc80c7202bda70c654b143895c322 (diff)
downloadchromium_src-ee162d84652bb1dc914b12621722a9a3b706978f.zip
chromium_src-ee162d84652bb1dc914b12621722a9a3b706978f.tar.gz
chromium_src-ee162d84652bb1dc914b12621722a9a3b706978f.tar.bz2
Split ViewType between chrome and content
BUG=89642 TEST=still works Review URL: http://codereview.chromium.org/8135026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104253 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_bookmark_manager_api.cc5
-rw-r--r--chrome/browser/extensions/extension_host.cc55
-rw-r--r--chrome/browser/extensions/extension_host.h10
-rw-r--r--chrome/browser/extensions/extension_host_mac.h4
-rw-r--r--chrome/browser/extensions/extension_host_mac.mm3
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc41
-rw-r--r--chrome/browser/extensions/extension_process_manager.h4
7 files changed, 67 insertions, 55 deletions
diff --git a/chrome/browser/extensions/extension_bookmark_manager_api.cc b/chrome/browser/extensions/extension_bookmark_manager_api.cc
index fb28876..af347e9 100644
--- a/chrome/browser/extensions/extension_bookmark_manager_api.cc
+++ b/chrome/browser/extensions/extension_bookmark_manager_api.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/chrome_view_types.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "grit/generated_resources.h"
@@ -370,7 +371,7 @@ bool StartDragBookmarkManagerFunction::RunImpl() {
GetNodesFromArguments(model, args_.get(), 0, &nodes));
if (render_view_host_->delegate()->GetRenderViewType() ==
- ViewType::TAB_CONTENTS) {
+ content::ViewType::TAB_CONTENTS) {
TabContents* tab_contents =
dispatcher()->delegate()->GetAssociatedTabContents();
CHECK(tab_contents);
@@ -412,7 +413,7 @@ bool DropBookmarkManagerFunction::RunImpl() {
drop_index = drop_parent->child_count();
if (render_view_host_->delegate()->GetRenderViewType() ==
- ViewType::TAB_CONTENTS) {
+ content::ViewType::TAB_CONTENTS) {
TabContents* tab_contents =
dispatcher()->delegate()->GetAssociatedTabContents();
CHECK(tab_contents);
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index a13f668..0c885d7 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -33,6 +33,7 @@
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
+#include "chrome/common/chrome_view_types.h"
#include "content/browser/browsing_instance.h"
#include "content/browser/content_browser_client.h"
#include "content/browser/renderer_host/browser_render_process_host.h"
@@ -129,7 +130,7 @@ class ExtensionHost::ProcessCreationQueue {
ExtensionHost::ExtensionHost(const Extension* extension,
SiteInstance* site_instance,
const GURL& url,
- ViewType::Type host_type)
+ content::ViewType::Type host_type)
: extension_(extension),
extension_id_(extension->id()),
profile_(Profile::FromBrowserContext(
@@ -214,9 +215,9 @@ void ExtensionHost::CreateRenderViewSoon(RenderWidgetHostView* host_view) {
void ExtensionHost::CreateRenderViewNow() {
render_view_host_->CreateRenderView(string16());
- if (extension_host_type_ == ViewType::EXTENSION_POPUP ||
- extension_host_type_ == ViewType::EXTENSION_DIALOG ||
- extension_host_type_ == ViewType::EXTENSION_INFOBAR) {
+ if (extension_host_type_ == chrome::ViewType::EXTENSION_POPUP ||
+ extension_host_type_ == chrome::ViewType::EXTENSION_DIALOG ||
+ extension_host_type_ == chrome::ViewType::EXTENSION_INFOBAR) {
// If the host is bound to a browser, then extract its window id.
// Extensions hosted in ExternalTabContainer objects may not have
// an associated browser.
@@ -357,9 +358,9 @@ void ExtensionHost::DisableScrollbarsForSmallWindows(
void ExtensionHost::DidStopLoading() {
bool notify = !did_stop_loading_;
did_stop_loading_ = true;
- if (extension_host_type_ == ViewType::EXTENSION_POPUP ||
- extension_host_type_ == ViewType::EXTENSION_DIALOG ||
- extension_host_type_ == ViewType::EXTENSION_INFOBAR) {
+ if (extension_host_type_ == chrome::ViewType::EXTENSION_POPUP ||
+ extension_host_type_ == chrome::ViewType::EXTENSION_DIALOG ||
+ extension_host_type_ == chrome::ViewType::EXTENSION_INFOBAR) {
#if defined(TOOLKIT_VIEWS)
if (view_.get())
view_->DidStopLoading();
@@ -370,16 +371,16 @@ void ExtensionHost::DidStopLoading() {
chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
Source<Profile>(profile_),
Details<ExtensionHost>(this));
- if (extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE) {
+ if (extension_host_type_ == chrome::ViewType::EXTENSION_BACKGROUND_PAGE) {
UMA_HISTOGRAM_TIMES("Extensions.BackgroundPageLoadTime",
since_created_.Elapsed());
- } else if (extension_host_type_ == ViewType::EXTENSION_DIALOG) {
+ } else if (extension_host_type_ == chrome::ViewType::EXTENSION_DIALOG) {
UMA_HISTOGRAM_TIMES("Extensions.DialogLoadTime",
since_created_.Elapsed());
- } else if (extension_host_type_ == ViewType::EXTENSION_POPUP) {
+ } else if (extension_host_type_ == chrome::ViewType::EXTENSION_POPUP) {
UMA_HISTOGRAM_TIMES("Extensions.PopupLoadTime",
since_created_.Elapsed());
- } else if (extension_host_type_ == ViewType::EXTENSION_INFOBAR) {
+ } else if (extension_host_type_ == chrome::ViewType::EXTENSION_INFOBAR) {
UMA_HISTOGRAM_TIMES("Extensions.InfobarLoadTime",
since_created_.Elapsed());
}
@@ -397,7 +398,7 @@ void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) {
profile_->GetExtensionService()->SetBackgroundPageReady(extension_);
} else {
switch (extension_host_type_) {
- case ViewType::EXTENSION_INFOBAR:
+ case chrome::ViewType::EXTENSION_INFOBAR:
InsertInfobarCSS();
break;
default:
@@ -408,7 +409,7 @@ void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) {
void ExtensionHost::DocumentOnLoadCompletedInMainFrame(RenderViewHost* rvh,
int32 page_id) {
- if (ViewType::EXTENSION_POPUP == GetRenderViewType()) {
+ if (chrome::ViewType::EXTENSION_POPUP == GetRenderViewType()) {
NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSION_POPUP_VIEW_READY,
Source<Profile>(profile_),
@@ -477,10 +478,10 @@ void ExtensionHost::OnDialogClosed(IPC::Message* reply_msg,
}
void ExtensionHost::Close(RenderViewHost* render_view_host) {
- if (extension_host_type_ == ViewType::EXTENSION_POPUP ||
- extension_host_type_ == ViewType::EXTENSION_DIALOG ||
- extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE ||
- extension_host_type_ == ViewType::EXTENSION_INFOBAR) {
+ if (extension_host_type_ == chrome::ViewType::EXTENSION_POPUP ||
+ extension_host_type_ == chrome::ViewType::EXTENSION_DIALOG ||
+ extension_host_type_ == chrome::ViewType::EXTENSION_BACKGROUND_PAGE ||
+ extension_host_type_ == chrome::ViewType::EXTENSION_INFOBAR) {
NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
Source<Profile>(profile_),
@@ -514,15 +515,15 @@ WebPreferences ExtensionHost::GetWebkitPrefs() {
webkit_prefs.loads_images_automatically = true;
webkit_prefs.javascript_enabled = true;
- if (extension_host_type_ == ViewType::EXTENSION_POPUP ||
- extension_host_type_ == ViewType::EXTENSION_DIALOG ||
- extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE ||
- extension_host_type_ == ViewType::EXTENSION_INFOBAR)
+ if (extension_host_type_ == chrome::ViewType::EXTENSION_POPUP ||
+ extension_host_type_ == chrome::ViewType::EXTENSION_DIALOG ||
+ extension_host_type_ == chrome::ViewType::EXTENSION_BACKGROUND_PAGE ||
+ extension_host_type_ == chrome::ViewType::EXTENSION_INFOBAR)
webkit_prefs.allow_scripts_to_close_windows = true;
// Disable anything that requires the GPU process for background pages.
// See http://crbug.com/64512 and http://crbug.com/64841.
- if (extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE) {
+ if (extension_host_type_ == chrome::ViewType::EXTENSION_BACKGROUND_PAGE) {
webkit_prefs.experimental_webgl_enabled = false;
webkit_prefs.accelerated_compositing_enabled = false;
webkit_prefs.accelerated_2d_canvas_enabled = false;
@@ -537,7 +538,7 @@ RenderViewHostDelegate::View* ExtensionHost::GetViewDelegate() {
bool ExtensionHost::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) {
- if (extension_host_type_ == ViewType::EXTENSION_POPUP &&
+ if (extension_host_type_ == chrome::ViewType::EXTENSION_POPUP &&
event.type == NativeWebKeyboardEvent::RawKeyDown &&
event.windowsKeyCode == ui::VKEY_ESCAPE) {
DCHECK(is_keyboard_shortcut != NULL);
@@ -547,7 +548,7 @@ bool ExtensionHost::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
}
void ExtensionHost::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
- if (extension_host_type_ == ViewType::EXTENSION_POPUP) {
+ if (extension_host_type_ == chrome::ViewType::EXTENSION_POPUP) {
if (event.type == NativeWebKeyboardEvent::RawKeyDown &&
event.windowsKeyCode == ui::VKEY_ESCAPE) {
NotificationService::current()->Notify(
@@ -769,7 +770,7 @@ void ExtensionHost::GotFocus() {
void ExtensionHost::TakeFocus(bool reverse) {
}
-ViewType::Type ExtensionHost::GetRenderViewType() const {
+content::ViewType::Type ExtensionHost::GetRenderViewType() const {
return extension_host_type_;
}
@@ -794,8 +795,8 @@ void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) {
if (view_.get())
view_->RenderViewCreated();
- if (extension_host_type_ == ViewType::EXTENSION_POPUP ||
- extension_host_type_ == ViewType::EXTENSION_INFOBAR) {
+ if (extension_host_type_ == chrome::ViewType::EXTENSION_POPUP ||
+ extension_host_type_ == chrome::ViewType::EXTENSION_INFOBAR) {
render_view_host->EnablePreferredSizeMode(
kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow);
}
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index a0e100b..40b5c00 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -51,7 +51,7 @@ class ExtensionHost : public RenderViewHostDelegate,
static void EnableDOMAutomation() { enable_dom_automation_ = true; }
ExtensionHost(const Extension* extension, SiteInstance* site_instance,
- const GURL& url, ViewType::Type host_type);
+ const GURL& url, content::ViewType::Type host_type);
virtual ~ExtensionHost();
#if defined(TOOLKIT_VIEWS)
@@ -84,7 +84,9 @@ class ExtensionHost : public RenderViewHostDelegate,
Profile* profile() const { return profile_; }
- ViewType::Type extension_host_type() const { return extension_host_type_; }
+ content::ViewType::Type extension_host_type() const {
+ return extension_host_type_;
+ }
// ExtensionFunctionDispatcher::Delegate
virtual TabContents* GetAssociatedTabContents() const OVERRIDE;
@@ -114,7 +116,7 @@ class ExtensionHost : public RenderViewHostDelegate,
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual const GURL& GetURL() const OVERRIDE;
virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
- virtual ViewType::Type GetRenderViewType() const OVERRIDE;
+ virtual content::ViewType::Type GetRenderViewType() const OVERRIDE;
virtual void RenderViewGone(RenderViewHost* render_view_host,
base::TerminationStatus status,
int error_code) OVERRIDE;
@@ -275,7 +277,7 @@ class ExtensionHost : public RenderViewHostDelegate,
// Only EXTENSION_INFOBAR, EXTENSION_POPUP, and EXTENSION_BACKGROUND_PAGE
// are used here, others are not hosted by ExtensionHost.
- ViewType::Type extension_host_type_;
+ content::ViewType::Type extension_host_type_;
// The relevant TabContents associated with this ExtensionHost, if any.
TabContents* associated_tab_contents_;
diff --git a/chrome/browser/extensions/extension_host_mac.h b/chrome/browser/extensions/extension_host_mac.h
index da46f16..b7dfe88 100644
--- a/chrome/browser/extensions/extension_host_mac.h
+++ b/chrome/browser/extensions/extension_host_mac.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -13,7 +13,7 @@ class RenderWidgetHostView;
class ExtensionHostMac : public ExtensionHost {
public:
ExtensionHostMac(const Extension* extension, SiteInstance* site_instance,
- const GURL& url, ViewType::Type host_type) :
+ const GURL& url, content::ViewType::Type host_type) :
ExtensionHost(extension, site_instance, url, host_type) {}
virtual ~ExtensionHostMac();
protected:
diff --git a/chrome/browser/extensions/extension_host_mac.mm b/chrome/browser/extensions/extension_host_mac.mm
index 9c9234b..8b3ee43 100644
--- a/chrome/browser/extensions/extension_host_mac.mm
+++ b/chrome/browser/extensions/extension_host_mac.mm
@@ -7,6 +7,7 @@
#import "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
#import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h"
#import "chrome/browser/ui/cocoa/info_bubble_window.h"
+#include "chrome/common/chrome_view_types.h"
#include "content/browser/renderer_host/render_widget_host_view_mac.h"
#include "content/common/native_web_keyboard_event.h"
@@ -51,7 +52,7 @@ void ExtensionHostMac::ShowCreatedWidgetInternal(
void ExtensionHostMac::UnhandledKeyboardEvent(
const NativeWebKeyboardEvent& event) {
if (event.skip_in_browser || event.type == NativeWebKeyboardEvent::Char ||
- extension_host_type() != ViewType::EXTENSION_POPUP) {
+ extension_host_type() != chrome::ViewType::EXTENSION_POPUP) {
return;
}
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 600eeeb..8c90eec 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -20,6 +20,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/url_constants.h"
+#include "chrome/common/chrome_view_types.h"
#include "content/browser/browser_thread.h"
#include "content/browser/site_instance.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -34,10 +35,11 @@ class IncognitoExtensionProcessManager : public ExtensionProcessManager {
public:
explicit IncognitoExtensionProcessManager(Profile* profile);
virtual ~IncognitoExtensionProcessManager() {}
- virtual ExtensionHost* CreateViewHost(const Extension* extension,
- const GURL& url,
- Browser* browser,
- ViewType::Type view_type) OVERRIDE;
+ virtual ExtensionHost* CreateViewHost(
+ const Extension* extension,
+ const GURL& url,
+ Browser* browser,
+ content::ViewType::Type view_type) OVERRIDE;
virtual void CreateBackgroundHost(const Extension* extension,
const GURL& url);
virtual SiteInstance* GetSiteInstanceForURL(const GURL& url);
@@ -120,10 +122,11 @@ ExtensionHost* ExtensionProcessManager::CreateViewHost(
const Extension* extension,
const GURL& url,
Browser* browser,
- ViewType::Type view_type) {
+ content::ViewType::Type view_type) {
DCHECK(extension);
// A NULL browser may only be given for pop-up views.
- DCHECK(browser || (!browser && view_type == ViewType::EXTENSION_POPUP));
+ DCHECK(browser ||
+ (!browser && view_type == chrome::ViewType::EXTENSION_POPUP));
ExtensionHost* host =
#if defined(OS_MACOSX)
new ExtensionHostMac(extension, GetSiteInstanceForURL(url), url,
@@ -137,9 +140,10 @@ ExtensionHost* ExtensionProcessManager::CreateViewHost(
}
ExtensionHost* ExtensionProcessManager::CreateViewHost(
- const GURL& url, Browser* browser, ViewType::Type view_type) {
+ const GURL& url, Browser* browser, content::ViewType::Type view_type) {
// A NULL browser may only be given for pop-up views.
- DCHECK(browser || (!browser && view_type == ViewType::EXTENSION_POPUP));
+ DCHECK(browser ||
+ (!browser && view_type == chrome::ViewType::EXTENSION_POPUP));
Profile* profile =
Profile::FromBrowserContext(browsing_instance_->browser_context());
ExtensionService* service = profile->GetExtensionService();
@@ -153,27 +157,29 @@ ExtensionHost* ExtensionProcessManager::CreateViewHost(
ExtensionHost* ExtensionProcessManager::CreatePopupHost(
const Extension* extension, const GURL& url, Browser* browser) {
- return CreateViewHost(extension, url, browser, ViewType::EXTENSION_POPUP);
+ return CreateViewHost(
+ extension, url, browser, chrome::ViewType::EXTENSION_POPUP);
}
ExtensionHost* ExtensionProcessManager::CreatePopupHost(
const GURL& url, Browser* browser) {
- return CreateViewHost(url, browser, ViewType::EXTENSION_POPUP);
+ return CreateViewHost(url, browser, chrome::ViewType::EXTENSION_POPUP);
}
ExtensionHost* ExtensionProcessManager::CreateDialogHost(
const GURL& url, Browser* browser) {
- return CreateViewHost(url, browser, ViewType::EXTENSION_DIALOG);
+ return CreateViewHost(url, browser, chrome::ViewType::EXTENSION_DIALOG);
}
ExtensionHost* ExtensionProcessManager::CreateInfobarHost(
const Extension* extension, const GURL& url, Browser* browser) {
- return CreateViewHost(extension, url, browser, ViewType::EXTENSION_INFOBAR);
+ return CreateViewHost(
+ extension, url, browser, chrome::ViewType::EXTENSION_INFOBAR);
}
ExtensionHost* ExtensionProcessManager::CreateInfobarHost(
const GURL& url, Browser* browser) {
- return CreateViewHost(url, browser, ViewType::EXTENSION_INFOBAR);
+ return CreateViewHost(url, browser, chrome::ViewType::EXTENSION_INFOBAR);
}
void ExtensionProcessManager::CreateBackgroundHost(
@@ -190,10 +196,10 @@ void ExtensionProcessManager::CreateBackgroundHost(
ExtensionHost* host =
#if defined(OS_MACOSX)
new ExtensionHostMac(extension, GetSiteInstanceForURL(url), url,
- ViewType::EXTENSION_BACKGROUND_PAGE);
+ chrome::ViewType::EXTENSION_BACKGROUND_PAGE);
#else
new ExtensionHost(extension, GetSiteInstanceForURL(url), url,
- ViewType::EXTENSION_BACKGROUND_PAGE);
+ chrome::ViewType::EXTENSION_BACKGROUND_PAGE);
#endif
host->CreateRenderViewSoon(NULL); // create a RenderViewHost with no view
@@ -409,7 +415,8 @@ void ExtensionProcessManager::Observe(int type,
case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: {
ExtensionHost* host = Details<ExtensionHost>(details).ptr();
- if (host->extension_host_type() == ViewType::EXTENSION_BACKGROUND_PAGE) {
+ if (host->extension_host_type() ==
+ chrome::ViewType::EXTENSION_BACKGROUND_PAGE) {
delete host;
// |host| should deregister itself from our structures.
CHECK(background_hosts_.find(host) == background_hosts_.end());
@@ -470,7 +477,7 @@ ExtensionHost* IncognitoExtensionProcessManager::CreateViewHost(
const Extension* extension,
const GURL& url,
Browser* browser,
- ViewType::Type view_type) {
+ content::ViewType::Type view_type) {
if (extension->incognito_split_mode()) {
if (IsIncognitoEnabled(extension)) {
return ExtensionProcessManager::CreateViewHost(extension, url,
diff --git a/chrome/browser/extensions/extension_process_manager.h b/chrome/browser/extensions/extension_process_manager.h
index 73b1cdf..e146ce5 100644
--- a/chrome/browser/extensions/extension_process_manager.h
+++ b/chrome/browser/extensions/extension_process_manager.h
@@ -39,10 +39,10 @@ class ExtensionProcessManager : public NotificationObserver {
virtual ExtensionHost* CreateViewHost(const Extension* extension,
const GURL& url,
Browser* browser,
- ViewType::Type view_type);
+ content::ViewType::Type view_type);
ExtensionHost* CreateViewHost(const GURL& url,
Browser* browser,
- ViewType::Type view_type);
+ content::ViewType::Type view_type);
ExtensionHost* CreatePopupHost(const Extension* extension,
const GURL& url,
Browser* browser);