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

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

Issue 2831263003: Gate sending referrers to CWS on whether the profile has SafeBrowsing enabled. (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
« no previous file with comments | « no previous file | chrome/browser/extensions/webstore_inline_installer_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/extensions/webstore_inline_installer.h" 5 #include "chrome/browser/extensions/webstore_inline_installer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/extensions/webstore_data_fetcher.h" 12 #include "chrome/browser/extensions/webstore_data_fetcher.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 15 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
16 #include "chrome/common/pref_names.h"
17 #include "components/prefs/pref_service.h"
16 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/navigation_handle.h" 19 #include "content/public/browser/navigation_handle.h"
18 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
19 21
20 using content::WebContents; 22 using content::WebContents;
21 23
22 namespace extensions { 24 namespace extensions {
23 25
24 const char kInvalidWebstoreResponseError[] = 26 const char kInvalidWebstoreResponseError[] =
25 "Invalid Chrome Web Store response."; 27 "Invalid Chrome Web Store response.";
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 *error = ""; 102 *error = "";
101 return true; 103 return true;
102 } 104 }
103 105
104 std::string WebstoreInlineInstaller::GetJsonPostData() { 106 std::string WebstoreInlineInstaller::GetJsonPostData() {
105 // web_contents() might return null during tab destruction. This object would 107 // web_contents() might return null during tab destruction. This object would
106 // also be destroyed shortly thereafter but check to be on the safe side. 108 // also be destroyed shortly thereafter but check to be on the safe side.
107 if (!web_contents()) 109 if (!web_contents())
108 return std::string(); 110 return std::string();
109 111
112 // Report extra data only when SafeBrowsing is enabled for the current
113 // profile.
114 Profile* profile =
115 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
Devlin 2017/04/21 17:09:43 nit: looks like WebstoreStandaloneInstaller has a
robertshield 2017/04/21 18:02:54 Thanks, done.
116 if (!profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled))
117 return std::string();
118
110 content::NavigationController& navigation_controller = 119 content::NavigationController& navigation_controller =
111 web_contents()->GetController(); 120 web_contents()->GetController();
112 content::NavigationEntry* navigation_entry = 121 content::NavigationEntry* navigation_entry =
113 navigation_controller.GetLastCommittedEntry(); 122 navigation_controller.GetLastCommittedEntry();
114 123
115 if (navigation_entry) { 124 if (navigation_entry) {
116 const std::vector<GURL>& redirect_urls = 125 const std::vector<GURL>& redirect_urls =
117 navigation_entry->GetRedirectChain(); 126 navigation_entry->GetRedirectChain();
118 127
119 if (!redirect_urls.empty()) { 128 if (!redirect_urls.empty()) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 DLOG(WARNING) << "Could not parse " << verified_site_pattern_spec << 297 DLOG(WARNING) << "Could not parse " << verified_site_pattern_spec <<
289 " as URL pattern " << parse_result; 298 " as URL pattern " << parse_result;
290 return false; 299 return false;
291 } 300 }
292 verified_site_pattern.SetScheme("*"); 301 verified_site_pattern.SetScheme("*");
293 302
294 return verified_site_pattern.MatchesURL(requestor_url); 303 return verified_site_pattern.MatchesURL(requestor_url);
295 } 304 }
296 305
297 } // namespace extensions 306 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/webstore_inline_installer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698