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

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

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

Powered by Google App Engine
This is Rietveld 408576698