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"
18 class ManagedModeURLFilter
;
19 class ManagedUserService
;
22 class NavigationEntry
;
25 class ManagedModeNavigationObserver
26 : public content::WebContentsObserver
,
27 public content::WebContentsUserData
<ManagedModeNavigationObserver
> {
29 virtual ~ManagedModeNavigationObserver();
31 // Sets the specific infobar as dismissed.
32 void WarnInfoBarDismissed();
34 const std::vector
<const content::NavigationEntry
*>*
35 blocked_navigations() const {
36 return &blocked_navigations_
.get();
39 // Called when a network request to |url| is blocked.
40 static void OnRequestBlocked(int render_process_host_id
,
43 const base::Callback
<void(bool)>& callback
);
46 friend class content::WebContentsUserData
<ManagedModeNavigationObserver
>;
48 explicit ManagedModeNavigationObserver(content::WebContents
* web_contents
);
50 // content::WebContentsObserver implementation.
51 virtual void ProvisionalChangeToMainFrameUrl(
53 content::RenderFrameHost
* render_frame_host
) OVERRIDE
;
54 virtual void DidCommitProvisionalLoadForFrame(
56 const base::string16
& frame_unique_name
,
59 content::PageTransition transition_type
,
60 content::RenderViewHost
* render_view_host
) OVERRIDE
;
62 void OnRequestBlockedInternal(const GURL
& url
);
64 // Owned by the profile, so outlives us.
65 ManagedUserService
* managed_user_service_
;
67 // Owned by ManagedUserService.
68 const ManagedModeURLFilter
* url_filter_
;
70 // Owned by the InfoBarService, which has the same lifetime as this object.
71 InfoBar
* warn_infobar_
;
73 ScopedVector
<const content::NavigationEntry
> blocked_navigations_
;
75 DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver
);
78 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_