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

Unified Diff: chrome/browser/extensions/webstore_inline_installer.cc

Issue 2655823002: Include referrer chain with inline install requests. (Closed)
Patch Set: Add missing comment. Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/webstore_inline_installer.cc
diff --git a/chrome/browser/extensions/webstore_inline_installer.cc b/chrome/browser/extensions/webstore_inline_installer.cc
index 9e992bcb64fc1bedc00a3d598de8f3acc041de6b..38931a3a35395b9415c522f708252523cc06b337 100644
--- a/chrome/browser/extensions/webstore_inline_installer.cc
+++ b/chrome/browser/extensions/webstore_inline_installer.cc
@@ -4,11 +4,17 @@
#include "chrome/browser/extensions/webstore_inline_installer.h"
+#include <utility>
+
+#include "base/json/json_writer.h"
#include "base/strings/stringprintf.h"
+#include "base/values.h"
+#include "chrome/browser/extensions/webstore_data_fetcher.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "content/public/browser/navigation_details.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
using content::WebContents;
@@ -95,6 +101,41 @@ bool WebstoreInlineInstaller::IsRequestorPermitted(
return true;
}
+std::string WebstoreInlineInstaller::GetJsonPostData() {
+ // web_contents() might return null during tab destruction. This object would
+ // also be destroyed shortly thereafter but check to be on the safe side.
+ if (!web_contents())
+ return std::string();
+
+ content::NavigationController& navigation_controller =
+ web_contents()->GetController();
+ content::NavigationEntry* navigation_entry =
+ navigation_controller.GetLastCommittedEntry();
+
+ if (navigation_entry) {
+ const std::vector<GURL>& redirect_urls =
+ navigation_entry->GetRedirectChain();
+
+ if (!redirect_urls.empty()) {
+ base::DictionaryValue dictionary;
+ dictionary.SetString("id", id());
+ dictionary.SetString("referrer", requestor_url_.spec());
+ std::unique_ptr<base::ListValue> redirect_chain =
+ base::MakeUnique<base::ListValue>();
+ for (const GURL& url : redirect_urls) {
+ redirect_chain->AppendString(url.spec());
+ }
+ dictionary.Set("redirect_chain", std::move(redirect_chain));
+
+ std::string json;
+ base::JSONWriter::Write(dictionary, &json);
+ return json;
+ }
+ }
+
+ return std::string();
+}
+
bool WebstoreInlineInstaller::CheckRequestorAlive() const {
// The frame or tab may have gone away - cancel installation in that case.
return host_ != nullptr && web_contents() != nullptr;

Powered by Google App Engine
This is Rietveld 408576698