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

Side by Side Diff: chrome/renderer/greasemonkey_slave.h

Issue 7254: Initial Greasemonkey support (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | chrome/renderer/greasemonkey_slave.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2008 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 CHROME_RENDERER_GREASEMONKEY_SLAVE_H__
6 #define CHROME_RENDERER_GREASEMONKEY_SLAVE_H__
7
8 #include <vector>
9
10 #include "base/scoped_ptr.h"
11 #include "base/shared_memory.h"
12 #include "base/string_piece.h"
13 #include "webkit/glue/webframe.h"
14
15 // Parsed representation of a Greasemonkey script.
16 class GreasemonkeyScript {
17 public:
18 // TODO(aa): Pass in filename script came from, for errors. Needs to be in
19 // shared memory.
20 GreasemonkeyScript() {}
21
22 const StringPiece& GetBody() const {
23 return body_;
24 }
25
26 bool Parse(const StringPiece& script_text) {
27 // TODO(aa): Parse out includes, convert to regexes.
28 body_ = script_text;
29 return true;
30 }
31
32 private:
33 // References the body of the script in shared memory. The underlying memory
34 // is valid until shared_memory_ is either deleted or Unmap()'d.
35 StringPiece body_;
36 };
37
38
39 // Manages installed GreasemonkeyScripts for a render process.
40 class GreasemonkeySlave {
41 public:
42 GreasemonkeySlave();
43
44 // Update the parsed scripts from shared memory.
45 bool UpdateScripts(SharedMemoryHandle shared_memory);
46
47 // Inject the appropriate scripts into a frame based on its URL.
48 // TODO(aa): Extract a GreasemonkeyFrame interface out of this to improve
49 // testability.
50 bool InjectScripts(WebFrame* frame);
51
52 private:
53 // Shared memory containing raw script data.
54 scoped_ptr<SharedMemory> shared_memory_;
55
56 // Parsed script data.
57 std::vector<GreasemonkeyScript> scripts_;
58
59 DISALLOW_COPY_AND_ASSIGN(GreasemonkeySlave);
60 };
61
62 #endif // CHROME_RENDERER_GREASEMONKEY_SLAVE_H__
OLDNEW
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | chrome/renderer/greasemonkey_slave.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698