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

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: Updated. 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"
16 #include "chrome/common/extensions/extension_messages.h"
17 #include "chrome/common/extensions/extension_set.h"
13 #include "chrome/common/extensions/user_script.h" 18 #include "chrome/common/extensions/user_script.h"
14 #include "content/browser/browser_thread.h" 19 #include "content/browser/browser_thread.h"
15 #include "content/common/notification_observer.h" 20 #include "content/common/notification_observer.h"
16 #include "content/common/notification_registrar.h" 21 #include "content/common/notification_registrar.h"
17 22
18 namespace base { 23 namespace base {
19 class StringPiece; 24 class StringPiece;
20 } 25 }
21 26
22 class Profile; 27 class Profile;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // Start loading of scripts. 73 // Start loading of scripts.
69 // Will always send a message to the master upon completion. 74 // Will always send a message to the master upon completion.
70 void StartLoad(const UserScriptList& external_scripts); 75 void StartLoad(const UserScriptList& external_scripts);
71 76
72 // The master is going away; don't call it back. 77 // The master is going away; don't call it back.
73 void DisownMaster() { 78 void DisownMaster() {
74 master_ = NULL; 79 master_ = NULL;
75 } 80 }
76 81
77 private: 82 private:
78 private:
79 FRIEND_TEST_ALL_PREFIXES(UserScriptMasterTest, SkipBOMAtTheBeginning); 83 FRIEND_TEST_ALL_PREFIXES(UserScriptMasterTest, SkipBOMAtTheBeginning);
80 FRIEND_TEST_ALL_PREFIXES(UserScriptMasterTest, LeaveBOMNotAtTheBeginning); 84 FRIEND_TEST_ALL_PREFIXES(UserScriptMasterTest, LeaveBOMNotAtTheBeginning);
81 friend class base::RefCountedThreadSafe<UserScriptMaster::ScriptReloader>; 85 friend class base::RefCountedThreadSafe<UserScriptMaster::ScriptReloader>;
82 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);
106
107 // Uses extensions_info_ to build a map of localization messages.
108 // Returns NULL if |extension_id| is invalid.
109 SubstitutionMap* GetLocalizationMessages(std::string extension_id);
102 110
103 // A pointer back to our master. 111 // A pointer back to our master.
104 // May be NULL if DisownMaster() is called. 112 // May be NULL if DisownMaster() is called.
105 UserScriptMaster* master_; 113 UserScriptMaster* master_;
106 114
115 // Maps extension info needed for localization to an extension ID.
116 std::map<std::string, ExtensionSet::ExtensionPathAndDefaultLocale>
117 extensions_info_;
118
107 // The message loop to call our master back on. 119 // The message loop to call our master back on.
108 // Expected to always outlive us. 120 // Expected to always outlive us.
109 BrowserThread::ID master_thread_id_; 121 BrowserThread::ID master_thread_id_;
110 122
111 DISALLOW_COPY_AND_ASSIGN(ScriptReloader); 123 DISALLOW_COPY_AND_ASSIGN(ScriptReloader);
112 }; 124 };
113 125
114 private: 126 private:
115 // NotificationObserver implementation. 127 // NotificationObserver implementation.
116 virtual void Observe(int type, 128 virtual void Observe(int type,
(...skipping 25 matching lines...) Expand all
142 // finishes. This boolean tracks whether another load is pending. 154 // finishes. This boolean tracks whether another load is pending.
143 bool pending_load_; 155 bool pending_load_;
144 156
145 // The profile for which the scripts managed here are installed. 157 // The profile for which the scripts managed here are installed.
146 Profile* profile_; 158 Profile* profile_;
147 159
148 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); 160 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster);
149 }; 161 };
150 162
151 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ 163 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698