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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
11 #include "base/memory/scoped_vector.h"
12 #include "base/values.h"
13 #include "chrome/browser/managed_mode/managed_users.h"
14 #include "content/public/browser/web_contents_observer.h"
15 #include "content/public/browser/web_contents_user_data.h"
17 class ManagedModeURLFilter
;
18 class ManagedUserService
;
21 class NavigationEntry
;
28 class ManagedModeNavigationObserver
29 : public content::WebContentsObserver
,
30 public content::WebContentsUserData
<ManagedModeNavigationObserver
> {
32 virtual ~ManagedModeNavigationObserver();
34 // Sets the specific infobar as dismissed.
35 void WarnInfoBarDismissed();
37 const std::vector
<const content::NavigationEntry
*>*
38 blocked_navigations() const {
39 return &blocked_navigations_
.get();
42 // Called when a network request to |url| is blocked.
43 static void OnRequestBlocked(int render_process_host_id
,
46 const base::Callback
<void(bool)>& callback
);
49 friend class content::WebContentsUserData
<ManagedModeNavigationObserver
>;
51 explicit ManagedModeNavigationObserver(content::WebContents
* web_contents
);
53 // content::WebContentsObserver implementation.
54 virtual void ProvisionalChangeToMainFrameUrl(
56 content::RenderFrameHost
* render_frame_host
) OVERRIDE
;
57 virtual void DidCommitProvisionalLoadForFrame(
59 const base::string16
& frame_unique_name
,
62 content::PageTransition transition_type
,
63 content::RenderViewHost
* render_view_host
) OVERRIDE
;
65 void OnRequestBlockedInternal(const GURL
& url
);
67 // Owned by the profile, so outlives us.
68 ManagedUserService
* managed_user_service_
;
70 // Owned by ManagedUserService.
71 const ManagedModeURLFilter
* url_filter_
;
73 // Owned by the InfoBarService, which has the same lifetime as this object.
74 infobars::InfoBar
* warn_infobar_
;
76 ScopedVector
<const content::NavigationEntry
> blocked_navigations_
;
78 DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver
);
81 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_