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

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

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 #include "chrome/browser/extensions/extension_function.h" 5 #include "chrome/browser/extensions/extension_function.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/extensions/extension_function_dispatcher.h" 9 #include "chrome/browser/extensions/extension_function_dispatcher.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" 12 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
13 #include "chrome/common/extensions/extension_messages.h" 13 #include "chrome/common/extensions/extension_messages.h"
14 #include "content/browser/renderer_host/render_view_host.h" 14 #include "content/browser/renderer_host/render_view_host.h"
15 #include "content/browser/user_metrics.h" 15 #include "content/browser/user_metrics.h"
16 #include "content/public/browser/notification_source.h" 16 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/notification_types.h" 17 #include "content/public/browser/notification_types.h"
18 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
19 #include "content/public/common/result_codes.h" 19 #include "content/public/common/result_codes.h"
20 20
21 using content::BrowserThread; 21 using content::BrowserThread;
22 22
23 // static 23 // static
24 void ExtensionFunctionDeleteTraits::Destruct(const ExtensionFunction* x) { 24 void ExtensionFunctionDeleteTraits::Destruct(const ExtensionFunction* x) {
25 x->Destruct(); 25 x->Destruct();
26 } 26 }
27 27
28 UIThreadExtensionFunction::RenderViewHostTracker::RenderViewHostTracker( 28 UIThreadExtensionFunction::RenderViewHostTracker::RenderViewHostTracker(
29 UIThreadExtensionFunction* function) 29 UIThreadExtensionFunction* function,
30 : function_(function) { 30 RenderViewHost* render_view_host)
31 : RenderViewHostObserver(render_view_host),
32 function_(function) {
31 registrar_.Add(this, 33 registrar_.Add(this,
32 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, 34 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED,
33 content::Source<RenderViewHost>(function->render_view_host())); 35 content::Source<RenderViewHost>(function->render_view_host()));
34 } 36 }
35 37
36 void UIThreadExtensionFunction::RenderViewHostTracker::Observe( 38 void UIThreadExtensionFunction::RenderViewHostTracker::Observe(
37 int type, 39 int type,
38 const content::NotificationSource& source, 40 const content::NotificationSource& source,
39 const content::NotificationDetails& details) { 41 const content::NotificationDetails& details) {
40 CHECK(type == content::NOTIFICATION_RENDER_VIEW_HOST_DELETED); 42 CHECK(type == content::NOTIFICATION_RENDER_VIEW_HOST_DELETED);
41 CHECK(content::Source<RenderViewHost>(source).ptr() == 43 CHECK(content::Source<RenderViewHost>(source).ptr() ==
42 function_->render_view_host()); 44 function_->render_view_host());
43 function_->SetRenderViewHost(NULL); 45 function_->SetRenderViewHost(NULL);
44 } 46 }
45 47
48 void UIThreadExtensionFunction::RenderViewHostTracker::RenderViewHostDestroyed(
49 RenderViewHost* render_view_host) {
50 // Overidding the default behavior of RenderViewHostObserver which is to
51 // delete this. In our case, we'll be deleted when the
52 // UIThreadExtensionFunction that contains us goes away.
53 }
54
55 bool UIThreadExtensionFunction::RenderViewHostTracker::OnMessageReceived(
56 const IPC::Message& message) {
57 return function_->OnMessageReceivedFromRenderView(message);
58 }
59
46 ExtensionFunction::ExtensionFunction() 60 ExtensionFunction::ExtensionFunction()
47 : request_id_(-1), 61 : request_id_(-1),
48 profile_id_(NULL), 62 profile_id_(NULL),
49 has_callback_(false), 63 has_callback_(false),
50 include_incognito_(false), 64 include_incognito_(false),
51 user_gesture_(false), 65 user_gesture_(false),
52 args_(NULL), 66 args_(NULL),
53 bad_message_(false) { 67 bad_message_(false) {
54 } 68 }
55 69
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 146 }
133 147
134 UIThreadExtensionFunction::~UIThreadExtensionFunction() { 148 UIThreadExtensionFunction::~UIThreadExtensionFunction() {
135 } 149 }
136 150
137 UIThreadExtensionFunction* 151 UIThreadExtensionFunction*
138 UIThreadExtensionFunction::AsUIThreadExtensionFunction() { 152 UIThreadExtensionFunction::AsUIThreadExtensionFunction() {
139 return this; 153 return this;
140 } 154 }
141 155
156 bool UIThreadExtensionFunction::OnMessageReceivedFromRenderView(
157 const IPC::Message& message) {
158 return false;
159 }
160
142 void UIThreadExtensionFunction::Destruct() const { 161 void UIThreadExtensionFunction::Destruct() const {
143 BrowserThread::DeleteOnUIThread::Destruct(this); 162 BrowserThread::DeleteOnUIThread::Destruct(this);
144 } 163 }
145 164
146 void UIThreadExtensionFunction::SetRenderViewHost( 165 void UIThreadExtensionFunction::SetRenderViewHost(
147 RenderViewHost* render_view_host) { 166 RenderViewHost* render_view_host) {
148 render_view_host_ = render_view_host; 167 render_view_host_ = render_view_host;
149 tracker_.reset(render_view_host ? new RenderViewHostTracker(this) : NULL); 168 tracker_.reset(render_view_host ?
169 new RenderViewHostTracker(this, render_view_host) : NULL);
150 } 170 }
151 171
152 Browser* UIThreadExtensionFunction::GetCurrentBrowser() { 172 Browser* UIThreadExtensionFunction::GetCurrentBrowser() {
153 return dispatcher()->GetCurrentBrowser(render_view_host_, include_incognito_); 173 return dispatcher()->GetCurrentBrowser(render_view_host_, include_incognito_);
154 } 174 }
155 175
156 void UIThreadExtensionFunction::SendResponse(bool success) { 176 void UIThreadExtensionFunction::SendResponse(bool success) {
157 if (delegate_) { 177 if (delegate_) {
158 delegate_->OnSendResponse(this, success); 178 delegate_->OnSendResponse(this, success);
159 } else { 179 } else {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 229
210 SyncIOThreadExtensionFunction::SyncIOThreadExtensionFunction() { 230 SyncIOThreadExtensionFunction::SyncIOThreadExtensionFunction() {
211 } 231 }
212 232
213 SyncIOThreadExtensionFunction::~SyncIOThreadExtensionFunction() { 233 SyncIOThreadExtensionFunction::~SyncIOThreadExtensionFunction() {
214 } 234 }
215 235
216 void SyncIOThreadExtensionFunction::Run() { 236 void SyncIOThreadExtensionFunction::Run() {
217 SendResponse(RunImpl()); 237 SendResponse(RunImpl());
218 } 238 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698