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

Unified Diff: mojo/services/html_viewer/blink_platform_impl.cc

Issue 1008543005: Add HTMLViewer command line arg to set user agent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: formatting Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/html_viewer/blink_platform_impl.cc
diff --git a/mojo/services/html_viewer/blink_platform_impl.cc b/mojo/services/html_viewer/blink_platform_impl.cc
index e94e70ac22c772e4e9844fe6e2052bddf0e5edf9..6f9a8cbf8b73ca3313e2ab21b9bcca420966edea 100644
--- a/mojo/services/html_viewer/blink_platform_impl.cc
+++ b/mojo/services/html_viewer/blink_platform_impl.cc
@@ -6,6 +6,7 @@
#include <cmath>
+#include "base/command_line.h"
#include "base/rand_util.h"
#include "base/stl_util.h"
#include "base/synchronization/waitable_event.h"
@@ -21,10 +22,13 @@
namespace html_viewer {
namespace {
+// Allows overriding user agent scring.
+const char kUserAgentSwitch[] = "user-agent";
+
// TODO(darin): Figure out what our UA should really be.
-const char kUserAgentString[] =
- "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) "
- "Chrome/35.0.1916.153 Safari/537.36";
+const char kDefaultUserAgentString[] =
+ "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) "
+ "Chrome/35.0.1916.153 Safari/537.36";
class WebWaitableEventImpl : public blink::WebWaitableEvent {
public:
@@ -172,7 +176,12 @@ blink::WebSocketHandle* BlinkPlatformImpl::createWebSocketHandle() {
}
blink::WebString BlinkPlatformImpl::userAgent() {
- return blink::WebString::fromUTF8(kUserAgentString);
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(kUserAgentSwitch)) {
+ return blink::WebString::fromUTF8(
+ command_line->GetSwitchValueASCII(kUserAgentSwitch));
+ }
+ return blink::WebString::fromUTF8(kDefaultUserAgentString);
}
blink::WebData BlinkPlatformImpl::parseDataURL(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698