Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef EXTENSIONS_BROWSER_BROWSER_USER_SCRIPT_H_ | |
| 6 #define EXTENSIONS_BROWSER_BROWSER_USER_SCRIPT_H_ | |
| 7 | |
| 8 #include "extensions/common/user_script.h" | |
| 9 | |
| 10 namespace base { | |
| 11 class Pickle; | |
| 12 } | |
| 13 | |
| 14 namespace extensions { | |
| 15 | |
| 16 // browser/ process representation of a user script file. | |
| 17 // Contains the content of the script file, so this is expensive to copy around. | |
| 18 class BrowserScriptFile : public UserScriptFileInfo { | |
| 19 public: | |
| 20 BrowserScriptFile(const UserScriptFileInfo& info); | |
| 21 BrowserScriptFile(const base::FilePath& extension_root, | |
| 22 const base::FilePath& relative_path, | |
| 23 const GURL& url); | |
| 24 ~BrowserScriptFile() override; | |
| 25 | |
| 26 void set_content(base::StringPiece content) { | |
| 27 content_.assign(content.begin(), content.end()); | |
| 28 } | |
| 29 base::StringPiece GetContent() { return content_; } | |
| 30 | |
| 31 private: | |
| 32 std::string content_; | |
| 33 | |
| 34 DISALLOW_COPY_AND_ASSIGN(BrowserScriptFile); | |
| 35 }; | |
| 36 | |
| 37 // browser/ process representation of a user script. | |
| 38 // A user script can contain multiple script files in it. The browser/ process | |
| 39 // loads these files and then the contents are shared with the renderer/ process | |
| 40 // via shared memory. | |
| 41 class BrowserUserScript : public UserScriptInfo, | |
|
Devlin
2016/08/11 17:05:54
I'd prefer we avoided having a Browser/Renderer Us
| |
| 42 public UserScriptFiles<BrowserScriptFile> { | |
| 43 public: | |
| 44 BrowserUserScript(); | |
| 45 BrowserUserScript(UserScriptInfo& meta, | |
| 46 UserScriptFiles<UserScriptFileInfo>& files); | |
| 47 ~BrowserUserScript() override; | |
| 48 | |
| 49 void Pickle(base::Pickle* pickle) const; | |
| 50 | |
| 51 private: | |
| 52 DISALLOW_COPY_AND_ASSIGN(BrowserUserScript); | |
| 53 }; | |
| 54 | |
| 55 using BrowserUserScriptList = std::vector<std::unique_ptr<BrowserUserScript>>; | |
| 56 using BrowserScriptFileList = std::vector<std::unique_ptr<BrowserScriptFile>>; | |
| 57 | |
| 58 } // namespace extensions | |
| 59 | |
| 60 #endif // EXTENSIONS_BROWSER_BROWSER_USER_SCRIPT_H_ | |
| OLD | NEW |