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

Side by Side Diff: chrome/browser/extensions/convert_user_script.cc

Issue 7347011: Update URLPatternSet to contain a std::set instead of std::vector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows compile errors. Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/extensions/convert_user_script.h" 5 #include "chrome/browser/extensions/convert_user_script.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 root->SetString(keys::kDescription, script.description()); 95 root->SetString(keys::kDescription, script.description());
96 root->SetString(keys::kPublicKey, key); 96 root->SetString(keys::kPublicKey, key);
97 root->SetBoolean(keys::kConvertedFromUserScript, true); 97 root->SetBoolean(keys::kConvertedFromUserScript, true);
98 98
99 ListValue* js_files = new ListValue(); 99 ListValue* js_files = new ListValue();
100 js_files->Append(Value::CreateStringValue("script.js")); 100 js_files->Append(Value::CreateStringValue("script.js"));
101 101
102 // If the script provides its own match patterns, we use those. Otherwise, we 102 // If the script provides its own match patterns, we use those. Otherwise, we
103 // generate some using the include globs. 103 // generate some using the include globs.
104 ListValue* matches = new ListValue(); 104 ListValue* matches = new ListValue();
105 if (!script.url_patterns().empty()) { 105 if (!script.url_patterns().is_empty()) {
106 for (size_t i = 0; i < script.url_patterns().size(); ++i) { 106 for (URLPatternSet::const_iterator i = script.url_patterns().begin();
107 matches->Append(Value::CreateStringValue( 107 i != script.url_patterns().end(); ++i) {
108 script.url_patterns()[i].GetAsString())); 108 matches->Append(Value::CreateStringValue(i->GetAsString()));
109 } 109 }
110 } else { 110 } else {
111 // TODO(aa): Derive tighter matches where possible. 111 // TODO(aa): Derive tighter matches where possible.
112 matches->Append(Value::CreateStringValue("http://*/*")); 112 matches->Append(Value::CreateStringValue("http://*/*"));
113 matches->Append(Value::CreateStringValue("https://*/*")); 113 matches->Append(Value::CreateStringValue("https://*/*"));
114 } 114 }
115 115
116 ListValue* includes = new ListValue(); 116 ListValue* includes = new ListValue();
117 for (size_t i = 0; i < script.globs().size(); ++i) 117 for (size_t i = 0; i < script.globs().size(); ++i)
118 includes->Append(Value::CreateStringValue(script.globs().at(i))); 118 includes->Append(Value::CreateStringValue(script.globs().at(i)));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 Extension::NO_FLAGS, 162 Extension::NO_FLAGS,
163 error); 163 error);
164 if (!extension) { 164 if (!extension) {
165 NOTREACHED() << "Could not init extension " << *error; 165 NOTREACHED() << "Could not init extension " << *error;
166 return NULL; 166 return NULL;
167 } 167 }
168 168
169 temp_dir.Take(); // The caller takes ownership of the directory. 169 temp_dir.Take(); // The caller takes ownership of the directory.
170 return extension; 170 return extension;
171 } 171 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/browser/extensions/convert_user_script_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698