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

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

Issue 12207051: Make ManagedMode's GoBackToSafety feature kinda' multi-desktop aware...! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" 11 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
12 #include "chrome/browser/api/infobars/infobar_service.h" 12 #include "chrome/browser/api/infobars/infobar_service.h"
13 #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h" 13 #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h"
14 #include "chrome/browser/managed_mode/managed_mode.h" 14 #include "chrome/browser/managed_mode/managed_mode.h"
15 #include "chrome/browser/managed_mode/managed_mode_interstitial.h" 15 #include "chrome/browser/managed_mode/managed_mode_interstitial.h"
16 #include "chrome/browser/managed_mode/managed_mode_resource_throttle.h" 16 #include "chrome/browser/managed_mode/managed_mode_resource_throttle.h"
17 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" 17 #include "chrome/browser/managed_mode/managed_mode_url_filter.h"
18 #include "chrome/browser/managed_mode/managed_user_service.h" 18 #include "chrome/browser/managed_mode/managed_user_service.h"
19 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 19 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
20 #include "chrome/browser/prefs/pref_service.h" 20 #include "chrome/browser/prefs/pref_service.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_commands.h" 23 #include "chrome/browser/ui/browser_commands.h"
24 #include "chrome/browser/ui/browser_finder.h" 24 #include "chrome/browser/ui/browser_finder.h"
25 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_list_impl.h"
26 #include "chrome/browser/ui/host_desktop.h"
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" 27 #include "chrome/browser/ui/tabs/tab_strip_model.h"
27 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
28 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
29 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/render_process_host.h" 31 #include "content/public/browser/render_process_host.h"
31 #include "content/public/browser/render_view_host.h" 32 #include "content/public/browser/render_view_host.h"
32 #include "content/public/browser/user_metrics.h" 33 #include "content/public/browser/user_metrics.h"
33 #include "content/public/browser/web_contents_delegate.h" 34 #include "content/public/browser/web_contents_delegate.h"
34 #include "content/public/common/frame_navigate_params.h" 35 #include "content/public/common/frame_navigate_params.h"
35 #include "grit/generated_resources.h" 36 #include "grit/generated_resources.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // For now, just go back one page (the user didn't retreat from that page, 82 // For now, just go back one page (the user didn't retreat from that page,
82 // so it should be okay). 83 // so it should be okay).
83 content::NavigationController* controller = 84 content::NavigationController* controller =
84 &web_contents->GetController(); 85 &web_contents->GetController();
85 if (controller->CanGoBack()) { 86 if (controller->CanGoBack()) {
86 controller->GoBack(); 87 controller->GoBack();
87 return; 88 return;
88 } 89 }
89 90
90 // If we can't go back (because we opened a new tab), try to close the tab. 91 // If we can't go back (because we opened a new tab), try to close the tab.
91 // If this is the last tab, open a new window. 92 // If this is the last tab on this desktop, open a new window.
92 if (BrowserList::size() == 1) { 93 chrome::HostDesktopType host_desktop_type =
93 Browser* browser = *(BrowserList::begin()); 94 chrome::GetHostDesktopTypeForNativeView(web_contents->GetNativeView());
95 const chrome::BrowserListImpl* browser_list =
96 chrome::BrowserListImpl::GetInstance(host_desktop_type);
97 if (browser_list->size() == 1) {
98 Browser* browser = browser_list->get(0);
94 DCHECK(browser == chrome::FindBrowserWithWebContents(web_contents)); 99 DCHECK(browser == chrome::FindBrowserWithWebContents(web_contents));
95 if (browser->tab_strip_model()->count() == 1) 100 if (browser->tab_strip_model()->count() == 1)
96 chrome::NewEmptyWindow(browser->profile()); 101 chrome::NewEmptyWindow(browser->profile());
97 } 102 }
98 103
99 web_contents->GetDelegate()->CloseContents(web_contents); 104 web_contents->GetDelegate()->CloseContents(web_contents);
100 } 105 }
101 106
102 // static 107 // static
103 InfoBarDelegate* ManagedModeWarningInfobarDelegate::Create( 108 InfoBarDelegate* ManagedModeWarningInfobarDelegate::Create(
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 case NOT_RECORDING_URLS: 489 case NOT_RECORDING_URLS:
485 // Check that the infobar is present. 490 // Check that the infobar is present.
486 DCHECK(preview_infobar_delegate_); 491 DCHECK(preview_infobar_delegate_);
487 break; 492 break;
488 } 493 }
489 } 494 }
490 495
491 if (behavior == ManagedModeURLFilter::ALLOW) 496 if (behavior == ManagedModeURLFilter::ALLOW)
492 last_allowed_page_ = web_contents()->GetController().GetCurrentEntryIndex(); 497 last_allowed_page_ = web_contents()->GetController().GetCurrentEntryIndex();
493 } 498 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698