summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/search_engines
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-17 03:09:42 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-17 03:09:42 +0000
commitb5a1d11cc70ab12c69e579d132204863a780eb75 (patch)
treea9300148dd2434b645ad7fe1716cce2f9e42e064 /chrome/browser/ui/search_engines
parentcd124097edce07ef5e0a7f80105e81c7982b81a1 (diff)
downloadchromium_src-b5a1d11cc70ab12c69e579d132204863a780eb75.zip
chromium_src-b5a1d11cc70ab12c69e579d132204863a780eb75.tar.gz
chromium_src-b5a1d11cc70ab12c69e579d132204863a780eb75.tar.bz2
Make TabContentsObserver handle registration automatically, as well as exposing getters for TC, routing_id, and sending messages.
Review URL: http://codereview.chromium.org/6537004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75226 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/search_engines')
-rw-r--r--chrome/browser/ui/search_engines/search_engine_tab_helper.cc28
-rw-r--r--chrome/browser/ui/search_engines/search_engine_tab_helper.h4
-rw-r--r--chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h4
-rw-r--r--chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc8
-rw-r--r--chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h8
5 files changed, 24 insertions, 28 deletions
diff --git a/chrome/browser/ui/search_engines/search_engine_tab_helper.cc b/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
index db1d0dd..82d11f0 100644
--- a/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
+++ b/chrome/browser/ui/search_engines/search_engine_tab_helper.cc
@@ -9,7 +9,7 @@
#include "chrome/browser/search_engines/template_url_fetcher.h"
#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h"
-#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/render_messages_params.h"
@@ -23,9 +23,9 @@ bool IsFormSubmit(const NavigationEntry* entry) {
} // namespace
-SearchEngineTabHelper::SearchEngineTabHelper(TabContentsWrapper* tab_contents)
- : tab_contents_(tab_contents) {
- DCHECK(tab_contents_);
+SearchEngineTabHelper::SearchEngineTabHelper(TabContents* tab_contents)
+ : TabContentsObserver(tab_contents) {
+ DCHECK(tab_contents);
}
SearchEngineTabHelper::~SearchEngineTabHelper() {
@@ -57,11 +57,11 @@ void SearchEngineTabHelper::OnPageHasOSDD(
// Make sure page_id is the current page and other basic checks.
DCHECK(doc_url.is_valid());
- if (!tab_contents_->tab_contents()->IsActiveEntry(page_id))
+ if (!tab_contents()->IsActiveEntry(page_id))
return;
- if (!tab_contents_->profile()->GetTemplateURLFetcher())
+ if (!tab_contents()->profile()->GetTemplateURLFetcher())
return;
- if (tab_contents_->profile()->IsOffTheRecord())
+ if (tab_contents()->profile()->IsOffTheRecord())
return;
TemplateURLFetcher::ProviderType provider_type;
@@ -83,8 +83,7 @@ void SearchEngineTabHelper::OnPageHasOSDD(
return;
}
- const NavigationController& controller =
- tab_contents_->tab_contents()->controller();
+ const NavigationController& controller = tab_contents()->controller();
const NavigationEntry* entry = controller.GetLastCommittedEntry();
DCHECK(entry);
@@ -116,11 +115,11 @@ void SearchEngineTabHelper::OnPageHasOSDD(
// Download the OpenSearch description document. If this is successful, a
// new keyword will be created when done.
- tab_contents_->profile()->GetTemplateURLFetcher()->ScheduleDownload(
+ tab_contents()->profile()->GetTemplateURLFetcher()->ScheduleDownload(
keyword,
doc_url,
base_entry->favicon().url(),
- new TemplateURLFetcherUICallbacks(this, tab_contents_),
+ new TemplateURLFetcherUICallbacks(this, tab_contents()),
provider_type);
}
@@ -129,11 +128,10 @@ void SearchEngineTabHelper::GenerateKeywordIfNecessary(
if (!params.searchable_form_url.is_valid())
return;
- if (tab_contents_->profile()->IsOffTheRecord())
+ if (tab_contents()->profile()->IsOffTheRecord())
return;
- const NavigationController& controller =
- tab_contents_->tab_contents()->controller();
+ const NavigationController& controller = tab_contents()->controller();
int last_index = controller.last_committed_entry_index();
// When there was no previous page, the last index will be 0. This is
// normally due to a form submit that opened in a new tab.
@@ -157,7 +155,7 @@ void SearchEngineTabHelper::GenerateKeywordIfNecessary(
return;
TemplateURLModel* url_model =
- tab_contents_->profile()->GetTemplateURLModel();
+ tab_contents()->profile()->GetTemplateURLModel();
if (!url_model)
return;
diff --git a/chrome/browser/ui/search_engines/search_engine_tab_helper.h b/chrome/browser/ui/search_engines/search_engine_tab_helper.h
index bcb1b0e..e259820 100644
--- a/chrome/browser/ui/search_engines/search_engine_tab_helper.h
+++ b/chrome/browser/ui/search_engines/search_engine_tab_helper.h
@@ -18,7 +18,7 @@ struct ViewHostMsg_PageHasOSDD_Type;
// functionality.
class SearchEngineTabHelper : public TabContentsObserver {
public:
- explicit SearchEngineTabHelper(TabContentsWrapper* tab_contents);
+ explicit SearchEngineTabHelper(TabContents* tab_contents);
virtual ~SearchEngineTabHelper();
SearchEngineTabHelperDelegate* delegate() const { return delegate_; }
@@ -40,8 +40,6 @@ class SearchEngineTabHelper : public TabContentsObserver {
void GenerateKeywordIfNecessary(
const ViewHostMsg_FrameNavigate_Params& params);
- TabContentsWrapper* tab_contents_;
-
// Delegate for notifying our owner about stuff. Not owned by us.
SearchEngineTabHelperDelegate* delegate_;
diff --git a/chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h b/chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h
index cc7fa88..8c83ea1 100644
--- a/chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h
+++ b/chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h
@@ -7,7 +7,7 @@
#pragma once
class Profile;
-class TabContentsWrapper;
+class TabContents;
class TemplateURL;
class TemplateURLModel;
@@ -18,7 +18,7 @@ class SearchEngineTabHelperDelegate {
// Shows a confirmation dialog box for setting the default search engine
// described by |template_url|. Takes ownership of |template_url|.
virtual void ConfirmSetDefaultSearchProvider(
- TabContentsWrapper* tab_contents,
+ TabContents* tab_contents,
TemplateURL* template_url,
TemplateURLModel* template_url_model) = 0;
diff --git a/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc b/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc
index 9c37f78..f10aa7b 100644
--- a/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc
+++ b/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc
@@ -9,18 +9,18 @@
#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
#include "chrome/browser/search_engines/template_url.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
#include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h"
-#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
TemplateURLFetcherUICallbacks::TemplateURLFetcherUICallbacks(
SearchEngineTabHelper* tab_helper,
- TabContentsWrapper* tab_contents)
+ TabContents* tab_contents)
: source_(tab_helper),
tab_contents_(tab_contents) {
registrar_.Add(this,
NotificationType::TAB_CONTENTS_DESTROYED,
- Source<TabContents>(tab_contents_->tab_contents()));
+ Source<TabContents>(tab_contents_));
}
TemplateURLFetcherUICallbacks::~TemplateURLFetcherUICallbacks() {
@@ -55,7 +55,7 @@ void TemplateURLFetcherUICallbacks::Observe(
const NotificationSource& source,
const NotificationDetails& details) {
DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED);
- DCHECK(source == Source<TabContents>(tab_contents_->tab_contents()));
+ DCHECK(source == Source<TabContents>(tab_contents_));
source_ = NULL;
tab_contents_ = NULL;
}
diff --git a/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h b/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h
index c1e6d46..2f994075 100644
--- a/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h
+++ b/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h
@@ -12,14 +12,14 @@
#include "chrome/common/notification_registrar.h"
class SearchEngineTabHelper;
-class TabContentsWrapper;
+class TabContents;
// Callbacks which display UI for the TemplateURLFetcher.
class TemplateURLFetcherUICallbacks : public TemplateURLFetcherCallbacks,
public NotificationObserver {
public:
explicit TemplateURLFetcherUICallbacks(SearchEngineTabHelper* tab_helper,
- TabContentsWrapper* tab_contents);
+ TabContents* tab_contents);
virtual ~TemplateURLFetcherUICallbacks();
// TemplateURLFetcherCallback implementation.
@@ -40,8 +40,8 @@ class TemplateURLFetcherUICallbacks : public TemplateURLFetcherCallbacks,
// originating tab is closed. If NULL, the engine is not added.
SearchEngineTabHelper* source_;
- // The TabContentsWrapper where this request originated.
- TabContentsWrapper* tab_contents_;
+ // The TabContents where this request originated.
+ TabContents* tab_contents_;
// Handles registering for our notifications.
NotificationRegistrar registrar_;