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

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

Issue 8530003: Delete the temporary file when generating MHTML with the extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more sync Created 9 years, 1 month 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_EXTENSION_FUNCTION_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/process.h" 16 #include "base/process.h"
17 #include "chrome/browser/extensions/extension_info_map.h" 17 #include "chrome/browser/extensions/extension_info_map.h"
18 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
19 #include "content/browser/renderer_host/render_view_host_observer.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
22 #include "ipc/ipc_message.h" 23 #include "ipc/ipc_message.h"
23 24
24 class Browser; 25 class Browser;
25 class ChromeRenderMessageFilter; 26 class ChromeRenderMessageFilter;
26 class ExtensionFunction; 27 class ExtensionFunction;
27 class ExtensionFunctionDispatcher; 28 class ExtensionFunctionDispatcher;
28 class UIThreadExtensionFunction; 29 class UIThreadExtensionFunction;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 bool success) = 0; 216 bool success) = 0;
216 }; 217 };
217 218
218 UIThreadExtensionFunction(); 219 UIThreadExtensionFunction();
219 220
220 virtual UIThreadExtensionFunction* AsUIThreadExtensionFunction() OVERRIDE; 221 virtual UIThreadExtensionFunction* AsUIThreadExtensionFunction() OVERRIDE;
221 222
222 void set_test_delegate(DelegateForTests* delegate) { 223 void set_test_delegate(DelegateForTests* delegate) {
223 delegate_ = delegate; 224 delegate_ = delegate;
224 } 225 }
226
227 // Called when a message was received.
228 // Should return true if it processed the message.
229 virtual bool OnMessageReceivedFromRenderView(const IPC::Message& message);
230
225 // Set the profile which contains the extension that has originated this 231 // Set the profile which contains the extension that has originated this
226 // function call. 232 // function call.
227 void set_profile(Profile* profile) { profile_ = profile; } 233 void set_profile(Profile* profile) { profile_ = profile; }
228 Profile* profile() const { return profile_; } 234 Profile* profile() const { return profile_; }
229 235
230 void SetRenderViewHost(RenderViewHost* render_view_host); 236 void SetRenderViewHost(RenderViewHost* render_view_host);
231 RenderViewHost* render_view_host() const { return render_view_host_; } 237 RenderViewHost* render_view_host() const { return render_view_host_; }
232 238
233 void set_dispatcher( 239 void set_dispatcher(
234 const base::WeakPtr<ExtensionFunctionDispatcher>& dispatcher) { 240 const base::WeakPtr<ExtensionFunctionDispatcher>& dispatcher) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 base::WeakPtr<ExtensionFunctionDispatcher> dispatcher_; 275 base::WeakPtr<ExtensionFunctionDispatcher> dispatcher_;
270 276
271 // The RenderViewHost we will send responses too. 277 // The RenderViewHost we will send responses too.
272 RenderViewHost* render_view_host_; 278 RenderViewHost* render_view_host_;
273 279
274 // The Profile of this function's extension. 280 // The Profile of this function's extension.
275 Profile* profile_; 281 Profile* profile_;
276 282
277 private: 283 private:
278 // Helper class to track the lifetime of ExtensionFunction's RenderViewHost 284 // Helper class to track the lifetime of ExtensionFunction's RenderViewHost
279 // pointer and NULL it out when it dies. We use this separate class (instead 285 // pointer and NULL it out when it dies. It also allows us to filter IPC
280 // of implementing NotificationObserver on ExtensionFunction) because it is 286 // messages comming from the RenderViewHost. We use this separate class
281 // common for subclasses of ExtensionFunction to be NotificationObservers, and 287 // (instead of implementing NotificationObserver on ExtensionFunction) because
282 // it would be an easy error to forget to call the base class's Observe() 288 // it is/ common for subclasses of ExtensionFunction to be
283 // method. 289 // NotificationObservers, and it would be an easy error to forget to call the
284 class RenderViewHostTracker : public content::NotificationObserver { 290 // base class's Observe() method.
291 class RenderViewHostTracker : public content::NotificationObserver,
292 public RenderViewHostObserver {
285 public: 293 public:
286 explicit RenderViewHostTracker(UIThreadExtensionFunction* function); 294 RenderViewHostTracker(UIThreadExtensionFunction* function,
295 RenderViewHost* render_view_host);
287 private: 296 private:
288 virtual void Observe(int type, 297 virtual void Observe(int type,
289 const content::NotificationSource& source, 298 const content::NotificationSource& source,
290 const content::NotificationDetails& details) OVERRIDE; 299 const content::NotificationDetails& details) OVERRIDE;
300
301 virtual void RenderViewHostDestroyed(
302 RenderViewHost* render_view_host) OVERRIDE;
303 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
304
291 UIThreadExtensionFunction* function_; 305 UIThreadExtensionFunction* function_;
292 content::NotificationRegistrar registrar_; 306 content::NotificationRegistrar registrar_;
307
308 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTracker);
293 }; 309 };
294 310
295 virtual void Destruct() const OVERRIDE; 311 virtual void Destruct() const OVERRIDE;
296 312
297 scoped_ptr<RenderViewHostTracker> tracker_; 313 scoped_ptr<RenderViewHostTracker> tracker_;
298 314
299 DelegateForTests* delegate_; 315 DelegateForTests* delegate_;
300 }; 316 };
301 317
302 // Extension functions that run on the IO thread. This type of function avoids 318 // Extension functions that run on the IO thread. This type of function avoids
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 public: 395 public:
380 SyncIOThreadExtensionFunction(); 396 SyncIOThreadExtensionFunction();
381 397
382 virtual void Run() OVERRIDE; 398 virtual void Run() OVERRIDE;
383 399
384 protected: 400 protected:
385 virtual ~SyncIOThreadExtensionFunction(); 401 virtual ~SyncIOThreadExtensionFunction();
386 }; 402 };
387 403
388 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ 404 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698