OLD | NEW |
---|---|
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 Loading... | |
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(); | |
liaoyuke
2017/02/25 01:28:19
Do we really need this return statement?
kkhorimoto
2017/02/25 01:35:05
Yes, NOTREACHED() does nothing in non-debug builds
liaoyuke
2017/02/25 01:40:55
I think it will compile even without this return,
kkhorimoto
2017/02/25 01:52:09
It will compile, but it will return the wrong valu
| |
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 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 } |
OLD | NEW |