Browse Source

Correctly set user agent for devtools

Cheng Zhao 9 years ago
parent
commit
a5dc911a05
2 changed files with 9 additions and 0 deletions
  1. 8 0
      atom/app/atom_content_client.cc
  2. 1 0
      atom/app/atom_content_client.h

+ 8 - 0
atom/app/atom_content_client.cc

@@ -7,6 +7,7 @@
 #include <string>
 #include <vector>
 
+#include "atom/common/atom_version.h"
 #include "atom/common/chrome_version.h"
 #include "atom/common/options_switches.h"
 #include "base/command_line.h"
@@ -14,6 +15,7 @@
 #include "base/strings/string_util.h"
 #include "content/public/common/content_constants.h"
 #include "content/public/common/pepper_plugin_info.h"
+#include "content/public/common/user_agent.h"
 #include "ppapi/shared_impl/ppapi_permissions.h"
 
 namespace atom {
@@ -72,6 +74,12 @@ std::string AtomContentClient::GetProduct() const {
   return "Chrome/" CHROME_VERSION_STRING;
 }
 
+std::string AtomContentClient::GetUserAgent() const {
+  return content::BuildUserAgentFromProduct(
+      "Chrome/" CHROME_VERSION_STRING " "
+      ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING);
+}
+
 void AtomContentClient::AddAdditionalSchemes(
     std::vector<std::string>* standard_schemes,
     std::vector<std::string>* savable_schemes) {

+ 1 - 0
atom/app/atom_content_client.h

@@ -20,6 +20,7 @@ class AtomContentClient : public brightray::ContentClient {
  protected:
   // content::ContentClient:
   std::string GetProduct() const override;
+  std::string GetUserAgent() const override;
   void AddAdditionalSchemes(
       std::vector<std::string>* standard_schemes,
       std::vector<std::string>* savable_schemes) override;