summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/android/tab_android.cc41
-rw-r--r--chrome/browser/android/tab_android.h5
2 files changed, 46 insertions, 0 deletions
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc
index 05fa32f..ff3bc6e 100644
--- a/chrome/browser/android/tab_android.cc
+++ b/chrome/browser/android/tab_android.cc
@@ -21,6 +21,8 @@
#include "chrome/browser/printing/print_view_manager_basic.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_android.h"
+#include "chrome/browser/search/instant_service.h"
+#include "chrome/browser/search/instant_service_factory.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/sync/glue/synced_tab_delegate_android.h"
@@ -45,6 +47,7 @@
#include "content/public/browser/android/content_view_core.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "jni/Tab_jni.h"
@@ -306,6 +309,34 @@ void TabAndroid::SwapTabContents(content::WebContents* old_contents,
did_finish_load);
}
+void TabAndroid::DefaultSearchProviderChanged() {
+ // TODO(kmadhusu): Move this function definition to a common place and update
+ // BrowserInstantController::DefaultSearchProviderChanged to use the same.
+ if (!web_contents())
+ return;
+
+ InstantService* instant_service =
+ InstantServiceFactory::GetForProfile(GetProfile());
+ if (!instant_service)
+ return;
+
+ // Send new search URLs to the renderer.
+ content::RenderProcessHost* rph = web_contents()->GetRenderProcessHost();
+ instant_service->SendSearchURLsToRenderer(rph);
+
+ // Reload the contents to ensure that it gets assigned to a non-previledged
+ // renderer.
+ if (!instant_service->IsInstantProcess(rph->GetID()))
+ return;
+ web_contents()->GetController().Reload(false);
+
+ // As the reload was not triggered by the user we don't want to close any
+ // infobars. We have to tell the InfoBarService after the reload, otherwise it
+ // would ignore this call when
+ // WebContentsObserver::DidStartNavigationToPendingEntry is invoked.
+ InfoBarService::FromWebContents(web_contents())->set_ignore_next_reload();
+}
+
void TabAndroid::OnWebContentsInstantSupportDisabled(
const content::WebContents* contents) {
DCHECK(contents);
@@ -408,6 +439,11 @@ void TabAndroid::InitWebContents(JNIEnv* env,
// Verify that the WebContents this tab represents matches the expected
// off the record state.
CHECK_EQ(GetProfile()->IsOffTheRecord(), incognito);
+
+ InstantService* instant_service =
+ InstantServiceFactory::GetForProfile(GetProfile());
+ if (instant_service)
+ instant_service->AddObserver(this);
}
void TabAndroid::DestroyWebContents(JNIEnv* env,
@@ -429,6 +465,11 @@ void TabAndroid::DestroyWebContents(JNIEnv* env,
content::Source<content::NavigationController>(
&web_contents()->GetController()));
+ InstantService* instant_service =
+ InstantServiceFactory::GetForProfile(GetProfile());
+ if (instant_service)
+ instant_service->RemoveObserver(this);
+
web_contents()->SetDelegate(NULL);
if (delete_native) {
diff --git a/chrome/browser/android/tab_android.h b/chrome/browser/android/tab_android.h
index f4378e3..0f3eb3d 100644
--- a/chrome/browser/android/tab_android.h
+++ b/chrome/browser/android/tab_android.h
@@ -11,6 +11,7 @@
#include "base/callback_forward.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
+#include "chrome/browser/search/instant_service_observer.h"
#include "chrome/browser/sync/glue/synced_tab_delegate_android.h"
#include "chrome/browser/ui/search/search_tab_helper_delegate.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
@@ -43,6 +44,7 @@ class PrerenderManager;
}
class TabAndroid : public CoreTabHelperDelegate,
+ public InstantServiceObserver,
public SearchTabHelperDelegate,
public content::NotificationObserver {
public:
@@ -113,6 +115,9 @@ class TabAndroid : public CoreTabHelperDelegate,
bool did_start_load,
bool did_finish_load) OVERRIDE;
+ // Overridden from InstantServiceObserver:
+ void DefaultSearchProviderChanged() OVERRIDE;
+
// Overridden from SearchTabHelperDelegate:
virtual void OnWebContentsInstantSupportDisabled(
const content::WebContents* web_contents) OVERRIDE;