| OLD | NEW |
| 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_SAVE_PAGE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SAVE_PAGE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SAVE_PAGE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SAVE_PAGE_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" |
| 10 #include "chrome/browser/extensions/extension_function.h" | 11 #include "chrome/browser/extensions/extension_function.h" |
| 11 #include "content/browser/tab_contents/tab_contents_observer.h" | 12 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 12 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "webkit/blob/deletable_file_reference.h" |
| 14 | 16 |
| 15 class SavePageAsMHTMLFunction : public AsyncExtensionFunction, | 17 class SavePageAsMHTMLFunction : public AsyncExtensionFunction, |
| 16 public content::NotificationObserver { | 18 public content::NotificationObserver { |
| 17 public: | 19 public: |
| 18 SavePageAsMHTMLFunction(); | 20 SavePageAsMHTMLFunction(); |
| 19 | 21 |
| 20 private: | 22 private: |
| 21 virtual ~SavePageAsMHTMLFunction(); | 23 virtual ~SavePageAsMHTMLFunction(); |
| 22 | 24 |
| 23 virtual bool RunImpl() OVERRIDE; | 25 virtual bool RunImpl() OVERRIDE; |
| 24 virtual void Observe(int type, | 26 virtual void Observe(int type, |
| 25 const content::NotificationSource& source, | 27 const content::NotificationSource& source, |
| 26 const content::NotificationDetails& details) OVERRIDE; | 28 const content::NotificationDetails& details) OVERRIDE; |
| 29 virtual bool OnMessageReceivedFromRenderView( |
| 30 const IPC::Message& message) OVERRIDE; |
| 27 | 31 |
| 28 // Called on the file thread. | 32 // Called on the file thread. |
| 29 void CreateTemporaryFile(); | 33 void CreateTemporaryFile(); |
| 30 | 34 |
| 31 // Called on the UI thread. | 35 // Called on the UI thread. |
| 32 void TemporaryFileCreated(bool success); | 36 void TemporaryFileCreated(bool success); |
| 33 void ReturnFailure(const std::string& error); | 37 void ReturnFailure(const std::string& error); |
| 34 void ReturnSuccess(int64 file_size); | 38 void ReturnSuccess(int64 file_size); |
| 35 | 39 |
| 40 // Returns the TabContents we are associated with, NULL if it's been closed. |
| 41 TabContents* GetTabContents(); |
| 42 |
| 36 int tab_id_; | 43 int tab_id_; |
| 37 | 44 |
| 38 // The path to the temporary file containing the MHTML data. | 45 // The path to the temporary file containing the MHTML data. |
| 39 FilePath mhtml_path_; | 46 FilePath mhtml_path_; |
| 40 | 47 |
| 48 // The file containing the MHTML. |
| 49 scoped_refptr<webkit_blob::DeletableFileReference> mhtml_file_; |
| 50 |
| 41 content::NotificationRegistrar registrar_; | 51 content::NotificationRegistrar registrar_; |
| 52 |
| 42 DECLARE_EXTENSION_FUNCTION_NAME("experimental.savePage.saveAsMHTML") | 53 DECLARE_EXTENSION_FUNCTION_NAME("experimental.savePage.saveAsMHTML") |
| 43 }; | 54 }; |
| 44 | 55 |
| 45 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SAVE_PAGE_API_H_ | 56 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SAVE_PAGE_API_H_ |
| OLD | NEW |