| 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 <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "chrome/browser/extensions/chrome_extension_function.h" | 14 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 15 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 14 #include "chrome/common/extensions/api/page_capture.h" | 16 #include "chrome/common/extensions/api/page_capture.h" |
| 17 #include "components/prefs/pref_change_registrar.h" |
| 18 #include "components/prefs/pref_service.h" |
| 15 #include "storage/browser/blob/shareable_file_reference.h" | 19 #include "storage/browser/blob/shareable_file_reference.h" |
| 16 | 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 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 49 void TemporaryFileCreated(bool success); | 53 void TemporaryFileCreated(bool success); |
| 50 void ReturnFailure(const std::string& error); | 54 void ReturnFailure(const std::string& error); |
| 51 void ReturnSuccess(int64_t file_size); | 55 void ReturnSuccess(int64_t file_size); |
| 52 | 56 |
| 53 // Callback called once the MHTML generation is done. | 57 // Callback called once the MHTML generation is done. |
| 54 void MHTMLGenerated(int64_t mhtml_file_size); | 58 void MHTMLGenerated(int64_t mhtml_file_size); |
| 55 | 59 |
| 56 // Returns the WebContents we are associated with, NULL if it's been closed. | 60 // Returns the WebContents we are associated with, NULL if it's been closed. |
| 57 content::WebContents* GetWebContents(); | 61 content::WebContents* GetWebContents(); |
| 58 | 62 |
| 63 // Handles permission checking inside of Public Sessions. |
| 64 void HandlePermissionRequest(); |
| 65 |
| 66 #if defined(OS_CHROMEOS) |
| 67 enum PermissionState { |
| 68 NOT_PROMPTED = 0, |
| 69 SHOWN_PROMPT, |
| 70 ALLOWED, |
| 71 DENIED |
| 72 }; |
| 73 |
| 74 // Sets up the dialog asking the user for permission. |
| 75 void ShowPermissionPrompt(); |
| 76 |
| 77 // Handles the user decision of whether to allow page capture. |
| 78 void ResolvePermissionPrompt(ExtensionInstallPrompt::Result prompt_result); |
| 79 |
| 80 // Continues with the page capture (if user allowed it), or returns failure |
| 81 // (user denied permission). |
| 82 void ResolvePermissionRequest(); |
| 83 |
| 84 PrefService* GetPrefs(); |
| 85 |
| 86 void UserChoiceSet(PermissionState value); |
| 87 PermissionState UserChoiceGet(); |
| 88 #endif // defined(OS_CHROMEOS) |
| 89 |
| 59 std::unique_ptr<extensions::api::page_capture::SaveAsMHTML::Params> params_; | 90 std::unique_ptr<extensions::api::page_capture::SaveAsMHTML::Params> params_; |
| 60 | 91 |
| 61 // The path to the temporary file containing the MHTML data. | 92 // The path to the temporary file containing the MHTML data. |
| 62 base::FilePath mhtml_path_; | 93 base::FilePath mhtml_path_; |
| 63 | 94 |
| 64 // The file containing the MHTML. | 95 // The file containing the MHTML. |
| 65 scoped_refptr<storage::ShareableFileReference> mhtml_file_; | 96 scoped_refptr<storage::ShareableFileReference> mhtml_file_; |
| 66 | 97 |
| 98 #if defined(OS_CHROMEOS) |
| 99 std::unique_ptr<ExtensionInstallPrompt> prompt_; |
| 100 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; |
| 101 #endif // defined(OS_CHROMEOS) |
| 102 |
| 67 DECLARE_EXTENSION_FUNCTION("pageCapture.saveAsMHTML", PAGECAPTURE_SAVEASMHTML) | 103 DECLARE_EXTENSION_FUNCTION("pageCapture.saveAsMHTML", PAGECAPTURE_SAVEASMHTML) |
| 68 }; | 104 }; |
| 69 | 105 |
| 70 } // namespace extensions | 106 } // namespace extensions |
| 71 | 107 |
| 72 #endif // CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_API_H_ | 108 #endif // CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_API_H_ |
| OLD | NEW |