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

Side by Side Diff: chrome/browser/extensions/activity_log/activity_log.cc

Issue 2777063003: Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Fix SupervisedUserWhitelistInstaller 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/activity_log/activity_log.h" 5 #include "chrome/browser/extensions/activity_log/activity_log.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/json/json_string_value_serializer.h" 13 #include "base/json/json_string_value_serializer.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h"
17 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
19 #include "base/synchronization/lock.h" 20 #include "base/synchronization/lock.h"
20 #include "base/threading/thread_checker.h" 21 #include "base/threading/thread_checker.h"
jdoerrie 2017/04/06 14:25:49 #include "base/values.h"
vabr (Chromium) 2017/04/07 20:40:39 Done.
21 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/chrome_notification_types.h" 23 #include "chrome/browser/chrome_notification_types.h"
23 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" 24 #include "chrome/browser/extensions/activity_log/activity_action_constants.h"
24 #include "chrome/browser/extensions/activity_log/counting_policy.h" 25 #include "chrome/browser/extensions/activity_log/counting_policy.h"
25 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h" 26 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h"
26 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat e_api.h" 27 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat e_api.h"
27 #include "chrome/browser/extensions/extension_tab_util.h" 28 #include "chrome/browser/extensions/extension_tab_util.h"
28 #include "chrome/browser/prerender/prerender_manager.h" 29 #include "chrome/browser/prerender/prerender_manager.h"
29 #include "chrome/browser/prerender/prerender_manager_factory.h" 30 #include "chrome/browser/prerender/prerender_manager_factory.h"
30 #include "chrome/browser/profiles/profile.h" 31 #include "chrome/browser/profiles/profile.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 bool arg_incognito = action->page_incognito(); 271 bool arg_incognito = action->page_incognito();
271 272
272 switch (api_info->arg_url_transform) { 273 switch (api_info->arg_url_transform) {
273 case NONE: { 274 case NONE: {
274 // No translation needed; just extract the URL directly from a raw string 275 // No translation needed; just extract the URL directly from a raw string
275 // or from a dictionary. Succeeds if we can find a string in the 276 // or from a dictionary. Succeeds if we can find a string in the
276 // argument list and that the string resolves to a valid URL. 277 // argument list and that the string resolves to a valid URL.
277 std::string url_string; 278 std::string url_string;
278 if (action->args()->GetString(url_index, &url_string) && 279 if (action->args()->GetString(url_index, &url_string) &&
279 ResolveUrl(action->page_url(), url_string, &arg_url)) { 280 ResolveUrl(action->page_url(), url_string, &arg_url)) {
280 action->mutable_args()->Set(url_index, 281 action->mutable_args()->Set(
281 new base::Value(kArgUrlPlaceholder)); 282 url_index, base::MakeUnique<base::Value>(kArgUrlPlaceholder));
282 } 283 }
283 break; 284 break;
284 } 285 }
285 286
286 case DICT_LOOKUP: { 287 case DICT_LOOKUP: {
287 CHECK(api_info->arg_url_dict_path); 288 CHECK(api_info->arg_url_dict_path);
288 // Look up the URL from a dictionary at the specified location. Succeeds 289 // Look up the URL from a dictionary at the specified location. Succeeds
289 // if we can find a dictionary in the argument list, the dictionary 290 // if we can find a dictionary in the argument list, the dictionary
290 // contains the specified key, and the corresponding value resolves to a 291 // contains the specified key, and the corresponding value resolves to a
291 // valid URL. 292 // valid URL.
(...skipping 10 matching lines...) Expand all
302 case LOOKUP_TAB_ID: { 303 case LOOKUP_TAB_ID: {
303 // Translation of tab IDs to URLs has been requested. There are two 304 // Translation of tab IDs to URLs has been requested. There are two
304 // cases to consider: either a single integer or a list of integers (when 305 // cases to consider: either a single integer or a list of integers (when
305 // multiple tabs are manipulated). 306 // multiple tabs are manipulated).
306 int tab_id; 307 int tab_id;
307 base::ListValue* tab_list = NULL; 308 base::ListValue* tab_list = NULL;
308 if (action->args()->GetInteger(url_index, &tab_id)) { 309 if (action->args()->GetInteger(url_index, &tab_id)) {
309 // Single tab ID to translate. 310 // Single tab ID to translate.
310 GetUrlForTabId(tab_id, profile, &arg_url, &arg_incognito); 311 GetUrlForTabId(tab_id, profile, &arg_url, &arg_incognito);
311 if (arg_url.is_valid()) { 312 if (arg_url.is_valid()) {
312 action->mutable_args()->Set(url_index, 313 action->mutable_args()->Set(
313 new base::Value(kArgUrlPlaceholder)); 314 url_index, base::MakeUnique<base::Value>(kArgUrlPlaceholder));
314 } 315 }
315 } else if (action->mutable_args()->GetList(url_index, &tab_list)) { 316 } else if (action->mutable_args()->GetList(url_index, &tab_list)) {
316 // A list of possible IDs to translate. Work through in reverse order 317 // A list of possible IDs to translate. Work through in reverse order
317 // so the last one translated is left in arg_url. 318 // so the last one translated is left in arg_url.
318 int extracted_index = -1; // Which list item is copied to arg_url? 319 int extracted_index = -1; // Which list item is copied to arg_url?
319 for (int i = tab_list->GetSize() - 1; i >= 0; --i) { 320 for (int i = tab_list->GetSize() - 1; i >= 0; --i) {
320 if (tab_list->GetInteger(i, &tab_id) && 321 if (tab_list->GetInteger(i, &tab_id) &&
321 GetUrlForTabId(tab_id, profile, &arg_url, &arg_incognito)) { 322 GetUrlForTabId(tab_id, profile, &arg_url, &arg_incognito)) {
322 if (!arg_incognito) 323 if (!arg_incognito)
323 tab_list->Set(i, new base::Value(arg_url.spec())); 324 tab_list->Set(i, base::MakeUnique<base::Value>(arg_url.spec()));
324 extracted_index = i; 325 extracted_index = i;
325 } 326 }
326 } 327 }
327 if (extracted_index >= 0) { 328 if (extracted_index >= 0) {
328 tab_list->Set(extracted_index, new base::Value(kArgUrlPlaceholder)); 329 tab_list->Set(extracted_index,
330 base::MakeUnique<base::Value>(kArgUrlPlaceholder));
329 } 331 }
330 } 332 }
331 break; 333 break;
332 } 334 }
333 335
334 default: 336 default:
335 NOTREACHED(); 337 NOTREACHED();
336 } 338 }
337 339
338 if (arg_url.is_valid()) { 340 if (arg_url.is_valid()) {
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 } 936 }
935 } 937 }
936 938
937 template <> 939 template <>
938 void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() { 940 void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() {
939 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 941 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
940 DependsOn(ExtensionRegistryFactory::GetInstance()); 942 DependsOn(ExtensionRegistryFactory::GetInstance());
941 } 943 }
942 944
943 } // namespace extensions 945 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698