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

Unified Diff: chrome/browser/ui/browser_instant_controller.cc

Issue 20388003: Reload Instant NTP and Instant-process tabs on search url change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased and addressed comments Created 7 years, 4 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
Index: chrome/browser/ui/browser_instant_controller.cc
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc
index 2e6c12df2549d15d5a51b031954c7799fc8e4d7c..b01713cbfafe85b2aa937f0027369fc39a0dc820 100644
--- a/chrome/browser/ui/browser_instant_controller.cc
+++ b/chrome/browser/ui/browser_instant_controller.cc
@@ -5,16 +5,12 @@
#include "chrome/browser/ui/browser_instant_controller.h"
#include "base/bind.h"
-#include "base/prefs/pref_service.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/profiles/profile.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/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_service.h"
-#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
@@ -25,9 +21,7 @@
#include "chrome/browser/ui/search/search_tab_helper.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
-#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
-#include "components/user_prefs/pref_registry_syncable.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
@@ -42,16 +36,12 @@ BrowserInstantController::BrowserInstantController(Browser* browser)
: browser_(browser),
instant_(this),
instant_unload_handler_(browser) {
- profile_pref_registrar_.Init(profile()->GetPrefs());
- profile_pref_registrar_.Add(
- prefs::kDefaultSearchProviderID,
- base::Bind(&BrowserInstantController::OnDefaultSearchProviderChanged,
- base::Unretained(this)));
browser_->search_model()->AddObserver(this);
InstantService* instant_service =
InstantServiceFactory::GetForProfile(profile());
instant_service->OnBrowserInstantControllerCreated();
+ instant_service->AddObserver(this);
samarth 2013/08/14 00:24:14 Call RemoveObserver in the destructor. I'm surpris
Anuj 2013/08/14 06:38:57 Done. Added BrowserWindowLifeCycle unit test in In
}
BrowserInstantController::~BrowserInstantController() {
@@ -268,25 +258,20 @@ void BrowserInstantController::ModelChanged(
instant_.InstantSupportChanged(new_state.instant_support);
}
-void BrowserInstantController::OnDefaultSearchProviderChanged(
- const std::string& pref_name) {
- DCHECK_EQ(pref_name, std::string(prefs::kDefaultSearchProviderID));
-
- Profile* browser_profile = profile();
- const TemplateURL* template_url =
- TemplateURLServiceFactory::GetForProfile(browser_profile)->
- GetDefaultSearchProvider();
- if (!template_url) {
- // A NULL |template_url| could mean either this notification is sent during
- // the browser start up operation or the user now has no default search
- // provider. There is no way for the user to reach this state using the
- // Chrome settings. Only explicitly poking at the DB or bugs in the Sync
- // could cause that, neither of which we support.
- return;
- }
+////////////////////////////////////////////////////////////////////////////////
+// BrowserInstantController, InstantServiceObserver implementation:
+
+void BrowserInstantController::DefaultSearchProviderChanged() {
+ ReloadTabsInInstantProcess();
+}
+
+void BrowserInstantController::GoogleURLUpdated() {
+ ReloadTabsInInstantProcess();
+}
+void BrowserInstantController::ReloadTabsInInstantProcess() {
InstantService* instant_service =
- InstantServiceFactory::GetForProfile(browser_profile);
+ InstantServiceFactory::GetForProfile(profile());
if (!instant_service)
return;

Powered by Google App Engine
This is Rietveld 408576698