0
Commit Graph

22 Commits

Author SHA1 Message Date
Alison Gale
770f3fce37 Migrate TODOs referencing old crbug IDs to the new issue tracker IDs
The canonical bug format is TODO(crbug.com/<id>). TODOs of the
following forms will all be migrated to the new format:

- TODO(crbug.com/<old id>)
- TODO(https://crbug.com/<old id>)
- TODO(crbug/<old id>)
- TODO(crbug/monorail/<old id>)
- TODO(<old id>)
- TODO(issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/u/1/issues/<old id>)
- TODO(bugs.chromium.org/<old id>)

Bug id mapping is sourced from go/chrome-on-buganizer-prod-issues.
See go/crbug-todo-migration for details.

#crbug-todo-migration

Bug: b/321899722
Change-Id: Ibc66b8c440e4bcdef414e77fef4d9874d2ea9951
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5493800
Auto-Submit: Alison Gale <agale@chromium.org>
Commit-Queue: Alison Gale <agale@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Owners-Override: Alison Gale <agale@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1293330}
2024-04-27 00:39:58 +00:00
Alison Gale
47d1537de7 Migrate TODOs referencing old crbug IDs to the new issue tracker IDs
The canonical bug format is TODO(crbug.com/<id>). TODOs of the
following forms will all be migrated to the new format:

- TODO(crbug.com/<old id>)
- TODO(https://crbug.com/<old id>)
- TODO(crbug/<old id>)
- TODO(crbug/monorail/<old id>)
- TODO(<old id>)
- TODO(issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/u/1/issues/<old id>)
- TODO(bugs.chromium.org/<old id>)

Bug id mapping is sourced from go/chrome-on-buganizer-prod-issues.
See go/crbug-todo-migration for details.

#crbug-todo-migration

Bug: b/321899722
Change-Id: Ieeb461e2d489e86fd50b87a2a0721a2be34520c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5467317
Owners-Override: Alison Gale <agale@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Commit-Queue: Alison Gale <agale@chromium.org>
Reviewed-by: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1290198}
2024-04-19 21:31:46 +00:00
Md Hasibul Hasan
a963a934b5 Convert base::StringPiece to std::string_view in content/browser
The changes of this CL are made using the following script.

```
target_directory="content/browser"
replace_string_in_files() {
  old_string="$1"
  new_string="$2"

  find "$target_directory" -type f \( -name "*.cc" -o -name "*.h" \) \
      -exec sed -i '' "s/$old_string/$new_string/g" {} +
}

delete_include() {
    find "$target_directory" \( -name "*.h" -o -name "*.cc" \) -print0 | while IFS= read -r -d '' file; do
        grep -v '#include "base/strings/string_piece.h"' "$file" > "$file.tmp" && mv "$file.tmp" "$file"
    done
}

add_include() {
    find "$target_directory" \( -name "*.h" -o -name "*.cc" \) -print0 | while IFS= read -r -d '' file; do
        local include_added=false
        local tempfile=$(mktemp)

        if grep -qE 'std::(string|u16string)_view' "$file"; then
            while IFS= read -r line; do
                echo "$line" >> "$tempfile"
                if [[ $line =~ ^\s*#include ]]; then
                    if ! $include_added; then
                        echo "#include <string_view>" >> "$tempfile"
                        include_added=true
                    fi
                fi
            done < "$file"

            mv "$tempfile" "$file"

            if $include_added; then
                echo "Added #include <string_view> after the first include line in $file"
            else
                echo "No include line found in $file"
            fi
        else
            echo "std::string_view not found in $file"
        fi
    done
}

replace_string_in_files "base::StringPiece16" "std::u16string_view"
replace_string_in_files "base::StringPiece" "std::string_view"
delete_include
add_include
```

Replaced base::StringPiece16 with std::u16string_view
Replaced base::StringPiece with std::string_view
Removed header "base/strings/string_piece.h"
Added header "<string_view>" where applicable

