- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / managed_mode / managed_mode_navigation_observer.h
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.
4
5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
7
8 #include <set>
9 #include <vector>
10
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"
16
17 class InfoBarDelegate;
18 class ManagedModeURLFilter;
19 class ManagedUserService;
20
21 namespace content {
22 class NavigationEntry;
23 }
24
25 class ManagedModeNavigationObserver
26     : public content::WebContentsObserver,
27       public content::WebContentsUserData<ManagedModeNavigationObserver> {
28  public:
29   virtual ~ManagedModeNavigationObserver();
30
31   // Sets the specific infobar as dismissed.
32   void WarnInfoBarDismissed();
33
34   const std::vector<const content::NavigationEntry*>*
35       blocked_navigations() const {
36     return &blocked_navigations_.get();
37   }
38
39   // Called when a network request to |url| is blocked.
40   static void OnRequestBlocked(int render_process_host_id,
41                                int render_view_id,
42                                const GURL& url,
43                                const base::Callback<void(bool)>& callback);
44
45  private:
46   friend class content::WebContentsUserData<ManagedModeNavigationObserver>;
47
48   explicit ManagedModeNavigationObserver(content::WebContents* web_contents);
49
50   // content::WebContentsObserver implementation.
51   virtual void ProvisionalChangeToMainFrameUrl(
52       const GURL& url,
53       content::RenderViewHost* render_view_host) OVERRIDE;
54   virtual void DidCommitProvisionalLoadForFrame(
55       int64 frame_id,
56       const string16& frame_unique_name,
57       bool is_main_frame,
58       const GURL& url,
59       content::PageTransition transition_type,
60       content::RenderViewHost* render_view_host) OVERRIDE;
61
62   void OnRequestBlockedInternal(const GURL& url);
63
64   // Owned by the profile, so outlives us.
65   ManagedUserService* managed_user_service_;
66
67   // Owned by ManagedUserService.
68   const ManagedModeURLFilter* url_filter_;
69
70   // Owned by the InfoBarService, which has the same lifetime as this object.
71   InfoBarDelegate* warn_infobar_;
72
73   ScopedVector<const content::NavigationEntry> blocked_navigations_;
74
75   DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver);
76 };
77
78 #endif  // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_