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

Side by Side Diff: ios/chrome/browser/web/chrome_web_client.mm

Issue 2705293014: Created web::UserAgentType. (Closed)
Patch Set: rebase + compile fix 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ios/chrome/browser/web/chrome_web_client.h" 5 #include "ios/chrome/browser/web/chrome_web_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/ios/ios_util.h" 9 #include "base/ios/ios_util.h"
10 #include "base/mac/bundle_locations.h" 10 #include "base/mac/bundle_locations.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 base::string16 ChromeWebClient::GetPluginNotSupportedText() const { 101 base::string16 ChromeWebClient::GetPluginNotSupportedText() const {
102 return l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED); 102 return l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED);
103 } 103 }
104 104
105 std::string ChromeWebClient::GetProduct() const { 105 std::string ChromeWebClient::GetProduct() const {
106 std::string product("CriOS/"); 106 std::string product("CriOS/");
107 product += version_info::GetVersionNumber(); 107 product += version_info::GetVersionNumber();
108 return product; 108 return product;
109 } 109 }
110 110
111 std::string ChromeWebClient::GetUserAgent(bool desktop_user_agent) const { 111 std::string ChromeWebClient::GetUserAgent(web::UserAgentType type) const {
112 // The user agent should not be requested for app-specific URLs.
113 DCHECK_NE(type, web::UserAgentType::NONE);
114
112 // Using desktop user agent overrides a command-line user agent, so that 115 // Using desktop user agent overrides a command-line user agent, so that
113 // request desktop site can still work when using an overridden UA. 116 // request desktop site can still work when using an overridden UA.
114 if (desktop_user_agent) { 117 if (type == web::UserAgentType::DESKTOP)
115 return base::SysNSStringToUTF8(ChromeWebView::kDesktopUserAgent); 118 return base::SysNSStringToUTF8(ChromeWebView::kDesktopUserAgent);
116 }
117 119
118 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 120 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
119 if (command_line->HasSwitch(switches::kUserAgent)) { 121 if (command_line->HasSwitch(switches::kUserAgent)) {
120 std::string user_agent = 122 std::string user_agent =
121 command_line->GetSwitchValueASCII(switches::kUserAgent); 123 command_line->GetSwitchValueASCII(switches::kUserAgent);
122 if (net::HttpUtil::IsValidHeaderValue(user_agent)) 124 if (net::HttpUtil::IsValidHeaderValue(user_agent))
123 return user_agent; 125 return user_agent;
124 LOG(WARNING) << "Ignored invalid value for flag --" << switches::kUserAgent; 126 LOG(WARNING) << "Ignored invalid value for flag --" << switches::kUserAgent;
125 } 127 }
126 128
127 std::string product = GetProduct(); 129 return web::BuildUserAgentFromProduct(GetProduct());
128 return web::BuildUserAgentFromProduct(product);
129 } 130 }
130 131
131 base::string16 ChromeWebClient::GetLocalizedString(int message_id) const { 132 base::string16 ChromeWebClient::GetLocalizedString(int message_id) const {
132 return l10n_util::GetStringUTF16(message_id); 133 return l10n_util::GetStringUTF16(message_id);
133 } 134 }
134 135
135 base::StringPiece ChromeWebClient::GetDataResource( 136 base::StringPiece ChromeWebClient::GetDataResource(
136 int resource_id, 137 int resource_id,
137 ui::ScaleFactor scale_factor) const { 138 ui::ScaleFactor scale_factor) const {
138 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( 139 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // If this call fails, web will fall back to the default params. 179 // If this call fails, web will fall back to the default params.
179 *params_vector = 180 *params_vector =
180 task_scheduler_util::GetBrowserWorkerPoolParamsFromVariations(); 181 task_scheduler_util::GetBrowserWorkerPoolParamsFromVariations();
181 *index_to_traits_callback = 182 *index_to_traits_callback =
182 base::Bind(&task_scheduler_util::BrowserWorkerPoolIndexForTraits); 183 base::Bind(&task_scheduler_util::BrowserWorkerPoolIndexForTraits);
183 } 184 }
184 185
185 void ChromeWebClient::PerformExperimentalTaskSchedulerRedirections() { 186 void ChromeWebClient::PerformExperimentalTaskSchedulerRedirections() {
186 task_scheduler_util::MaybePerformBrowserTaskSchedulerRedirection(); 187 task_scheduler_util::MaybePerformBrowserTaskSchedulerRedirection();
187 } 188 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/web/chrome_web_client.h ('k') | ios/chrome/browser/web/chrome_web_client_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698