Chromium Code Reviews| 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" |
|
jdoerrie
2017/04/13 09:08:51
#include "base/values.h"
vabr (Chromium)
2017/04/13 12:03:14
Done.
| |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
| 20 #include "chrome/browser/ui/browser_instant_controller.h" | 20 #include "chrome/browser/ui/browser_instant_controller.h" |
| 21 #include "chrome/browser/ui/search/instant_controller.h" | 21 #include "chrome/browser/ui/search/instant_controller.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 24 #include "chrome/grit/browser_resources.h" | 24 #include "chrome/grit/browser_resources.h" |
| 25 #include "components/pref_registry/pref_registry_syncable.h" | 25 #include "components/pref_registry/pref_registry_syncable.h" |
| 26 #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... | |
| 133 return; | 133 return; |
| 134 Browser* browser = chrome::FindBrowserWithWebContents( | 134 Browser* browser = chrome::FindBrowserWithWebContents( |
| 135 web_ui()->GetWebContents()); | 135 web_ui()->GetWebContents()); |
| 136 if (!browser || !browser->instant_controller()) | 136 if (!browser || !browser->instant_controller()) |
| 137 return; | 137 return; |
| 138 | 138 |
| 139 InstantController* instant = browser->instant_controller()->instant(); | 139 InstantController* instant = browser->instant_controller()->instant(); |
| 140 const std::list<DebugEvent>& events = instant->debug_events(); | 140 const std::list<DebugEvent>& events = instant->debug_events(); |
| 141 | 141 |
| 142 base::DictionaryValue data; | 142 base::DictionaryValue data; |
| 143 base::ListValue* entries = new base::ListValue(); | 143 auto entries = base::MakeUnique<base::ListValue>(); |
| 144 for (std::list<DebugEvent>::const_iterator it = events.begin(); | 144 for (std::list<DebugEvent>::const_iterator it = events.begin(); |
| 145 it != events.end(); ++it) { | 145 it != events.end(); ++it) { |
| 146 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | 146 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
| 147 entry->SetString("time", FormatTime(it->first)); | 147 entry->SetString("time", FormatTime(it->first)); |
| 148 entry->SetString("text", it->second); | 148 entry->SetString("text", it->second); |
| 149 entries->Append(std::move(entry)); | 149 entries->Append(std::move(entry)); |
| 150 } | 150 } |
| 151 data.Set("entries", entries); | 151 data.Set("entries", std::move(entries)); |
| 152 | 152 |
| 153 web_ui()->CallJavascriptFunctionUnsafe("instantConfig.getDebugInfoResult", | 153 web_ui()->CallJavascriptFunctionUnsafe("instantConfig.getDebugInfoResult", |
| 154 data); | 154 data); |
| 155 #endif | 155 #endif |
| 156 } | 156 } |
| 157 | 157 |
| 158 void InstantUIMessageHandler::ClearDebugInfo(const base::ListValue* args) { | 158 void InstantUIMessageHandler::ClearDebugInfo(const base::ListValue* args) { |
| 159 #if !defined(OS_ANDROID) | 159 #if !defined(OS_ANDROID) |
| 160 if (!web_ui()->GetWebContents()) | 160 if (!web_ui()->GetWebContents()) |
| 161 return; | 161 return; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 180 Profile* profile = Profile::FromWebUI(web_ui); | 180 Profile* profile = Profile::FromWebUI(web_ui); |
| 181 content::WebUIDataSource::Add(profile, CreateInstantHTMLSource()); | 181 content::WebUIDataSource::Add(profile, CreateInstantHTMLSource()); |
| 182 } | 182 } |
| 183 | 183 |
| 184 // static | 184 // static |
| 185 void InstantUI::RegisterProfilePrefs( | 185 void InstantUI::RegisterProfilePrefs( |
| 186 user_prefs::PrefRegistrySyncable* registry) { | 186 user_prefs::PrefRegistrySyncable* registry) { |
| 187 registry->RegisterStringPref(prefs::kInstantUIZeroSuggestUrlPrefix, | 187 registry->RegisterStringPref(prefs::kInstantUIZeroSuggestUrlPrefix, |
| 188 std::string()); | 188 std::string()); |
| 189 } | 189 } |
| OLD | NEW |