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

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

Issue 137833002: Fix an out-of-date issue in chrome.webNavigation document. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update doc Created 6 years, 11 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 "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta nts.h" 13 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta nts.h"
14 #include "chrome/browser/extensions/extension_system.h" 14 #include "chrome/browser/extensions/extension_system.h"
15 #include "chrome/browser/extensions/extension_tab_util.h" 15 #include "chrome/browser/extensions/extension_tab_util.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/extensions/api/web_navigation.h" 17 #include "chrome/common/extensions/api/web_navigation.h"
18 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "content/public/common/page_transition_types.h"
21 #include "extensions/browser/event_router.h" 22 #include "extensions/browser/event_router.h"
22 #include "extensions/common/event_filtering_info.h" 23 #include "extensions/common/event_filtering_info.h"
23 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
24 25
25 namespace extensions { 26 namespace extensions {
26 27
27 namespace keys = web_navigation_api_constants; 28 namespace keys = web_navigation_api_constants;
28 namespace web_navigation = api::web_navigation; 29 namespace web_navigation = api::web_navigation;
29 30
30 namespace web_navigation_api_helpers { 31 namespace web_navigation_api_helpers {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 bool is_main_frame, 93 bool is_main_frame,
93 const GURL& url, 94 const GURL& url,
94 content::PageTransition transition_type) { 95 content::PageTransition transition_type) {
95 scoped_ptr<base::ListValue> args(new base::ListValue()); 96 scoped_ptr<base::ListValue> args(new base::ListValue());
96 base::DictionaryValue* dict = new base::DictionaryValue(); 97 base::DictionaryValue* dict = new base::DictionaryValue();
97 dict->SetInteger(keys::kTabIdKey, ExtensionTabUtil::GetTabId(web_contents)); 98 dict->SetInteger(keys::kTabIdKey, ExtensionTabUtil::GetTabId(web_contents));
98 dict->SetString(keys::kUrlKey, url.spec()); 99 dict->SetString(keys::kUrlKey, url.spec());
99 dict->SetInteger(keys::kProcessIdKey, 100 dict->SetInteger(keys::kProcessIdKey,
100 web_contents->GetRenderViewHost()->GetProcess()->GetID()); 101 web_contents->GetRenderViewHost()->GetProcess()->GetID());
101 dict->SetInteger(keys::kFrameIdKey, GetFrameId(is_main_frame, frame_id)); 102 dict->SetInteger(keys::kFrameIdKey, GetFrameId(is_main_frame, frame_id));
102 dict->SetString( 103 std::string transition_type_string =
103 keys::kTransitionTypeKey, 104 content::PageTransitionGetCoreTransitionString(transition_type);
104 content::PageTransitionGetCoreTransitionString(transition_type)); 105 // For webNavigation API backward compatibility, keep "start_page" even after
106 // renamed to "auto_toplevel".
107 if (PageTransitionStripQualifier(transition_type) ==
108 content::PAGE_TRANSITION_AUTO_TOPLEVEL)
109 transition_type_string = "start_page";
110 dict->SetString(keys::kTransitionTypeKey, transition_type_string);
105 base::ListValue* qualifiers = new base::ListValue(); 111 base::ListValue* qualifiers = new base::ListValue();
106 if (transition_type & content::PAGE_TRANSITION_CLIENT_REDIRECT) 112 if (transition_type & content::PAGE_TRANSITION_CLIENT_REDIRECT)
107 qualifiers->Append(new base::StringValue("client_redirect")); 113 qualifiers->Append(new base::StringValue("client_redirect"));
108 if (transition_type & content::PAGE_TRANSITION_SERVER_REDIRECT) 114 if (transition_type & content::PAGE_TRANSITION_SERVER_REDIRECT)
109 qualifiers->Append(new base::StringValue("server_redirect")); 115 qualifiers->Append(new base::StringValue("server_redirect"));
110 if (transition_type & content::PAGE_TRANSITION_FORWARD_BACK) 116 if (transition_type & content::PAGE_TRANSITION_FORWARD_BACK)
111 qualifiers->Append(new base::StringValue("forward_back")); 117 qualifiers->Append(new base::StringValue("forward_back"));
112 if (transition_type & content::PAGE_TRANSITION_FROM_ADDRESS_BAR) 118 if (transition_type & content::PAGE_TRANSITION_FROM_ADDRESS_BAR)
113 qualifiers->Append(new base::StringValue("from_address_bar")); 119 qualifiers->Append(new base::StringValue("from_address_bar"));
114 dict->Set(keys::kTransitionQualifiersKey, qualifiers); 120 dict->Set(keys::kTransitionQualifiersKey, qualifiers);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 243
238 DispatchEvent(browser_context, 244 DispatchEvent(browser_context,
239 web_navigation::OnTabReplaced::kEventName, 245 web_navigation::OnTabReplaced::kEventName,
240 args.Pass(), 246 args.Pass(),
241 GURL()); 247 GURL());
242 } 248 }
243 249
244 } // namespace web_navigation_api_helpers 250 } // namespace web_navigation_api_helpers
245 251
246 } // namespace extensions 252 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/api/web_navigation.json » ('j') | chrome/common/extensions/api/web_navigation.json » ('J')

Powered by Google App Engine
This is Rietveld 408576698