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

Side by Side Diff: chrome/browser/extensions/api/web_navigation/web_navigation_api_helpers.cc

Issue 2811673002: Reland: Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Workaround with 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 // Implements the Chrome Extensions WebNavigation API. 5 // Implements the Chrome Extensions WebNavigation API.
6 6
7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_helper s.h" 7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_helper s.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/memory/ptr_util.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" 17 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
17 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta nts.h" 18 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta nts.h"
18 #include "chrome/browser/extensions/extension_tab_util.h" 19 #include "chrome/browser/extensions/extension_tab_util.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/common/extensions/api/web_navigation.h" 21 #include "chrome/common/extensions/api/web_navigation.h"
21 #include "content/public/browser/navigation_handle.h" 22 #include "content/public/browser/navigation_handle.h"
22 #include "content/public/browser/render_frame_host.h" 23 #include "content/public/browser/render_frame_host.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 118 }
118 119
119 std::string transition_type_string = 120 std::string transition_type_string =
120 ui::PageTransitionGetCoreTransitionString(transition_type); 121 ui::PageTransitionGetCoreTransitionString(transition_type);
121 // For webNavigation API backward compatibility, keep "start_page" even after 122 // For webNavigation API backward compatibility, keep "start_page" even after
122 // renamed to "auto_toplevel". 123 // renamed to "auto_toplevel".
123 if (ui::PageTransitionCoreTypeIs(transition_type, 124 if (ui::PageTransitionCoreTypeIs(transition_type,
124 ui::PAGE_TRANSITION_AUTO_TOPLEVEL)) 125 ui::PAGE_TRANSITION_AUTO_TOPLEVEL))
125 transition_type_string = "start_page"; 126 transition_type_string = "start_page";
126 dict->SetString(keys::kTransitionTypeKey, transition_type_string); 127 dict->SetString(keys::kTransitionTypeKey, transition_type_string);
127 base::ListValue* qualifiers = new base::ListValue(); 128 auto qualifiers = base::MakeUnique<base::ListValue>();
128 if (transition_type & ui::PAGE_TRANSITION_CLIENT_REDIRECT) 129 if (transition_type & ui::PAGE_TRANSITION_CLIENT_REDIRECT)
129 qualifiers->AppendString("client_redirect"); 130 qualifiers->AppendString("client_redirect");
130 if (transition_type & ui::PAGE_TRANSITION_SERVER_REDIRECT) 131 if (transition_type & ui::PAGE_TRANSITION_SERVER_REDIRECT)
131 qualifiers->AppendString("server_redirect"); 132 qualifiers->AppendString("server_redirect");
132 if (transition_type & ui::PAGE_TRANSITION_FORWARD_BACK) 133 if (transition_type & ui::PAGE_TRANSITION_FORWARD_BACK)
133 qualifiers->AppendString("forward_back"); 134 qualifiers->AppendString("forward_back");
134 if (transition_type & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) 135 if (transition_type & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)
135 qualifiers->AppendString("from_address_bar"); 136 qualifiers->AppendString("from_address_bar");
136 dict->Set(keys::kTransitionQualifiersKey, qualifiers); 137 dict->Set(keys::kTransitionQualifiersKey, std::move(qualifiers));
137 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); 138 dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now()));
138 args->Append(std::move(dict)); 139 args->Append(std::move(dict));
139 140
140 std::unique_ptr<Event> event( 141 std::unique_ptr<Event> event(
141 new Event(histogram_value, event_name, std::move(args))); 142 new Event(histogram_value, event_name, std::move(args)));
142 DispatchEvent(navigation_handle->GetWebContents()->GetBrowserContext(), 143 DispatchEvent(navigation_handle->GetWebContents()->GetBrowserContext(),
143 std::move(event), url); 144 std::move(event), url);
144 } 145 }
145 146
146 // Constructs and dispatches an onDOMContentLoaded event. 147 // Constructs and dispatches an onDOMContentLoaded event.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 std::unique_ptr<Event> event( 269 std::unique_ptr<Event> event(
269 new Event(events::WEB_NAVIGATION_ON_TAB_REPLACED, 270 new Event(events::WEB_NAVIGATION_ON_TAB_REPLACED,
270 web_navigation::OnTabReplaced::kEventName, 271 web_navigation::OnTabReplaced::kEventName,
271 web_navigation::OnTabReplaced::Create(details))); 272 web_navigation::OnTabReplaced::Create(details)));
272 DispatchEvent(browser_context, std::move(event), GURL()); 273 DispatchEvent(browser_context, std::move(event), GURL());
273 } 274 }
274 275
275 } // namespace web_navigation_api_helpers 276 } // namespace web_navigation_api_helpers
276 277
277 } // namespace extensions 278 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_event_router.cc ('k') | chrome/browser/extensions/convert_user_script.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698