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

Side by Side Diff: chrome/browser/ui/webui/instant_ui.cc

Issue 2814363006: Reland of Stop passing raw pointers to base::Value API in c/b/ui (Closed)
Patch Set: std::move Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_finder.h"
20 #include "chrome/browser/ui/browser_instant_controller.h" 21 #include "chrome/browser/ui/browser_instant_controller.h"
21 #include "chrome/browser/ui/search/instant_controller.h" 22 #include "chrome/browser/ui/search/instant_controller.h"
22 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
23 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
24 #include "chrome/grit/browser_resources.h" 25 #include "chrome/grit/browser_resources.h"
25 #include "components/pref_registry/pref_registry_syncable.h" 26 #include "components/pref_registry/pref_registry_syncable.h"
26 #include "components/prefs/pref_service.h" 27 #include "components/prefs/pref_service.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 return; 134 return;
134 Browser* browser = chrome::FindBrowserWithWebContents( 135 Browser* browser = chrome::FindBrowserWithWebContents(
135 web_ui()->GetWebContents()); 136 web_ui()->GetWebContents());
136 if (!browser || !browser->instant_controller()) 137 if (!browser || !browser->instant_controller())
137 return; 138 return;
138 139
139 InstantController* instant = browser->instant_controller()->instant(); 140 InstantController* instant = browser->instant_controller()->instant();
140 const std::list<DebugEvent>& events = instant->debug_events(); 141 const std::list<DebugEvent>& events = instant->debug_events();
141 142
142 base::DictionaryValue data; 143 base::DictionaryValue data;
143 base::ListValue* entries = new base::ListValue(); 144 auto entries = base::MakeUnique<base::ListValue>();
144 for (std::list<DebugEvent>::const_iterator it = events.begin(); 145 for (std::list<DebugEvent>::const_iterator it = events.begin();
145 it != events.end(); ++it) { 146 it != events.end(); ++it) {
146 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); 147 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
147 entry->SetString("time", FormatTime(it->first)); 148 entry->SetString("time", FormatTime(it->first));
148 entry->SetString("text", it->second); 149 entry->SetString("text", it->second);
149 entries->Append(std::move(entry)); 150 entries->Append(std::move(entry));
150 } 151 }
151 data.Set("entries", entries); 152 data.Set("entries", std::move(entries));
152 153
153 web_ui()->CallJavascriptFunctionUnsafe("instantConfig.getDebugInfoResult", 154 web_ui()->CallJavascriptFunctionUnsafe("instantConfig.getDebugInfoResult",
154 data); 155 data);
155 #endif 156 #endif
156 } 157 }
157 158
158 void InstantUIMessageHandler::ClearDebugInfo(const base::ListValue* args) { 159 void InstantUIMessageHandler::ClearDebugInfo(const base::ListValue* args) {
159 #if !defined(OS_ANDROID) 160 #if !defined(OS_ANDROID)
160 if (!web_ui()->GetWebContents()) 161 if (!web_ui()->GetWebContents())
161 return; 162 return;
(...skipping 18 matching lines...) Expand all
180 Profile* profile = Profile::FromWebUI(web_ui); 181 Profile* profile = Profile::FromWebUI(web_ui);
181 content::WebUIDataSource::Add(profile, CreateInstantHTMLSource()); 182 content::WebUIDataSource::Add(profile, CreateInstantHTMLSource());
182 } 183 }
183 184
184 // static 185 // static
185 void InstantUI::RegisterProfilePrefs( 186 void InstantUI::RegisterProfilePrefs(
186 user_prefs::PrefRegistrySyncable* registry) { 187 user_prefs::PrefRegistrySyncable* registry) {
187 registry->RegisterStringPref(prefs::kInstantUIZeroSuggestUrlPrefix, 188 registry->RegisterStringPref(prefs::kInstantUIZeroSuggestUrlPrefix,
188 std::string()); 189 std::string());
189 } 190 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698