OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/instant_ui.h" | 5 #include "chrome/browser/ui/webui/instant_ui.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/values.h" | |
18 #include "build/build_config.h" | 17 #include "build/build_config.h" |
19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
21 #include "chrome/browser/ui/browser_instant_controller.h" | 20 #include "chrome/browser/ui/browser_instant_controller.h" |
22 #include "chrome/browser/ui/search/instant_controller.h" | 21 #include "chrome/browser/ui/search/instant_controller.h" |
23 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
24 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
25 #include "chrome/grit/browser_resources.h" | 24 #include "chrome/grit/browser_resources.h" |
26 #include "components/pref_registry/pref_registry_syncable.h" | 25 #include "components/pref_registry/pref_registry_syncable.h" |
27 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 return; | 133 return; |
135 Browser* browser = chrome::FindBrowserWithWebContents( | 134 Browser* browser = chrome::FindBrowserWithWebContents( |
136 web_ui()->GetWebContents()); | 135 web_ui()->GetWebContents()); |
137 if (!browser || !browser->instant_controller()) | 136 if (!browser || !browser->instant_controller()) |
138 return; | 137 return; |
139 | 138 |
140 InstantController* instant = browser->instant_controller()->instant(); | 139 InstantController* instant = browser->instant_controller()->instant(); |
141 const std::list<DebugEvent>& events = instant->debug_events(); | 140 const std::list<DebugEvent>& events = instant->debug_events(); |
142 | 141 |
143 base::DictionaryValue data; | 142 base::DictionaryValue data; |
144 auto entries = base::MakeUnique<base::ListValue>(); | 143 base::ListValue* entries = new base::ListValue(); |
145 for (std::list<DebugEvent>::const_iterator it = events.begin(); | 144 for (std::list<DebugEvent>::const_iterator it = events.begin(); |
146 it != events.end(); ++it) { | 145 it != events.end(); ++it) { |
147 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | 146 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
148 entry->SetString("time", FormatTime(it->first)); | 147 entry->SetString("time", FormatTime(it->first)); |
149 entry->SetString("text", it->second); | 148 entry->SetString("text", it->second); |
150 entries->Append(std::move(entry)); | 149 entries->Append(std::move(entry)); |
151 } | 150 } |
152 data.Set("entries", std::move(entries)); | 151 data.Set("entries", entries); |
153 | 152 |
154 web_ui()->CallJavascriptFunctionUnsafe("instantConfig.getDebugInfoResult", | 153 web_ui()->CallJavascriptFunctionUnsafe("instantConfig.getDebugInfoResult", |
155 data); | 154 data); |
156 #endif | 155 #endif |
157 } | 156 } |
158 | 157 |
159 void InstantUIMessageHandler::ClearDebugInfo(const base::ListValue* args) { | 158 void InstantUIMessageHandler::ClearDebugInfo(const base::ListValue* args) { |
160 #if !defined(OS_ANDROID) | 159 #if !defined(OS_ANDROID) |
161 if (!web_ui()->GetWebContents()) | 160 if (!web_ui()->GetWebContents()) |
162 return; | 161 return; |
(...skipping 18 matching lines...) Expand all Loading... |
181 Profile* profile = Profile::FromWebUI(web_ui); | 180 Profile* profile = Profile::FromWebUI(web_ui); |
182 content::WebUIDataSource::Add(profile, CreateInstantHTMLSource()); | 181 content::WebUIDataSource::Add(profile, CreateInstantHTMLSource()); |
183 } | 182 } |
184 | 183 |
185 // static | 184 // static |
186 void InstantUI::RegisterProfilePrefs( | 185 void InstantUI::RegisterProfilePrefs( |
187 user_prefs::PrefRegistrySyncable* registry) { | 186 user_prefs::PrefRegistrySyncable* registry) { |
188 registry->RegisterStringPref(prefs::kInstantUIZeroSuggestUrlPrefix, | 187 registry->RegisterStringPref(prefs::kInstantUIZeroSuggestUrlPrefix, |
189 std::string()); | 188 std::string()); |
190 } | 189 } |
OLD | NEW |