| Index: chrome/browser/extensions/api/page_capture/page_capture_api.cc
|
| diff --git a/chrome/browser/extensions/api/page_capture/page_capture_api.cc b/chrome/browser/extensions/api/page_capture/page_capture_api.cc
|
| index 1e7c549d533f94e0f6f1c53a883d9c5680c85049..e8b38d7b82332730ec3a431ebb7ce012196ec2e8 100644
|
| --- a/chrome/browser/extensions/api/page_capture/page_capture_api.cc
|
| +++ b/chrome/browser/extensions/api/page_capture/page_capture_api.cc
|
| @@ -8,10 +8,14 @@
|
| #include <memory>
|
|
|
| #include "base/bind.h"
|
| +#include "base/bind_helpers.h"
|
| #include "base/files/file_util.h"
|
| +#include "base/memory/ptr_util.h"
|
| #include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/extensions/api/page_capture/page_capture_permission_helper.h"
|
| #include "chrome/browser/extensions/extension_tab_util.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/profiles/profiles_state.h"
|
| #include "content/public/browser/child_process_security_policy.h"
|
| #include "content/public/browser/notification_details.h"
|
| #include "content/public/browser/notification_source.h"
|
| @@ -63,6 +67,32 @@ bool PageCaptureSaveAsMHTMLFunction::RunAsync() {
|
|
|
| AddRef(); // Balanced in ReturnFailure/ReturnSuccess()
|
|
|
| + // In Public Sessions, extensions (and apps) are force-installed by admin
|
| + // policy so the user does not get a chance to review the permissions for
|
| + // these extensions. This is not acceptable from a security/privacy
|
| + // standpoint, so when an extension uses the PageCapture API for the first
|
| + // time, we show the user a dialog where they can choose whether to allow the
|
| + // extension access to the API.
|
| +#if defined(OS_CHROMEOS)
|
| + if (profiles::IsPublicSession()) {
|
| + auto success_callback = base::Bind(
|
| + base::IgnoreResult(&BrowserThread::PostTask), BrowserThread::FILE,
|
| + FROM_HERE,
|
| + base::Bind(&PageCaptureSaveAsMHTMLFunction::CreateTemporaryFile,
|
| + base::Unretained(this)));
|
| + auto failure_callback = base::Bind(
|
| + &PageCaptureSaveAsMHTMLFunction::ReturnFailure, base::Unretained(this));
|
| + permission_helper_ = base::MakeUnique<PageCapturePermissionHelper>(
|
| + extension(),
|
| + // OffTheRecordPrefs are used here because the pref must not be
|
| + // persistent across user sessions.
|
| + GetProfile()->GetOffTheRecordPrefs(), success_callback,
|
| + failure_callback);
|
| + permission_helper_->HandlePermissionRequest(GetWebContents());
|
| + return true;
|
| + }
|
| +#endif
|
| +
|
| BrowserThread::PostTask(
|
| BrowserThread::FILE, FROM_HERE,
|
| base::Bind(&PageCaptureSaveAsMHTMLFunction::CreateTemporaryFile, this));
|
|
|