Page Speed Optimization Libraries
1.5.27.2
|
00001 /* 00002 * Copyright 2011 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00018 00019 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_TEST_URL_NAMER_H_ 00020 #define NET_INSTAWEB_REWRITER_PUBLIC_TEST_URL_NAMER_H_ 00021 00022 #include "net/instaweb/rewriter/public/url_namer.h" 00023 00024 #include "net/instaweb/util/public/basictypes.h" 00025 #include "net/instaweb/util/public/string.h" 00026 #include "net/instaweb/util/public/string_util.h" 00027 00028 namespace net_instaweb { 00029 00030 class GoogleUrl; 00031 class OutputResource; 00032 class ResourceNamer; 00033 class RewriteOptions; 00034 00037 class TestUrlNamer : public UrlNamer { 00038 public: 00039 TestUrlNamer(); 00040 virtual ~TestUrlNamer(); 00041 00042 virtual GoogleString Encode(const RewriteOptions* rewrite_options, 00043 const OutputResource& output_resource, 00044 EncodeOption encode_option) const; 00045 00046 virtual bool Decode(const GoogleUrl& request_url, 00047 GoogleUrl* owner_domain, 00048 GoogleString* decoded) const; 00049 00050 static GoogleString EncodeUrl(const StringPiece& original_base, 00051 const StringPiece& unmapped_base, 00052 const StringPiece& resolved_path, 00053 const ResourceNamer& leaf_details); 00054 00057 virtual bool ProxyMode() const { return proxy_mode_; } 00058 00060 virtual bool IsProxyEncoded(const GoogleUrl& url) const; 00061 00063 static void SetProxyMode(bool value) { proxy_mode_ = value; } 00064 00067 static void UseNormalEncoding(bool yes) { 00068 use_normal_encoding_ = yes; 00069 } 00070 00071 static bool UseNormalEncoding() { return use_normal_encoding_; } 00072 00073 private: 00074 bool IsOriginEncoded(const GoogleUrl& url) const; 00075 bool IsPathEncoded(const GoogleUrl& url) const; 00076 00077 static bool use_normal_encoding_; 00078 static bool proxy_mode_; 00079 00080 DISALLOW_COPY_AND_ASSIGN(TestUrlNamer); 00081 }; 00082 00083 } 00084 00085 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_TEST_URL_NAMER_H_