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

Side by Side Diff: chrome/browser/extensions/api/page_capture/page_capture_api.h

Issue 2552203007: Public Sessions - prompt the user for pageCapture requests (Closed)
Patch Set: Unused variable Created 4 years 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
OLDNEW
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
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 HandlePermission();
65
66 #if defined(OS_CHROMEOS)
Devlin 2016/12/12 20:09:37 This is a fair amount of cros-only code. I think
Ivan Šandrk 2016/12/13 16:32:47 That's a good point. Are you fine with me doing a
Devlin 2016/12/13 21:51:29 Is there a reason not to do it here? I don't feel
Ivan Šandrk 2017/01/04 17:09:59 Done.
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 // Function used to resolve user decision regarding allowing page capture.
Devlin 2016/12/12 20:09:37 nit: typically, we don't need "Function used to"-t
Ivan Šandrk 2016/12/13 16:32:47 True, done.
78 void ResolvePermissionPrompt(ExtensionInstallPrompt::Result prompt_result);
79
80 // Helper function that continues with the page capture (if user allowed it),
81 // or returns failure (user denied permission).
82 void ChainRunAsync();
Devlin 2016/12/12 20:09:37 I'm not sure the "ChainRunAsync" name makes sense
Ivan Šandrk 2016/12/13 16:32:47 Does ResolvePermissionRequest sound better?
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698