Bug: 40506050
Change-Id: I2bc22c79dd9a0c839745afe065123f7a53c4a5ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5401117
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1281746}
2024-04-03 10:15:14 +00:00
Takashi Toyoshima
a35e5fc64f LinkPreview: Implement the capability control
This patch implements the capability control for the preview mode.
We prepare a variant policy set for the preview mode so that we can
adjust the rule for a visible page.

Also, we pass a different cancel closure as we don't need to cancel
a prerendering, but just need to navigate to an error page that shows
an explanation why the page cannot be shown in the preview mode.

The error page handling, and disabling the control on tab promotions
are not implemented yet in this CL.

Bug: b/299240273
Change-Id: I705de780a83fe975b85c0ab567565342b7467da2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4941187
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: Ken Okada <kenoss@chromium.org>
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Lingqi Chi <lingqi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1212566}
2023-10-20 04:00:34 +00:00
Lingqi Chi
0611a4c1cb Prerender: Grant interfaces that can make sync IPCs during
activation

Prerender has to preform two-stage Mojo capability control to ensure
the status on the browser process and renderer processes are on sync.
For the second stage, prerender allows interfaces that can make sync
IPCs whose policies should be kCancel/kGrant to make IPCs.
However, some interfaces are treated in a different way: We defer the
binding requests on the renderer side, and resume them upon renderer
activation, so we can mark them kDefer. For these interfaces, they
should be treated as kGrant interfaces during the second stage.

So this CL fixes this issue which causes renderer hangs.

It is unfortunate that we have to add some hardcode rules for these
interfaces. This CL Left some TODOs that requires
I533dd0f0438d493ad8a7a74479526827bf93e1d9 to land first.

Bug: 1385623
Change-Id: I180c6f8b0cc37c4157346cc5a556cc07f8c2b1f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4082358
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1083506}
2022-12-15 01:59:17 +00:00
Ali Hijazi
d87307de3e Rewrite T& into raw_ref<T> under content/
The changes were generated by running
tools/clang/rewrite_raw_ref_fields/rewrite-multiple-platforms.sh with
tool-arg=--enable_raw_ref_rewrite

`raw_ref` is a smart pointer for a pointer which can not be null, and
which provides Use-after-Free protection in the same ways as raw_ptr.
This class acts like a combination of std::reference_wrapper and
raw_ptr.

See raw_ptr and //base/memory/raw_ptr.md for more details on the
Use-after-Free protection.

Bug: 1357022
Change-Id: I14c1f8d4d890715fb9b9f0526ace78ecc625c08a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3999748
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Ali Hijazi <ahijazi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1068278}
2022-11-07 20:15:03 +00:00
Avi Drissman
4e1b7bc33d Update copyright headers in content/
The methodology used to generate this CL is documented in
https://crbug.com/1098010#c34.

No-Try: true
No-Presubmit: true
Bug: 1098010
Change-Id: I8c0f009d16350271f07d8e5e561085822cc9dd27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3895935
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1047456}
2022-09-15 14:03:50 +00:00
Lingqi Chi
2e03d9d6a7 Prerender: Perform capability control on associated interfaces.
This CL generalizes Mojo capability control to associated interfaces.

Before this CL, all of the associated interfaces are granted except
mojom::PepperHost.

