Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: chrome/browser/managed_mode/managed_mode_navigation_observer.cc

Issue 63423003: Set ENABLE_MANAGED_USERS #ifdef on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" 5 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "chrome/browser/history/history_service.h" 11 #include "chrome/browser/history/history_service.h"
12 #include "chrome/browser/history/history_service_factory.h" 12 #include "chrome/browser/history/history_service_factory.h"
13 #include "chrome/browser/history/history_types.h" 13 #include "chrome/browser/history/history_types.h"
14 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 14 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
15 #include "chrome/browser/infobars/infobar_service.h" 15 #include "chrome/browser/infobars/infobar_service.h"
16 #include "chrome/browser/managed_mode/managed_mode_interstitial.h" 16 #include "chrome/browser/managed_mode/managed_mode_interstitial.h"
17 #include "chrome/browser/managed_mode/managed_mode_resource_throttle.h" 17 #include "chrome/browser/managed_mode/managed_mode_resource_throttle.h"
18 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" 18 #include "chrome/browser/managed_mode/managed_mode_url_filter.h"
19 #include "chrome/browser/managed_mode/managed_user_service.h" 19 #include "chrome/browser/managed_mode/managed_user_service.h"
20 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 20 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/tab_contents/tab_util.h" 22 #include "chrome/browser/tab_contents/tab_util.h"
23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_commands.h"
25 #include "chrome/browser/ui/browser_finder.h"
26 #include "chrome/browser/ui/browser_list.h"
27 #include "chrome/browser/ui/host_desktop.h"
28 #include "chrome/browser/ui/tabs/tab_strip_model.h"
29 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/navigation_entry.h" 24 #include "content/public/browser/navigation_entry.h"
31 #include "content/public/browser/render_process_host.h" 25 #include "content/public/browser/render_process_host.h"
32 #include "content/public/browser/render_view_host.h" 26 #include "content/public/browser/render_view_host.h"
33 #include "content/public/browser/user_metrics.h" 27 #include "content/public/browser/user_metrics.h"
34 #include "content/public/browser/web_contents_view.h" 28 #include "content/public/browser/web_contents_view.h"
35 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
36 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
37 31
32 #if !defined(OS_ANDROID)
33 #include "chrome/browser/ui/browser.h"
34 #include "chrome/browser/ui/browser_commands.h"
35 #include "chrome/browser/ui/browser_finder.h"
36 #include "chrome/browser/ui/browser_list.h"
37 #include "chrome/browser/ui/host_desktop.h"
38 #include "chrome/browser/ui/tabs/tab_strip_model.h"
39 #endif
40
38 using base::Time; 41 using base::Time;
39 using content::NavigationEntry; 42 using content::NavigationEntry;
40 43
41 namespace { 44 namespace {
42 45
43 46
44 // Helpers -------------------------------------------------------------------- 47 // Helpers --------------------------------------------------------------------
45 48
49 #if !defined(OS_ANDROID)
50 // TODO(bauerb): Get rid of the platform-specific #ifdef here.
51 // http://crbug.com/313377
46 void GoBackToSafety(content::WebContents* web_contents) { 52 void GoBackToSafety(content::WebContents* web_contents) {
47 // For now, just go back one page (the user didn't retreat from that page, 53 // For now, just go back one page (the user didn't retreat from that page,
48 // so it should be okay). 54 // so it should be okay).
49 content::NavigationController* controller = 55 content::NavigationController* controller =
50 &web_contents->GetController(); 56 &web_contents->GetController();
51 if (controller->CanGoBack()) { 57 if (controller->CanGoBack()) {
52 controller->GoBack(); 58 controller->GoBack();
53 return; 59 return;
54 } 60 }
55 61
56 // If we can't go back (because we opened a new tab), try to close the tab. 62 // If we can't go back (because we opened a new tab), try to close the tab.
57 // If this is the last tab on this desktop, open a new window. 63 // If this is the last tab on this desktop, open a new window.
58 chrome::HostDesktopType host_desktop_type = 64 chrome::HostDesktopType host_desktop_type =
59 chrome::GetHostDesktopTypeForNativeView( 65 chrome::GetHostDesktopTypeForNativeView(
60 web_contents->GetView()->GetNativeView()); 66 web_contents->GetView()->GetNativeView());
61 const BrowserList* browser_list = BrowserList::GetInstance(host_desktop_type); 67 const BrowserList* browser_list = BrowserList::GetInstance(host_desktop_type);
62 if (browser_list->size() == 1) { 68 if (browser_list->size() == 1) {
63 Browser* browser = browser_list->get(0); 69 Browser* browser = browser_list->get(0);
64 DCHECK(browser == chrome::FindBrowserWithWebContents(web_contents)); 70 DCHECK(browser == chrome::FindBrowserWithWebContents(web_contents));
65 if (browser->tab_strip_model()->count() == 1) 71 if (browser->tab_strip_model()->count() == 1)
66 chrome::NewEmptyWindow(browser->profile(), browser->host_desktop_type()); 72 chrome::NewEmptyWindow(browser->profile(), browser->host_desktop_type());
67 } 73 }
68 74
69 web_contents->GetDelegate()->CloseContents(web_contents); 75 web_contents->GetDelegate()->CloseContents(web_contents);
70 } 76 }
71 77 #endif
72 78
73 // ManagedModeWarningInfoBarDelegate ------------------------------------------ 79 // ManagedModeWarningInfoBarDelegate ------------------------------------------
74 80
75 class ManagedModeWarningInfoBarDelegate : public ConfirmInfoBarDelegate { 81 class ManagedModeWarningInfoBarDelegate : public ConfirmInfoBarDelegate {
76 public: 82 public:
77 // Creates a managed mode warning infobar delegate and adds it to 83 // Creates a managed mode warning infobar delegate and adds it to
78 // |infobar_service|. Returns the delegate if it was successfully added. 84 // |infobar_service|. Returns the delegate if it was successfully added.
79 static InfoBarDelegate* Create(InfoBarService* infobar_service); 85 static InfoBarDelegate* Create(InfoBarService* infobar_service);
80 86
81 private: 87 private:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return BUTTON_OK; 134 return BUTTON_OK;
129 } 135 }
130 136
131 string16 ManagedModeWarningInfoBarDelegate::GetButtonLabel( 137 string16 ManagedModeWarningInfoBarDelegate::GetButtonLabel(
132 InfoBarButton button) const { 138 InfoBarButton button) const {
133 DCHECK_EQ(BUTTON_OK, button); 139 DCHECK_EQ(BUTTON_OK, button);
134 return l10n_util::GetStringUTF16(IDS_MANAGED_USER_WARN_INFOBAR_GO_BACK); 140 return l10n_util::GetStringUTF16(IDS_MANAGED_USER_WARN_INFOBAR_GO_BACK);
135 } 141 }
136 142
137 bool ManagedModeWarningInfoBarDelegate::Accept() { 143 bool ManagedModeWarningInfoBarDelegate::Accept() {
144 #if defined(OS_ANDROID)
145 // TODO(bauerb): Get rid of the platform-specific #ifdef here.
146 // http://crbug.com/313377
147 NOTIMPLEMENTED();
148 #else
138 GoBackToSafety(web_contents()); 149 GoBackToSafety(web_contents());
150 #endif
139 151
140 return false; 152 return false;
141 } 153 }
142 154
143 155
144 } // namespace 156 } // namespace
145 157
146 // ManagedModeNavigationObserver ---------------------------------------------- 158 // ManagedModeNavigationObserver ----------------------------------------------
147 159
148 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagedModeNavigationObserver); 160 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagedModeNavigationObserver);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 history_service->AddPage(add_page_args); 254 history_service->AddPage(add_page_args);
243 255
244 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); 256 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create());
245 entry->SetVirtualURL(url); 257 entry->SetVirtualURL(url);
246 entry->SetTimestamp(timestamp); 258 entry->SetTimestamp(timestamp);
247 blocked_navigations_.push_back(entry.release()); 259 blocked_navigations_.push_back(entry.release());
248 ManagedUserService* managed_user_service = 260 ManagedUserService* managed_user_service =
249 ManagedUserServiceFactory::GetForProfile(profile); 261 ManagedUserServiceFactory::GetForProfile(profile);
250 managed_user_service->DidBlockNavigation(web_contents()); 262 managed_user_service->DidBlockNavigation(web_contents());
251 } 263 }
OLDNEW
« no previous file with comments | « chrome/browser/android/tab_android.cc ('k') | chrome/browser/managed_mode/managed_mode_url_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698