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

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

Issue 2705293014: Created web::UserAgentType. (Closed)
Patch Set: fix GetLastCommittedWebItem Created 3 years, 10 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 if (type == web::UserAgentType::NONE) {
114 NOTREACHED();
115 return std::string();
Eugene But (OOO till 7-30) 2017/02/25 01:51:52 DCHECK_NE(type, web::UserAgentType::NONE); See Ch
kkhorimoto 2017/02/27 23:29:04 Hmm, I had not seen those guidelines before. I gu
116 }
117
112 // Using desktop user agent overrides a command-line user agent, so that 118 // Using desktop user agent overrides a command-line user agent, so that
113 // request desktop site can still work when using an overridden UA. 119 // request desktop site can still work when using an overridden UA.
114 if (desktop_user_agent) { 120 if (type == web::UserAgentType::DESKTOP)
115 return base::SysNSStringToUTF8(ChromeWebView::kDesktopUserAgent); 121 return base::SysNSStringToUTF8(ChromeWebView::kDesktopUserAgent);
116 }
117 122
118 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 123 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
119 if (command_line->HasSwitch(switches::kUserAgent)) { 124 if (command_line->HasSwitch(switches::kUserAgent)) {
120 std::string user_agent = 125 std::string user_agent =
121 command_line->GetSwitchValueASCII(switches::kUserAgent); 126 command_line->GetSwitchValueASCII(switches::kUserAgent);
122 if (net::HttpUtil::IsValidHeaderValue(user_agent)) 127 if (net::HttpUtil::IsValidHeaderValue(user_agent))
123 return user_agent; 128 return user_agent;
124 LOG(WARNING) << "Ignored invalid value for flag --" << switches::kUserAgent; 129 LOG(WARNING) << "Ignored invalid value for flag --" << switches::kUserAgent;
125 } 130 }
126 131
127 std::string product = GetProduct(); 132 std::string product = GetProduct();
128 return web::BuildUserAgentFromProduct(product); 133 return web::BuildUserAgentFromProduct(product);
Eugene But (OOO till 7-30) 2017/02/25 01:51:52 Optional nit: Since you touching this. return web:
kkhorimoto 2017/02/27 23:29:04 Done.
129 } 134 }
130 135
131 base::string16 ChromeWebClient::GetLocalizedString(int message_id) const { 136 base::string16 ChromeWebClient::GetLocalizedString(int message_id) const {
132 return l10n_util::GetStringUTF16(message_id); 137 return l10n_util::GetStringUTF16(message_id);
133 } 138 }
134 139
135 base::StringPiece ChromeWebClient::GetDataResource( 140 base::StringPiece ChromeWebClient::GetDataResource(
136 int resource_id, 141 int resource_id,
137 ui::ScaleFactor scale_factor) const { 142 ui::ScaleFactor scale_factor) const {
138 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( 143 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. 183 // If this call fails, web will fall back to the default params.
179 *params_vector = 184 *params_vector =
180 task_scheduler_util::GetBrowserWorkerPoolParamsFromVariations(); 185 task_scheduler_util::GetBrowserWorkerPoolParamsFromVariations();
181 *index_to_traits_callback = 186 *index_to_traits_callback =
182 base::Bind(&task_scheduler_util::BrowserWorkerPoolIndexForTraits); 187 base::Bind(&task_scheduler_util::BrowserWorkerPoolIndexForTraits);
183 } 188 }
184 189
185 void ChromeWebClient::PerformExperimentalTaskSchedulerRedirections() { 190 void ChromeWebClient::PerformExperimentalTaskSchedulerRedirections() {
186 task_scheduler_util::MaybePerformBrowserTaskSchedulerRedirection(); 191 task_scheduler_util::MaybePerformBrowserTaskSchedulerRedirection();
187 } 192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698