After this CL, Prerender2 cancels prerendering when a received
binding request is not allowed to bind during prerendering. The
allowlists are defined in
chrome/browser/chrome_content_browser_client_binder_policies.cc (for
//chrome)
and content/browser/mojo_binder_policy_map_impl.cc(for //content).

Design(chromium@):
https://docs.google.com/document/d/1LPLURqzJW1EuhTAuD3igf1HlP4YaaiF3JNpvTdSZ3LE/edit#heading=h.xfm7goxm51fp

Bug: 1259007
Change-Id: I20ab235d7c2d6fa37aba1b686a064b6ffad36088
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3218175
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/main@{#939240}
2021-11-08 05:45:41 +00:00
Matt Falkenhagen
f78c2191a9 prerendering: Migrate to one Activate IPC per RenderView only.
Before this CL, we had an Activate IPC per RenderView and also an
Activate IPC for each document. This CL removes the per-document one.

This fixes a race where a document created in the renderer before the
RenderView IPC arrives starts with document.prerendering true, but it
never receives the per-document IPC so never transitions to
document.prerendering false.

This is the next step after commit 84e9a9b442. See [1], [2] for more
details on the design decision.

This CL does not add tests because it is difficult to test the above
race condition. The existing tests including ones added in
https://chromium-review.googlesource.com/c/chromium/src/+/3034321 should
continue to pass.

[1] https://groups.google.com/a/chromium.org/g/navigation-dev/c/v3T8NfWPTg8/m/brmF98nKAAAJ
[2] https://docs.google.com/document/d/1S8_ilRC_TkDa4Wz3PvBPYhhqIuGNHDX0DKsvjMFotKM/edit?usp=sharing

Bug: 1229552
Change-Id: Iabadf0ed2c1ca36b1153553aeed0f9c412a4ba49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3033843
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#904994}
2021-07-24 02:01:43 +00:00
Lingqi Chi
93462c64bc Prerender: Check MojoBinderPolicyApplier::GrantAll() is called within
Mojo message calls

This CL adds a DCHECK into MojoBinderPolicyApplier::GrantAll() to ensure
this method is called within Mojo message call stacks.
We should guarantee it because MojoBinderPolicyApplier::GrantAll()
invokes BrowserInterfaceBrokerImpl::BindInterface(), and the
BindInterface() method may call mojo::ReportBadMessage(), which should
be called within a stack frame of a Mojo message dispatch.

(Now mojom::LocalFrameHost::DidActivateForPrerendering() invokes
MojoBinderPolicyApplier::GrantAll(). See the issue description for more
information.)

Bug: 1217977
Change-Id: Ib63811a753243756b778b1a1f02f5aa616dedeba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2952745
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#892439}
2021-06-15 05:25:08 +00:00
Lingqi Chi
c8b3e81417 Reland "Prerender: Loosen Mojo capability control before firing
prerenderingchange"

This relands commit Ib3da39f9cae6b1a46d08a64d8f41b5f5b50460c0.

The added test failed on the LaCrOS builds because of the use of the
Gamepad API. This CL relands the test except for the LaCrOS builds.
Also this adds a new test using the NotificationService interface to
keep the test coverage on the LaCrOS builds.

Original change's description:
> For prerendering, MojoBinderPolicyMapApplier wants to loosen the
> kCancel policy slightly before the activation is complete.
>
> The activation of a prerendered page follows the steps below.
> 1. The activation navigation to the prerendered page is committed.
> 2. PrerenderHostRegistry knows that it can activate the prerendered
> page.
> 3. It informs every RenderFrameHostImpl(RFHI) of activation, and they
> will inform the corresponding documents on renderer sides.
> 4. These documents update their prerendering states and dispatch
> prerenderingchange events.
> 5. These documents inform the browser process that they finished
> activating.
> 6. The browser process releases binder policies. This should be done
> after step 5 because the renderer isn't meant to get these deferred
> messages before the prerenderingchange event is diepatched. But these
> Mojo message pipes are not channel-associated, once we grant those
> deferred binders and the interfaces are bound to the renderer, it
> might receives some deferred messages before CommitActivation arrives.
>
> The prerendered page is allowed to access kCancel and kUnexpected APIs
> in the prerenderingchange event, so RFHI may receive kCancel or
> kUnexpected binding requests between 4 and 6, which means we should
> loosen the Mojo capability control before firing this event.
>
> The decision of when to loose control has not been finalized, but at
> this point we can loosen the kCancel and kUnexpected polices in
> RenderFrameHostImpl::ActivateForPrerendering() for starting early
> testing.
>
> This CL implements this logic and adds a browser test for the
> GamepadMonitor interface, whose policy is kCancel, to ensure the
> change works.
>
> Bug: 1132752, 1186796
> Change-Id: Ib3da39f9cae6b1a46d08a64d8f41b5f5b50460c0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2810422
> Commit-Queue: Lingqi Chi <lingqi@chromium.org>
> Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
> Reviewed-by: Matt Falkenhagen <falken@chromium.org>
> Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#874138}

Bug: 1132752, 1186796, 1198110
Change-Id: I8be5c672e7a81db261329bc807146c9d13f92bc9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2842625
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#875615}
2021-04-23 11:45:18 +00:00
Christos Froussios
9fe412b789 Revert "Prerender: Loosen Mojo capability control before firing"
This reverts commit a728ed6052.

Reason for revert: 
All/PrerenderBrowserTest.GamepadMonitorAfterNavigation/WebContents
All/PrerenderBrowserTest.GamepadMonitorAfterNavigation/MPArch
are failing on linux-lacros-tester-rel
Example: https://ci.chromium.org/ui/p/chromium/builders/ci/linux-lacros-tester-rel/9034/overview

Original change's description:
> Prerender: Loosen Mojo capability control before firing
> prerenderingchange
>
> For prerendering, MojoBinderPolicyMapApplier wants to loosen the kCancel
> policy slightly before the activation is complete.
>
> The activation of a prerendered page follows the steps below.
> 1. The activation navigation to the prerendered page is committed.
> 2. PrerenderHostRegistry knows that it can activate the prerendered page.
> 3. It informs every RenderFrameHostImpl(RFHI) of activation, and they
> will inform the corresponding documents on renderer sides.
> 4. These documents update their prerendering states and dispatch
> prerenderingchange events.
> 5. These documents inform the browser process that they finished
> activating.
> 6. The browser process releases binder policies. This should be done
> after step 5 because the renderer isn't meant to get these deferred
> messages before the prerenderingchange event is diepatched. But these
> Mojo message pipes are not channel-associated, once we grant those
> deferred binders and the interfaces are bound to the renderer, it might
> receives some deferred messages before CommitActivation arrives.
>
> The prerendered page is allowed to access kCancel and kUnexpected APIs
> in the prerenderingchange event, so RFHI may receive kCancel or
> kUnexpected binding requests between 4 and 6, which means we should
> loosen the Mojo capability control before firing this event.
>
> The decision of when to loose control has not been finalized, but at
> this point we can loosen the kCancel and kUnexpected polices in
> RenderFrameHostImpl::ActivateForPrerendering() for starting early
> testing.
>
> This CL implements this logic and adds a browser test for the
> GamepadMonitor interface, whose policy is kCancel, to ensure the change
> works.
>
> Bug: 1132752, 1186796
> Change-Id: Ib3da39f9cae6b1a46d08a64d8f41b5f5b50460c0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2810422
> Commit-Queue: Lingqi Chi <lingqi@chromium.org>
> Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
> Reviewed-by: Matt Falkenhagen <falken@chromium.org>
> Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#874138}

Bug: 1132752
Bug: 1186796
Change-Id: Icb14aa78708d99d93079ee29bfede536432d2caf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2837979
Auto-Submit: Christos Froussios <cfroussios@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Christos Froussios <cfroussios@chromium.org>
Owners-Override: Christos Froussios <cfroussios@chromium.org>
Cr-Commit-Position: refs/heads/master@{#874205}
2021-04-20 10:29:48 +00:00
Lingqi Chi
a728ed6052 Prerender: Loosen Mojo capability control before firing
prerenderingchange

For prerendering, MojoBinderPolicyMapApplier wants to loosen the kCancel
policy slightly before the activation is complete.

The activation of a prerendered page follows the steps below.
1. The activation navigation to the prerendered page is committed.
2. PrerenderHostRegistry knows that it can activate the prerendered page.
3. It informs every RenderFrameHostImpl(RFHI) of activation, and they
will inform the corresponding documents on renderer sides.
4. These documents update their prerendering states and dispatch
prerenderingchange events.
5. These documents inform the browser process that they finished
activating.
6. The browser process releases binder policies. This should be done
after step 5 because the renderer isn't meant to get these deferred
messages before the prerenderingchange event is diepatched. But these
Mojo message pipes are not channel-associated, once we grant those
deferred binders and the interfaces are bound to the renderer, it might
receives some deferred messages before CommitActivation arrives.

The prerendered page is allowed to access kCancel and kUnexpected APIs
in the prerenderingchange event, so RFHI may receive kCancel or
kUnexpected binding requests between 4 and 6, which means we should
loosen the Mojo capability control before firing this event.

The decision of when to loose control has not been finalized, but at
this point we can loosen the kCancel and kUnexpected polices in
RenderFrameHostImpl::ActivateForPrerendering() for starting early
testing.

This CL implements this logic and adds a browser test for the
GamepadMonitor interface, whose policy is kCancel, to ensure the change
works.

Bug: 1132752, 1186796
Change-Id: Ib3da39f9cae6b1a46d08a64d8f41b5f5b50460c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2810422
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#874138}
2021-04-20 05:32:09 +00:00
Lingqi Chi
fc4b7d9cd0 Prerender: Record Cancelled Interfaces
This CL includes the following changes.
- Updates the final state of PrerenderHost when MojoBinderPolicyApplier
cancels prerendering.
- Records the interface that causes the cancellation and reports it to
UMA.

Bug: 1132752, 1126305
Change-Id: Ibc156d588424917c2a8f05478e386b272c6cffe8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2796850
Reviewed-by: Steven Holte <holte@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#870322}
2021-04-08 01:41:22 +00:00
Lingqi Chi
e9e0fb3d12 Prerender: Handle Unexpected Binding Requests
For kUnexpected interface binders, we want to understand the situation
by checking crash reports.
When receiving an unexpected binding request, MojoBinderPolicyApplier
- Reports a bad mojom message to crash the corresponding renderer.
- Cancels the prerender.

Bug: 1141364
Change-Id: Ia332ccb14b723ce160c6514a7c8128e96c466c7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2784660
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#867577}
2021-03-30 13:13:51 +00:00
Lingqi Chi
0ca6ac5a38 Prerender: Add kPrepareToGrantAll Mode to MojoBinderPolicyApplier
This CL allows Prerender2 to partially loosen its binding policies by
switching MojoBinderPolicyApplier(MBPA) into the kPrepareToGrantAll
mode.

The Prerender activation flow requires Mojo capability control to
loosen kCancel and kUnexpected policies before Blink dispatches the
`prerenderingchange` event.
(https://docs.google.com/document/d/1_l1LDUALf8PbZIz5y_UYNGZmYCMKNpePDLBHn-gTsTM/)

Mojo capability control controls when and whether to bind a interface
with MBPA. Before this CL, MBPA only runs in two modes, one applies
pre-set policies strictly, and will cancel the current prerender if it
receives a kCancel/kUnexpected interface; the other ignores these
policies and runs all binders immediately.

To meet the new requirement, this CL introduces a new
mode, kPrepareToGrantAll. When running in this mode, MBPA only defers
non-kGrant binding requests but not cancels prerendering.

Bug: 1132752
Change-Id: Ie93eb7aba458f3e687649d6c3859feb44ccdfe20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2726016
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#863697}
2021-03-17 10:39:55 +00:00
Lingqi Chi
242d891e46 Prerender: Set MojoBinderPolicyApplier in the constructor of
RenderFrameHostImpl

After https://chromium-review.googlesource.com/c/chromium/src/+/2689551,
RenderFrameHostImpl(RFHI) can access the correct prerendering state in
its constructor. So RFHI can decide whether to enable Mojo capability
control here according to the prerendering state.
This CL sets MojoBinderPolicyApplier in RFHI::ctor. It brings the
following benefits:
1. In prerendering pages, we can ensure that
BrowserInterfaceBrokerImpl(BIB) receives interface binders after
RFHI sets MojoBinderPolicyApplier, i.e., Mojo capability control is
enabled before BIB receives the first binding request.
2. It unifies the logic of setting MojoBinderPolicyApplier; RFHI sets it
in three different methods before this CL.
3. It guarantees every RenderFrameHostImpl in the prerendering frame
tree enables Mojo capability control. Before this CL, activating the
prerendering page could happen before RFHI::CommitNavigation(), which
fails `CHECK(policy_applier_);` in ReleaseMojoBinderPolicies().

Bug: 1132752, 1160611
Change-Id: Ie1bb0366fc01d3018ad7e6b52cff31152d000f78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2738156
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#861494}
2021-03-10 09:45:49 +00:00
Lingqi Chi
cd5239ed9e Prerender: rename *ForPrerendering to *ForSameOriginPrerendering
Same-origin prerendering and cross-origin prerendering should have
different Mojo binder policies to protect users' privacy.
Prerender2 plan to support only same-origin prerendering in the early
stage, so now all policies set for prerendering are for same-origin
prerendering.

This CL renames all policy-related *ForPrerendering functions to
*ForSameOriginPrerendering to make the intention clearer.

Bug: 1145976
Change-Id: Iad714876af22a29441071fcbbc62e0ae70bfa7bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2726024
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#859301}
2021-03-03 09:15:33 +00:00
Hiroki Nakagawa
422bd2ba3c Prerender: Remove outdated TODO comments about BrowserInterfaceBroker
These TODOs were already fixed by
- https://crrev.com/c/2629067
- https://crrev.com/c/2639501

Bug: 1132752
Change-Id: I354096c7cd6fd14319b844c64fb395cd273beb17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2686771
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Auto-Submit: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#852583}
2021-02-10 11:19:07 +00:00
Lingqi Chi
ee8814f71f Prerender: Enable Mojo Capability Control in Prerendering Frames
Prerender2 wants to defer running some interface binders so as to
control the capability of renderer processes in prerendering pages.
This CL creates MojoBinderPolicyApplier and adds it to
BrowserInterfaceBrokerImpl of prerendering frames to make it.

Bug: 1132752
Change-Id: I0777620c68eb0435611ab96e27bc3e56c4936029
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2629067
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845087}
2021-01-20 07:35:07 +00:00
Lingqi Chi
775e6075d2 Prerender: Add content API MojoBinderPolicyMap
This is part of work to control the Mojo interfaces available to
prerendered pages. See design doc[1] for more details.

In addition to content/, embedders define their own Mojo interfaces,
so they need to add their binding policies.
This CL adds a new content API named MojoBinderPolicyMap that allows
embedders to register policies for embedder-specific interfaces by
overriding ContentBrowserClient::RegisterMojoBinderPolicyMap method.

[1] https://docs.google.com/document/d/1E3Ma8HQFmxx8OvWVrjqpLziYIRbTRgLat4cM-nyKB6w/edit?usp=sharing

Bug: 1132752
Change-Id: Ie47a9fc2517fd3cda8438e9c61a5fa6854a8f36d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2507230
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836539}
2020-12-14 06:31:16 +00:00
Lingqi Chi
fa0dda127b Prerender: Equip BrowserInterfaceBroker with MojoBinderPolicyApplier
Some new features, such as prerendering, need to defer some binding
interface requests or stop the renderer when an unexpected mojo pipe is
requested to set up.
This CL introduces MojoBinderPolicyApplier that manages binding requests
and integrates it with BrowserInterfaceBroker.

Regarding the MojoBinderPolicyApplier, it should be initialized with a
predefined policy map. It decide the actions the applier takes when
handling incoming requests. Based on the predefined policies and the
current state, a MojoBinderPolicyApplier instance may take the following
actions:
1. Bind the given interface immediately. (kGrant or
`ResolveDeferredBinders` has been invoked)
2. Delay binding the interface until `ResolveDeferredBinders` is called.
(kDefer)
3. Call the cancelling closure. (kCancel)
4. Stop the renderer and collect some metrics for analysis. (kUnexpected)

Bug: 1132752
Change-Id: Ifdc2f0b27d2f4613274fe5c6e44ddb056a199509
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2513960
Commit-Queue: Lingqi Chi <lingqi@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828609}
2020-11-18 05:32:45 +00:00