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

Side by Side Diff: chrome/browser/extensions/user_script_master.h

Issue 7552028: Injected CSS localization fix (see bug no.) (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Inserted whitespace. Created 9 years, 4 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 #ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map>
10 #include <string>
11
9 #include "base/file_path.h" 12 #include "base/file_path.h"
10 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
12 #include "base/shared_memory.h" 15 #include "base/shared_memory.h"
13 #include "chrome/common/extensions/user_script.h" 16 #include "chrome/common/extensions/user_script.h"
14 #include "content/browser/browser_thread.h" 17 #include "content/browser/browser_thread.h"
15 #include "content/common/notification_observer.h" 18 #include "content/common/notification_observer.h"
16 #include "content/common/notification_registrar.h" 19 #include "content/common/notification_registrar.h"
17 20
18 namespace base { 21 namespace base {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // Start loading of scripts. 71 // Start loading of scripts.
69 // Will always send a message to the master upon completion. 72 // Will always send a message to the master upon completion.
70 void StartLoad(const UserScriptList& external_scripts); 73 void StartLoad(const UserScriptList& external_scripts);
71 74
72 // The master is going away; don't call it back. 75 // The master is going away; don't call it back.
73 void DisownMaster() { 76 void DisownMaster() {
74 master_ = NULL; 77 master_ = NULL;
75 } 78 }
76 79
77 private: 80 private:
78 private:
79 FRIEND_TEST_ALL_PREFIXES(UserScriptMasterTest, SkipBOMAtTheBeginning); 81 FRIEND_TEST_ALL_PREFIXES(UserScriptMasterTest, SkipBOMAtTheBeginning);
80 FRIEND_TEST_ALL_PREFIXES(UserScriptMasterTest, LeaveBOMNotAtTheBeginning); 82 FRIEND_TEST_ALL_PREFIXES(UserScriptMasterTest, LeaveBOMNotAtTheBeginning);
81 friend class base::RefCountedThreadSafe<UserScriptMaster::ScriptReloader>; 83 friend class base::RefCountedThreadSafe<UserScriptMaster::ScriptReloader>;
82 84
85 typedef std::pair<FilePath, std::string> ExtensionPathAndDefaultLocale;
Nebojša Ćirić 2011/08/10 20:38:57 This could go into ExtensionSet class, as a public
adriansc 2011/08/10 23:20:53 Done.
86
83 ~ScriptReloader() {} 87 ~ScriptReloader() {}
84 88
85 // Where functions are run: 89 // Where functions are run:
86 // master file 90 // master file
87 // StartLoad -> RunLoad 91 // StartLoad -> RunLoad
88 // LoadUserScripts() 92 // LoadUserScripts()
89 // NotifyMaster <- RunLoad 93 // NotifyMaster <- RunLoad
90 94
91 // Runs on the master thread. 95 // Runs on the master thread.
92 // Notify the master that new scripts are available. 96 // Notify the master that new scripts are available.
93 void NotifyMaster(base::SharedMemory* memory); 97 void NotifyMaster(base::SharedMemory* memory);
94 98
95 // Runs on the File thread. 99 // Runs on the File thread.
96 // Load the specified user scripts, calling NotifyMaster when done. 100 // Load the specified user scripts, calling NotifyMaster when done.
97 // |user_scripts| is intentionally passed by value so its lifetime isn't 101 // |user_scripts| is intentionally passed by value so its lifetime isn't
98 // tied to the caller. 102 // tied to the caller.
99 void RunLoad(const UserScriptList& user_scripts); 103 void RunLoad(const UserScriptList& user_scripts);
100 104
101 static void LoadUserScripts(UserScriptList* user_scripts); 105 void LoadUserScripts(UserScriptList* user_scripts);
102 106
103 // A pointer back to our master. 107 // A pointer back to our master.
104 // May be NULL if DisownMaster() is called. 108 // May be NULL if DisownMaster() is called.
105 UserScriptMaster* master_; 109 UserScriptMaster* master_;
106 110
111 // Maps extension info needed for localization to an extension ID.
112 std::map<std::string, ExtensionPathAndDefaultLocale> extensions_info_;
113
107 // The message loop to call our master back on. 114 // The message loop to call our master back on.
108 // Expected to always outlive us. 115 // Expected to always outlive us.
109 BrowserThread::ID master_thread_id_; 116 BrowserThread::ID master_thread_id_;
110 117
111 DISALLOW_COPY_AND_ASSIGN(ScriptReloader); 118 DISALLOW_COPY_AND_ASSIGN(ScriptReloader);
112 }; 119 };
113 120
114 private: 121 private:
115 // NotificationObserver implementation. 122 // NotificationObserver implementation.
116 virtual void Observe(int type, 123 virtual void Observe(int type,
(...skipping 25 matching lines...) Expand all
142 // finishes. This boolean tracks whether another load is pending. 149 // finishes. This boolean tracks whether another load is pending.
143 bool pending_load_; 150 bool pending_load_;
144 151
145 // The profile for which the scripts managed here are installed. 152 // The profile for which the scripts managed here are installed.
146 Profile* profile_; 153 Profile* profile_;
147 154
148 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); 155 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster);
149 }; 156 };
150 157
151 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ 158 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698