OLD | NEW |
1 // Copyright 2009 The Chromium Authors. All rights reserved. | 1 // Copyright 2009 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 "chrome/common/extensions/user_script.h" | 5 #include "chrome/common/extensions/user_script.h" |
6 | 6 |
7 #include "base/pickle.h" | 7 #include "base/pickle.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 void UserScript::File::Unpickle(const ::Pickle& pickle, void** iter) { | 70 void UserScript::File::Unpickle(const ::Pickle& pickle, void** iter) { |
71 // Read url. | 71 // Read url. |
72 std::string url; | 72 std::string url; |
73 CHECK(pickle.ReadString(iter, &url)); | 73 CHECK(pickle.ReadString(iter, &url)); |
74 set_url(GURL(url)); | 74 set_url(GURL(url)); |
75 } | 75 } |
76 | 76 |
77 void UserScript::Pickle(::Pickle* pickle) const { | 77 void UserScript::Pickle(::Pickle* pickle) const { |
78 // Write the run location. | 78 // Write simple types. |
79 pickle->WriteInt(run_location()); | 79 pickle->WriteInt(run_location()); |
80 | |
81 // Write the extension id. | |
82 pickle->WriteString(extension_id()); | 80 pickle->WriteString(extension_id()); |
83 | |
84 // Write Greasemonkey emulation. | |
85 pickle->WriteBool(emulate_greasemonkey()); | 81 pickle->WriteBool(emulate_greasemonkey()); |
86 | |
87 // Write match all frames | |
88 pickle->WriteBool(match_all_frames()); | 82 pickle->WriteBool(match_all_frames()); |
| 83 pickle->WriteBool(is_incognito_enabled()); |
89 | 84 |
90 // Write globs. | 85 // Write globs. |
91 std::vector<std::string>::const_iterator glob; | 86 std::vector<std::string>::const_iterator glob; |
92 pickle->WriteSize(globs_.size()); | 87 pickle->WriteSize(globs_.size()); |
93 for (glob = globs_.begin(); glob != globs_.end(); ++glob) { | 88 for (glob = globs_.begin(); glob != globs_.end(); ++glob) { |
94 pickle->WriteString(*glob); | 89 pickle->WriteString(*glob); |
95 } | 90 } |
96 pickle->WriteSize(exclude_globs_.size()); | 91 pickle->WriteSize(exclude_globs_.size()); |
97 for (glob = exclude_globs_.begin(); glob != exclude_globs_.end(); ++glob) { | 92 for (glob = exclude_globs_.begin(); glob != exclude_globs_.end(); ++glob) { |
98 pickle->WriteString(*glob); | 93 pickle->WriteString(*glob); |
(...skipping 21 matching lines...) Expand all Loading... |
120 } | 115 } |
121 } | 116 } |
122 | 117 |
123 void UserScript::Unpickle(const ::Pickle& pickle, void** iter) { | 118 void UserScript::Unpickle(const ::Pickle& pickle, void** iter) { |
124 // Read the run location. | 119 // Read the run location. |
125 int run_location = 0; | 120 int run_location = 0; |
126 CHECK(pickle.ReadInt(iter, &run_location)); | 121 CHECK(pickle.ReadInt(iter, &run_location)); |
127 CHECK(run_location >= 0 && run_location < RUN_LOCATION_LAST); | 122 CHECK(run_location >= 0 && run_location < RUN_LOCATION_LAST); |
128 run_location_ = static_cast<RunLocation>(run_location); | 123 run_location_ = static_cast<RunLocation>(run_location); |
129 | 124 |
130 // Read the extension ID. | |
131 CHECK(pickle.ReadString(iter, &extension_id_)); | 125 CHECK(pickle.ReadString(iter, &extension_id_)); |
132 | |
133 // Read Greasemonkey emulation. | |
134 CHECK(pickle.ReadBool(iter, &emulate_greasemonkey_)); | 126 CHECK(pickle.ReadBool(iter, &emulate_greasemonkey_)); |
135 | |
136 // Read match all frames | |
137 CHECK(pickle.ReadBool(iter, &match_all_frames_)); | 127 CHECK(pickle.ReadBool(iter, &match_all_frames_)); |
| 128 CHECK(pickle.ReadBool(iter, &incognito_enabled_)); |
138 | 129 |
139 // Read globs. | 130 // Read globs. |
140 size_t num_globs = 0; | 131 size_t num_globs = 0; |
141 CHECK(pickle.ReadSize(iter, &num_globs)); | 132 CHECK(pickle.ReadSize(iter, &num_globs)); |
142 globs_.clear(); | 133 globs_.clear(); |
143 for (size_t i = 0; i < num_globs; ++i) { | 134 for (size_t i = 0; i < num_globs; ++i) { |
144 std::string glob; | 135 std::string glob; |
145 CHECK(pickle.ReadString(iter, &glob)); | 136 CHECK(pickle.ReadString(iter, &glob)); |
146 globs_.push_back(glob); | 137 globs_.push_back(glob); |
147 } | 138 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Read css scripts. | 171 // Read css scripts. |
181 size_t num_css_files = 0; | 172 size_t num_css_files = 0; |
182 CHECK(pickle.ReadSize(iter, &num_css_files)); | 173 CHECK(pickle.ReadSize(iter, &num_css_files)); |
183 css_scripts_.clear(); | 174 css_scripts_.clear(); |
184 for (size_t i = 0; i < num_css_files; ++i) { | 175 for (size_t i = 0; i < num_css_files; ++i) { |
185 File file; | 176 File file; |
186 file.Unpickle(pickle, iter); | 177 file.Unpickle(pickle, iter); |
187 css_scripts_.push_back(file); | 178 css_scripts_.push_back(file); |
188 } | 179 } |
189 } | 180 } |
OLD | NEW |