Chromium Code Reviews| 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..8a83a31e208aa0400af113db759b0b8e12c78121 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,46 @@ bool WebstoreInlineInstaller::IsRequestorPermitted( |
| return true; |
| } |
| +void WebstoreInlineInstaller::StartWebstoreDataRequest( |
|
Devlin
2017/01/27 20:31:34
In the original version of this patch, this used a
robertshield
2017/01/28 03:58:48
Good idea! That's a lot cleaner and makes deriving
|
| + WebstoreDataFetcher* fetcher, |
| + const std::vector<GURL> redirect_list) { |
| + if (!redirect_list.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_list) { |
|
Devlin
2017/01/27 20:31:34
Are we worried at all about the size of the redire
robertshield
2017/01/28 03:58:48
Good question, I'm not really sure. A estimate of
|
| + redirect_chain->AppendString(url.spec()); |
| + } |
| + dictionary.Set("redirect_chain", std::move(redirect_chain)); |
| + |
| + std::unique_ptr<std::string> json = base::MakeUnique<std::string>(); |
| + base::JSONWriter::Write(dictionary, json.get()); |
| + fetcher->SetJsonPostData(std::move(json)); |
| + } |
| + fetcher->Start(); |
| +} |
| + |
| +void WebstoreInlineInstaller::OnBeforeWebstoreDataRequest( |
| + WebstoreDataFetcher* fetcher) { |
| + content::WebContents* web_contents = GetWebContents(); |
| + |
| + std::vector<GURL> redirect_chain; |
| + if (web_contents) { |
| + content::NavigationController& navigation_controller = |
| + web_contents->GetController(); |
| + content::NavigationEntry* navigation_entry = |
| + navigation_controller.GetLastCommittedEntry(); |
| + if (navigation_entry) { |
| + const std::vector<GURL>& temp_redirects = |
| + navigation_entry->GetRedirectChain(); |
| + redirect_chain.assign(temp_redirects.begin(), temp_redirects.end()); |
| + } |
| + } |
| + StartWebstoreDataRequest(fetcher, redirect_chain); |
| +} |
| + |
| bool WebstoreInlineInstaller::CheckRequestorAlive() const { |
| // The frame or tab may have gone away - cancel installation in that case. |
| return host_ != nullptr && web_contents() != nullptr; |