Commit 1739e57d authored by avi@chromium.org's avatar avi@chromium.org

Move extension delegate calls to a new ExtensionTabHelperDelegate interface.

BUG=105872
TEST=no functionality change

Review URL: http://codereview.chromium.org/8741025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112288 0039d316-1c4b-4281-b951-d872f2087c98
parent ca16cd0c
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper) ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper)
: TabContentsObserver(wrapper->tab_contents()), : TabContentsObserver(wrapper->tab_contents()),
delegate_(NULL),
extension_app_(NULL), extension_app_(NULL),
ALLOW_THIS_IN_INITIALIZER_LIST( ALLOW_THIS_IN_INITIALIZER_LIST(
extension_function_dispatcher_(wrapper->profile(), this)), extension_function_dispatcher_(wrapper->profile(), this)),
...@@ -140,13 +141,13 @@ void ExtensionTabHelper::OnDidGetApplicationInfo( ...@@ -140,13 +141,13 @@ void ExtensionTabHelper::OnDidGetApplicationInfo(
int32 page_id, const WebApplicationInfo& info) { int32 page_id, const WebApplicationInfo& info) {
web_app_info_ = info; web_app_info_ = info;
if (wrapper_->delegate()) if (delegate_)
wrapper_->delegate()->OnDidGetApplicationInfo(wrapper_, page_id); delegate_->OnDidGetApplicationInfo(wrapper_, page_id);
} }
void ExtensionTabHelper::OnInstallApplication(const WebApplicationInfo& info) { void ExtensionTabHelper::OnInstallApplication(const WebApplicationInfo& info) {
if (wrapper_->delegate()) if (delegate_)
wrapper_->delegate()->OnInstallApplication(wrapper_, info); delegate_->OnInstallApplication(wrapper_, info);
} }
void ExtensionTabHelper::OnInlineWebstoreInstall( void ExtensionTabHelper::OnInlineWebstoreInstall(
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
class Extension; class Extension;
class ExtensionTabHelperDelegate;
class TabContentsWrapper; class TabContentsWrapper;
struct WebApplicationInfo; struct WebApplicationInfo;
...@@ -38,6 +39,9 @@ class ExtensionTabHelper ...@@ -38,6 +39,9 @@ class ExtensionTabHelper
// Copies the internal state from another ExtensionTabHelper. // Copies the internal state from another ExtensionTabHelper.
void CopyStateFrom(const ExtensionTabHelper& source); void CopyStateFrom(const ExtensionTabHelper& source);
ExtensionTabHelperDelegate* delegate() const { return delegate_; }
void set_delegate(ExtensionTabHelperDelegate* d) { delegate_ = d; }
// Call this after updating a page action to notify clients about the changes. // Call this after updating a page action to notify clients about the changes.
void PageActionStateChanged(); void PageActionStateChanged();
...@@ -134,6 +138,9 @@ class ExtensionTabHelper ...@@ -134,6 +138,9 @@ class ExtensionTabHelper
// Data for app extensions --------------------------------------------------- // Data for app extensions ---------------------------------------------------
// Delegate for notifying our owner about stuff. Not owned by us.
ExtensionTabHelperDelegate* delegate_;
// If non-null this tab is an app tab and this is the extension the tab was // If non-null this tab is an app tab and this is the extension the tab was
// created for. // created for.
const Extension* extension_app_; const Extension* extension_app_;
......
// 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.
#include "chrome/browser/extensions/extension_tab_helper_delegate.h"
ExtensionTabHelperDelegate::~ExtensionTabHelperDelegate() {
}
// Notification when an application programmatically requests installation.
void ExtensionTabHelperDelegate::OnInstallApplication(
TabContentsWrapper* source,
const WebApplicationInfo& app_info) {
}
void ExtensionTabHelperDelegate::OnDidGetApplicationInfo(
TabContentsWrapper* source, int32 page_id) {
}
// 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.
#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_DELEGATE_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_DELEGATE_H_
#pragma once
#include "base/basictypes.h"
class TabContentsWrapper;
struct WebApplicationInfo;
// Objects implement this interface to get notified about changes in the
// ExtensionTabHelper and to provide necessary functionality.
class ExtensionTabHelperDelegate {
public:
// Notification that a user's request to install an application has completed.
virtual void OnDidGetApplicationInfo(TabContentsWrapper* source,
int32 page_id);
// Notification when an application programmatically requests installation.
virtual void OnInstallApplication(TabContentsWrapper* source,
const WebApplicationInfo& app_info);
protected:
virtual ~ExtensionTabHelperDelegate();
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_DELEGATE_H_
...@@ -4989,6 +4989,7 @@ void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) { ...@@ -4989,6 +4989,7 @@ void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) {
tab->blocked_content_tab_helper()->set_delegate(delegate); tab->blocked_content_tab_helper()->set_delegate(delegate);
tab->bookmark_tab_helper()->set_delegate(delegate); tab->bookmark_tab_helper()->set_delegate(delegate);
tab->constrained_window_tab_helper()->set_delegate(delegate); tab->constrained_window_tab_helper()->set_delegate(delegate);
tab->extension_tab_helper()->set_delegate(delegate);
tab->search_engine_tab_helper()->set_delegate(delegate); tab->search_engine_tab_helper()->set_delegate(delegate);
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "base/string16.h" #include "base/string16.h"
#include "chrome/browser/command_updater.h" #include "chrome/browser/command_updater.h"
#include "chrome/browser/debugger/devtools_toggle_action.h" #include "chrome/browser/debugger/devtools_toggle_action.h"
#include "chrome/browser/extensions/extension_tab_helper_delegate.h"
#include "chrome/browser/event_disposition.h" #include "chrome/browser/event_disposition.h"
#include "chrome/browser/instant/instant_delegate.h" #include "chrome/browser/instant/instant_delegate.h"
#include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/prefs/pref_member.h"
...@@ -80,6 +81,7 @@ class Browser : public TabHandlerDelegate, ...@@ -80,6 +81,7 @@ class Browser : public TabHandlerDelegate,
public ConstrainedWindowTabHelperDelegate, public ConstrainedWindowTabHelperDelegate,
public BlockedContentTabHelperDelegate, public BlockedContentTabHelperDelegate,
public BookmarkTabHelperDelegate, public BookmarkTabHelperDelegate,
public ExtensionTabHelperDelegate,
public PageNavigator, public PageNavigator,
public CommandUpdater::CommandUpdaterDelegate, public CommandUpdater::CommandUpdaterDelegate,
public content::NotificationObserver, public content::NotificationObserver,
...@@ -1028,12 +1030,6 @@ class Browser : public TabHandlerDelegate, ...@@ -1028,12 +1030,6 @@ class Browser : public TabHandlerDelegate,
virtual void LostMouseLock() OVERRIDE; virtual void LostMouseLock() OVERRIDE;
// Overridden from TabContentsWrapperDelegate: // Overridden from TabContentsWrapperDelegate:
virtual void OnDidGetApplicationInfo(TabContentsWrapper* source,
int32 page_id) OVERRIDE;
virtual void OnInstallApplication(
TabContentsWrapper* source,
const WebApplicationInfo& app_info) OVERRIDE;
// Note that the caller is responsible for deleting |old_tab_contents|. // Note that the caller is responsible for deleting |old_tab_contents|.
virtual void SwapTabContents(TabContentsWrapper* old_tab_contents, virtual void SwapTabContents(TabContentsWrapper* old_tab_contents,
TabContentsWrapper* new_tab_contents) OVERRIDE; TabContentsWrapper* new_tab_contents) OVERRIDE;
...@@ -1057,6 +1053,13 @@ class Browser : public TabHandlerDelegate, ...@@ -1057,6 +1053,13 @@ class Browser : public TabHandlerDelegate,
virtual void URLStarredChanged(TabContentsWrapper* source, virtual void URLStarredChanged(TabContentsWrapper* source,
bool starred) OVERRIDE; bool starred) OVERRIDE;
// Overridden from ExtensionTabHelperDelegate:
virtual void OnDidGetApplicationInfo(TabContentsWrapper* source,
int32 page_id) OVERRIDE;
virtual void OnInstallApplication(
TabContentsWrapper* source,
const WebApplicationInfo& app_info) OVERRIDE;
// Overridden from SelectFileDialog::Listener: // Overridden from SelectFileDialog::Listener:
virtual void FileSelected(const FilePath& path, virtual void FileSelected(const FilePath& path,
int index, int index,
......
...@@ -6,13 +6,3 @@ ...@@ -6,13 +6,3 @@
TabContentsWrapperDelegate::~TabContentsWrapperDelegate() { TabContentsWrapperDelegate::~TabContentsWrapperDelegate() {
} }
// Notification when an application programmatically requests installation.
void TabContentsWrapperDelegate::OnInstallApplication(
TabContentsWrapper* source,
const WebApplicationInfo& app_info) {
}
void TabContentsWrapperDelegate::OnDidGetApplicationInfo(
TabContentsWrapper* source, int32 page_id) {
}
...@@ -9,20 +9,11 @@ ...@@ -9,20 +9,11 @@
#include "base/basictypes.h" #include "base/basictypes.h"
class TabContentsWrapper; class TabContentsWrapper;
struct WebApplicationInfo;
// Objects implement this interface to get notified about changes in the // Objects implement this interface to get notified about changes in the
// TabContentsWrapper and to provide necessary functionality. // TabContentsWrapper and to provide necessary functionality.
class TabContentsWrapperDelegate { class TabContentsWrapperDelegate {
public: public:
// Notification that a user's request to install an application has completed.
virtual void OnDidGetApplicationInfo(TabContentsWrapper* source,
int32 page_id);
// Notification when an application programmatically requests installation.
virtual void OnInstallApplication(TabContentsWrapper* source,
const WebApplicationInfo& app_info);
virtual void SwapTabContents(TabContentsWrapper* old_tc, virtual void SwapTabContents(TabContentsWrapper* old_tc,
TabContentsWrapper* new_tc) = 0; TabContentsWrapper* new_tc) = 0;
......
...@@ -1110,6 +1110,8 @@ ...@@ -1110,6 +1110,8 @@
'browser/extensions/extension_sync_data.h', 'browser/extensions/extension_sync_data.h',
'browser/extensions/extension_tab_helper.cc', 'browser/extensions/extension_tab_helper.cc',
'browser/extensions/extension_tab_helper.h', 'browser/extensions/extension_tab_helper.h',
'browser/extensions/extension_tab_helper_delegate.cc',
'browser/extensions/extension_tab_helper_delegate.h',
'browser/extensions/extension_tab_id_map.cc', 'browser/extensions/extension_tab_id_map.cc',
'browser/extensions/extension_tab_id_map.h', 'browser/extensions/extension_tab_id_map.h',
'browser/extensions/extension_tab_util.cc', 'browser/extensions/extension_tab_util.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment