diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-09 17:50:51 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-09 17:50:51 +0000 |
commit | 74e50c0cc9c4f0ba3301ae678c0939e3628b8e7b (patch) | |
tree | ba59354b161fb545a980f009f62f0366e4bd27e0 /webkit/common | |
parent | 91800dec3b3d1c95ef3cc9619b59db1243f74805 (diff) | |
download | chromium_src-74e50c0cc9c4f0ba3301ae678c0939e3628b8e7b.zip chromium_src-74e50c0cc9c4f0ba3301ae678c0939e3628b8e7b.tar.gz chromium_src-74e50c0cc9c4f0ba3301ae678c0939e3628b8e7b.tar.bz2 |
Simplify the user agent code some more since after r255534 it's not affected by the site's URL.
Code in content always gets it now from ContentClient::GetUserAgent. In Chrome, there's a GetUserAgent function which returns it.
BUG=338338
R=isherman@chromium.org, pauljensen@chromium.org, scottmg@chromium.org, tfarina@chromium.org
Review URL: https://codereview.chromium.org/191093002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255858 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/common')
-rw-r--r-- | webkit/common/user_agent/user_agent.cc | 75 | ||||
-rw-r--r-- | webkit/common/user_agent/user_agent.h | 26 | ||||
-rw-r--r-- | webkit/common/user_agent/webkit_user_agent.gyp | 2 |
3 files changed, 0 insertions, 103 deletions
diff --git a/webkit/common/user_agent/user_agent.cc b/webkit/common/user_agent/user_agent.cc deleted file mode 100644 index b746e25..0000000 --- a/webkit/common/user_agent/user_agent.cc +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/common/user_agent/user_agent.h" - -#include "base/lazy_instance.h" -#include "base/logging.h" -#include "base/synchronization/lock.h" - -namespace webkit_glue { - -namespace { - -class UserAgentState { - public: - UserAgentState(); - ~UserAgentState(); - - void Set(const std::string& user_agent); - const std::string& Get() const; - - private: - mutable std::string user_agent_; - - mutable bool user_agent_requested_; - - // This object can be accessed from multiple threads, so use a lock around - // accesses to the data members. - mutable base::Lock lock_; -}; - -UserAgentState::UserAgentState() - : user_agent_requested_(false) { -} - -UserAgentState::~UserAgentState() { -} - -void UserAgentState::Set(const std::string& user_agent) { - base::AutoLock auto_lock(lock_); - if (user_agent == user_agent_) { - // We allow the user agent to be set multiple times as long as it - // is set to the same value, in order to simplify unit testing - // given g_user_agent is a global. - return; - } - DCHECK(!user_agent.empty()); - DCHECK(!user_agent_requested_) << "Setting the user agent after someone has " - "already requested it can result in unexpected behavior."; - user_agent_ = user_agent; -} - -const std::string& UserAgentState::Get() const { - base::AutoLock auto_lock(lock_); - user_agent_requested_ = true; - - DCHECK(!user_agent_.empty()); - - return user_agent_; -} - -base::LazyInstance<UserAgentState> g_user_agent = LAZY_INSTANCE_INITIALIZER; - -} // namespace - -void SetUserAgent(const std::string& user_agent) { - g_user_agent.Get().Set(user_agent); -} - -const std::string& GetUserAgent(const GURL& url) { - return g_user_agent.Get().Get(); -} - -} // namespace webkit_glue diff --git a/webkit/common/user_agent/user_agent.h b/webkit/common/user_agent/user_agent.h deleted file mode 100644 index 2118122..0000000 --- a/webkit/common/user_agent/user_agent.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_COMMON_USER_AGENT_USER_AGENT_H_ -#define WEBKIT_COMMON_USER_AGENT_USER_AGENT_H_ - -#include <string> - -#include "webkit/common/user_agent/webkit_user_agent_export.h" - -class GURL; - -namespace webkit_glue { - -// Sets the user agent. This must be called before GetUserAgent() can -// be called. -WEBKIT_USER_AGENT_EXPORT void SetUserAgent(const std::string& user_agent); - -// Returns the user agent to use for the given URL. SetUserAgent() must -// be called prior to calling this function. -WEBKIT_USER_AGENT_EXPORT const std::string& GetUserAgent(const GURL& url); - -} // namespace webkit_glue - -#endif // WEBKIT_COMMON_USER_AGENT_USER_AGENT_H_ diff --git a/webkit/common/user_agent/webkit_user_agent.gyp b/webkit/common/user_agent/webkit_user_agent.gyp index 27449b7..3fbc5e0 100644 --- a/webkit/common/user_agent/webkit_user_agent.gyp +++ b/webkit/common/user_agent/webkit_user_agent.gyp @@ -19,8 +19,6 @@ '<(DEPTH)/url/url.gyp:url_lib', ], 'sources': [ - 'user_agent.cc', - 'user_agent.h', 'user_agent_util.cc', 'user_agent_util_ios.mm', 'user_agent_util.h', |