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

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

Issue 2695883003: Change uses of base::JoinString to pass StringPieces where possible. (Closed)
Patch Set: Remove dependency CL. Created 3 years, 9 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 #include "chrome/browser/extensions/webstore_installer.h" 5 #include "chrome/browser/extensions/webstore_installer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <limits> 9 #include <limits>
10 #include <set> 10 #include <set>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
17 #include "base/metrics/field_trial.h" 17 #include "base/metrics/field_trial.h"
18 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
19 #include "base/metrics/sparse_histogram.h" 19 #include "base/metrics/sparse_histogram.h"
20 #include "base/path_service.h" 20 #include "base/path_service.h"
21 #include "base/rand_util.h" 21 #include "base/rand_util.h"
22 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/string_piece.h"
23 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
24 #include "base/strings/stringprintf.h" 25 #include "base/strings/stringprintf.h"
25 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
26 #include "base/time/time.h" 27 #include "base/time/time.h"
27 #include "build/build_config.h" 28 #include "build/build_config.h"
28 #include "chrome/browser/chrome_notification_types.h" 29 #include "chrome/browser/chrome_notification_types.h"
29 #include "chrome/browser/download/download_crx_util.h" 30 #include "chrome/browser/download/download_crx_util.h"
30 #include "chrome/browser/download/download_prefs.h" 31 #include "chrome/browser/download/download_prefs.h"
31 #include "chrome/browser/download/download_stats.h" 32 #include "chrome/browser/download/download_stats.h"
32 #include "chrome/browser/extensions/crx_installer.h" 33 #include "chrome/browser/extensions/crx_installer.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 install_source = kDefaultInstallSource; 207 install_source = kDefaultInstallSource;
207 } 208 }
208 209
209 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 210 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
210 if (cmd_line->HasSwitch(switches::kAppsGalleryDownloadURL)) { 211 if (cmd_line->HasSwitch(switches::kAppsGalleryDownloadURL)) {
211 std::string download_url = 212 std::string download_url =
212 cmd_line->GetSwitchValueASCII(switches::kAppsGalleryDownloadURL); 213 cmd_line->GetSwitchValueASCII(switches::kAppsGalleryDownloadURL);
213 return GURL(base::StringPrintf(download_url.c_str(), 214 return GURL(base::StringPrintf(download_url.c_str(),
214 extension_id.c_str())); 215 extension_id.c_str()));
215 } 216 }
216 std::vector<std::string> params; 217 std::vector<base::StringPiece> params;
217 params.push_back("id=" + extension_id); 218 std::string extension_param = "id=" + extension_id;
219 std::string installsource_param = "installsource=" + install_source;
220 params.push_back(extension_param);
218 if (!install_source.empty()) 221 if (!install_source.empty())
219 params.push_back("installsource=" + install_source); 222 params.push_back(installsource_param);
220 params.push_back("uc"); 223 params.push_back("uc");
221 std::string url_string = extension_urls::GetWebstoreUpdateUrl().spec(); 224 std::string url_string = extension_urls::GetWebstoreUpdateUrl().spec();
222 225
223 GURL url(url_string + "?response=redirect&" + 226 GURL url(url_string + "?response=redirect&" +
224 update_client::UpdateQueryParams::Get( 227 update_client::UpdateQueryParams::Get(
225 update_client::UpdateQueryParams::CRX) + 228 update_client::UpdateQueryParams::CRX) +
226 "&x=" + net::EscapeQueryParamValue(base::JoinString(params, "&"), 229 "&x=" + net::EscapeQueryParamValue(base::JoinString(params, "&"),
227 true)); 230 true));
228 DCHECK(url.is_valid()); 231 DCHECK(url.is_valid());
229 232
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 1, 789 1,
787 kMaxSizeKb, 790 kMaxSizeKb,
788 kNumBuckets); 791 kNumBuckets);
789 } 792 }
790 UMA_HISTOGRAM_BOOLEAN( 793 UMA_HISTOGRAM_BOOLEAN(
791 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown", 794 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown",
792 total_bytes <= 0); 795 total_bytes <= 0);
793 } 796 }
794 797
795 } // namespace extensions 798 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/content_capabilities_browsertest.cc ('k') | chrome/browser/net/safe_search_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698