Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_API_PAGE_CAPTURE_PAGE_CAPTURE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_API_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "chrome/browser/extensions/chrome_extension_function.h" | 13 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 14 #include "chrome/common/extensions/api/page_capture.h" | 14 #include "chrome/common/extensions/api/page_capture.h" |
| 15 #include "storage/browser/blob/shareable_file_reference.h" | 15 #include "storage/browser/blob/shareable_file_reference.h" |
| 16 | 16 |
| 17 #if defined(OS_CHROMEOS) | |
| 18 #include "extensions/common/permissions/api_permission_set.h" | |
| 19 #endif | |
| 20 | |
| 17 namespace base { | 21 namespace base { |
| 18 class FilePath; | 22 class FilePath; |
| 19 } | 23 } |
| 20 | 24 |
| 21 namespace content { | 25 namespace content { |
| 22 class WebContents; | 26 class WebContents; |
| 23 } | 27 } |
| 24 | 28 |
| 25 namespace extensions { | 29 namespace extensions { |
| 26 | 30 |
| 27 class PageCaptureSaveAsMHTMLFunction : public ChromeAsyncExtensionFunction { | 31 class PageCaptureSaveAsMHTMLFunction : public ChromeAsyncExtensionFunction { |
| 28 public: | 32 public: |
| 29 PageCaptureSaveAsMHTMLFunction(); | 33 PageCaptureSaveAsMHTMLFunction(); |
| 30 | 34 |
| 31 // Test specific delegate used to test that the temporary file gets deleted. | 35 // Test specific delegate used to test that the temporary file gets deleted. |
| 32 class TestDelegate { | 36 class TestDelegate { |
| 33 public: | 37 public: |
| 34 // Called on the UI thread when the temporary file that contains the | 38 // Called on the UI thread when the temporary file that contains the |
| 35 // generated data has been created. | 39 // generated data has been created. |
| 36 virtual void OnTemporaryFileCreated(const base::FilePath& temp_file) = 0; | 40 virtual void OnTemporaryFileCreated(const base::FilePath& temp_file) = 0; |
| 37 }; | 41 }; |
| 38 static void SetTestDelegate(TestDelegate* delegate); | 42 static void SetTestDelegate(TestDelegate* delegate); |
| 39 | 43 |
| 40 private: | 44 private: |
| 41 ~PageCaptureSaveAsMHTMLFunction() override; | 45 ~PageCaptureSaveAsMHTMLFunction() override; |
| 42 bool RunAsync() override; | 46 bool RunAsync() override; |
| 43 bool OnMessageReceived(const IPC::Message& message) override; | 47 bool OnMessageReceived(const IPC::Message& message) override; |
| 44 | 48 |
| 49 #if defined(OS_CHROMEOS) | |
| 50 // Resolves the API permission request in Public Sessions. | |
| 51 void ResolvePermissionRequest(PermissionIDSet allowed_permissions); | |
|
Andrew T Wilson (Slow)
2017/02/07 14:26:51
This is fine as is - but would declaring this as c
Ivan Šandrk
2017/02/07 20:41:32
Not in the current version - two callsites both ma
Ivan Šandrk
2017/02/10 12:20:32
You are actually right, it's better as a const ref
| |
| 52 #endif | |
| 53 | |
| 45 // Called on the file thread. | 54 // Called on the file thread. |
| 46 void CreateTemporaryFile(); | 55 void CreateTemporaryFile(); |
| 47 | 56 |
| 48 // Called on the UI thread. | 57 // Called on the UI thread. |
| 49 void TemporaryFileCreated(bool success); | 58 void TemporaryFileCreated(bool success); |
| 50 void ReturnFailure(const std::string& error); | 59 void ReturnFailure(const std::string& error); |
| 51 void ReturnSuccess(int64_t file_size); | 60 void ReturnSuccess(int64_t file_size); |
| 52 | 61 |
| 53 // Callback called once the MHTML generation is done. | 62 // Callback called once the MHTML generation is done. |
| 54 void MHTMLGenerated(int64_t mhtml_file_size); | 63 void MHTMLGenerated(int64_t mhtml_file_size); |
| 55 | 64 |
| 56 // Returns the WebContents we are associated with, NULL if it's been closed. | 65 // Returns the WebContents we are associated with, NULL if it's been closed. |
| 57 content::WebContents* GetWebContents(); | 66 content::WebContents* GetWebContents(); |
| 58 | 67 |
| 59 std::unique_ptr<extensions::api::page_capture::SaveAsMHTML::Params> params_; | 68 std::unique_ptr<extensions::api::page_capture::SaveAsMHTML::Params> params_; |
| 60 | 69 |
| 61 // The path to the temporary file containing the MHTML data. | 70 // The path to the temporary file containing the MHTML data. |
| 62 base::FilePath mhtml_path_; | 71 base::FilePath mhtml_path_; |
| 63 | 72 |
| 64 // The file containing the MHTML. | 73 // The file containing the MHTML. |
| 65 scoped_refptr<storage::ShareableFileReference> mhtml_file_; | 74 scoped_refptr<storage::ShareableFileReference> mhtml_file_; |
| 66 | 75 |
| 67 DECLARE_EXTENSION_FUNCTION("pageCapture.saveAsMHTML", PAGECAPTURE_SAVEASMHTML) | 76 DECLARE_EXTENSION_FUNCTION("pageCapture.saveAsMHTML", PAGECAPTURE_SAVEASMHTML) |
| 68 }; | 77 }; |
| 69 | 78 |
| 70 } // namespace extensions | 79 } // namespace extensions |
| 71 | 80 |
| 72 #endif // CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_API_H_ | 81 #endif // CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_API_H_ |
| OLD | NEW |