forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bookmark_app_experimental_navigation_throttle.h
68 lines (51 loc) · 2.43 KB
/
bookmark_app_experimental_navigation_throttle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_EXPERIMENTAL_NAVIGATION_THROTTLE_H_
#define CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_EXPERIMENTAL_NAVIGATION_THROTTLE_H_
#include <memory>
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/navigation_throttle.h"
#include "url/gurl.h"
namespace content {
class NavigationHandle;
} // namespace content
namespace extensions {
class Extension;
// This class creates navigation throttles that redirect URLs to Bookmark Apps
// if the URLs are in scope of the Bookmark App.
class BookmarkAppExperimentalNavigationThrottle
: public content::NavigationThrottle {
public:
static std::unique_ptr<content::NavigationThrottle> MaybeCreateThrottleFor(
content::NavigationHandle* navigation_handle);
explicit BookmarkAppExperimentalNavigationThrottle(
content::NavigationHandle* navigation_handle);
~BookmarkAppExperimentalNavigationThrottle() override;
// content::NavigationThrottle:
content::NavigationThrottle::ThrottleCheckResult WillStartRequest() override;
content::NavigationThrottle::ThrottleCheckResult WillRedirectRequest()
override;
const char* GetNameForLogging() override;
private:
// Decides if the navigation should be opened in a new tab, in a new App
// Window, or if the navigation should continue normally.
content::NavigationThrottle::ThrottleCheckResult ProcessNavigation(
bool is_redirect);
// Opens the current target url in an App window. May post a task to do so if
// opening the app synchronously could result in the app opening in the
// background. Also closes the current tab if this is the first navigation.
content::NavigationThrottle::ThrottleCheckResult
OpenInAppWindowAndCloseTabIfNecessary(
scoped_refptr<const Extension> target_app);
void OpenBookmarkApp(scoped_refptr<const Extension> bookmark_app);
void CloseWebContents();
void OpenInNewTabAndCancel();
void ReparentWebContentsAndResume(scoped_refptr<const Extension> target_app);
base::WeakPtrFactory<BookmarkAppExperimentalNavigationThrottle>
weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(BookmarkAppExperimentalNavigationThrottle);
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_EXPERIMENTAL_NAVIGATION_THROTTLE_H_