| Index: chrome/browser/ui/webui/instant_ui.cc
|
| diff --git a/chrome/browser/ui/webui/instant_ui.cc b/chrome/browser/ui/webui/instant_ui.cc
|
| index 8a609208f199761219eec47c7d803c8548635a45..c354152d2e198630d23b9470de68320c39f0c625 100644
|
| --- a/chrome/browser/ui/webui/instant_ui.cc
|
| +++ b/chrome/browser/ui/webui/instant_ui.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Copyright 2012 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.
|
|
|
| @@ -7,13 +7,10 @@
|
| #include "base/bind.h"
|
| #include "base/prefs/pref_service.h"
|
| #include "base/stringprintf.h"
|
| -#include "base/time.h"
|
| -#include "chrome/browser/instant/instant_controller.h"
|
| +#include "chrome/browser/instant/instant_service.h"
|
| +#include "chrome/browser/instant/instant_service_factory.h"
|
| #include "chrome/browser/prefs/pref_registry_syncable.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| -#include "chrome/browser/ui/browser.h"
|
| -#include "chrome/browser/ui/browser_finder.h"
|
| -#include "chrome/browser/ui/browser_instant_controller.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "content/public/browser/web_ui.h"
|
| @@ -51,10 +48,10 @@ class InstantUIMessageHandler
|
| InstantUIMessageHandler();
|
| virtual ~InstantUIMessageHandler();
|
|
|
| - // WebUIMessageHandler implementation.
|
| + private:
|
| + // Overridden from content::WebUIMessageHandler:
|
| virtual void RegisterMessages() OVERRIDE;
|
|
|
| - private:
|
| void GetPreferenceValue(const base::ListValue* args);
|
| void SetPreferenceValue(const base::ListValue* args);
|
| void GetDebugInfo(const base::ListValue* value);
|
| @@ -62,9 +59,11 @@ class InstantUIMessageHandler
|
| DISALLOW_COPY_AND_ASSIGN(InstantUIMessageHandler);
|
| };
|
|
|
| -InstantUIMessageHandler::InstantUIMessageHandler() {}
|
| +InstantUIMessageHandler::InstantUIMessageHandler() {
|
| +}
|
|
|
| -InstantUIMessageHandler::~InstantUIMessageHandler() {}
|
| +InstantUIMessageHandler::~InstantUIMessageHandler() {
|
| +}
|
|
|
| void InstantUIMessageHandler::RegisterMessages() {
|
| web_ui()->RegisterMessageCallback(
|
| @@ -108,23 +107,18 @@ void InstantUIMessageHandler::SetPreferenceValue(const base::ListValue* args) {
|
| }
|
|
|
| void InstantUIMessageHandler::GetDebugInfo(const base::ListValue* args) {
|
| -#if !defined(OS_ANDROID)
|
| - typedef std::pair<int64, std::string> DebugEvent;
|
| -
|
| - if (!web_ui()->GetWebContents())
|
| - return;
|
| - Browser* browser = chrome::FindBrowserWithWebContents(
|
| - web_ui()->GetWebContents());
|
| - if (!browser || !browser->instant_controller())
|
| + InstantService* service =
|
| + InstantServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
|
| + if (!service)
|
| return;
|
|
|
| - InstantController* instant = browser->instant_controller()->instant();
|
| - const std::list<DebugEvent>& events = instant->debug_events();
|
| + typedef std::list<std::pair<int64, std::string> > DebugEventList;
|
| + const DebugEventList& events = service->debug_events();
|
|
|
| base::DictionaryValue data;
|
| base::ListValue* entries = new base::ListValue();
|
| - for (std::list<DebugEvent>::const_iterator it = events.begin();
|
| - it != events.end(); ++it) {
|
| + for (DebugEventList::const_iterator it = events.begin(); it != events.end();
|
| + ++it) {
|
| base::DictionaryValue* entry = new base::DictionaryValue();
|
| entry->SetString("time", FormatTime(it->first));
|
| entry->SetString("text", it->second);
|
| @@ -133,7 +127,6 @@ void InstantUIMessageHandler::GetDebugInfo(const base::ListValue* args) {
|
| data.Set("entries", entries);
|
|
|
| web_ui()->CallJavascriptFunction("instantConfig.getDebugInfoResult", data);
|
| -#endif
|
| }
|
|
|
| } // namespace
|
| @@ -149,6 +142,9 @@ InstantUI::InstantUI(content::WebUI* web_ui) : WebUIController(web_ui) {
|
| content::WebUIDataSource::Add(profile, CreateInstantHTMLSource());
|
| }
|
|
|
| +InstantUI::~InstantUI() {
|
| +}
|
| +
|
| // static
|
| void InstantUI::RegisterUserPrefs(PrefRegistrySyncable* registry) {
|
| registry->RegisterStringPref(prefs::kInstantUIZeroSuggestUrlPrefix, "",
|
|
|