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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm

Issue 7520023: Converted IncognitoForced boolean policy into IncognitoModeAvailability enum policy. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Removed unnecessary comment. Created 9 years, 4 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
6 6
7 #include "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "chrome/browser/bookmarks/bookmark_editor.h" 10 #include "chrome/browser/bookmarks/bookmark_editor.h"
11 #include "chrome/browser/bookmarks/bookmark_model.h" 11 #include "chrome/browser/bookmarks/bookmark_model.h"
12 #include "chrome/browser/bookmarks/bookmark_utils.h" 12 #include "chrome/browser/bookmarks/bookmark_utils.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/prefs/incognito_mode_prefs.h"
14 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #import "chrome/browser/themes/theme_service.h" 17 #import "chrome/browser/themes/theme_service.h"
17 #import "chrome/browser/themes/theme_service_factory.h" 18 #import "chrome/browser/themes/theme_service_factory.h"
18 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_list.h" 20 #include "chrome/browser/ui/browser_list.h"
20 #import "chrome/browser/ui/cocoa/background_gradient_view.h" 21 #import "chrome/browser/ui/cocoa/background_gradient_view.h"
21 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h" 22 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h"
22 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" 23 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h"
23 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" 24 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h"
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 (!bookmark_utils::CanPasteFromClipboard(node) || !can_edit)) { 1079 (!bookmark_utils::CanPasteFromClipboard(node) || !can_edit)) {
1079 return NO; 1080 return NO;
1080 } 1081 }
1081 1082
1082 if ((!can_edit) && 1083 if ((!can_edit) &&
1083 ((action == @selector(addPage:)) || 1084 ((action == @selector(addPage:)) ||
1084 (action == @selector(addFolder:)))) { 1085 (action == @selector(addFolder:)))) {
1085 return NO; 1086 return NO;
1086 } 1087 }
1087 1088
1089 Profile* profile = browser_->profile();
1088 // If this is an incognito window, don't allow "open in incognito". 1090 // If this is an incognito window, don't allow "open in incognito".
1089 if ((action == @selector(openBookmarkInIncognitoWindow:)) || 1091 if ((action == @selector(openBookmarkInIncognitoWindow:)) ||
1090 (action == @selector(openAllBookmarksIncognitoWindow:))) { 1092 (action == @selector(openAllBookmarksIncognitoWindow:))) {
1091 Profile* profile = browser_->profile();
1092 if (profile->IsOffTheRecord() || 1093 if (profile->IsOffTheRecord() ||
1093 !profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) { 1094 IncognitoModePrefs::GetAvailability(profile->GetPrefs()) ==
1095 IncognitoModePrefs::DISABLED) {
1094 return NO; 1096 return NO;
1095 } 1097 }
1096 } 1098 }
1099
1100 // If Incognito mode is forced, do not let open bookmarks in normal window.
1101 if ((action == @selector(openBookmark:)) ||
1102 (action == @selector(openAllBookmarksNewWindow:)) ||
1103 (action == @selector(openAllBookmarks:))) {
1104 if (IncognitoModePrefs::GetAvailability(profile->GetPrefs()) ==
1105 IncognitoModePrefs::FORCED) {
1106 return NO;
1107 }
1108 }
1097 1109
1098 // Enabled by default. 1110 // Enabled by default.
1099 return YES; 1111 return YES;
1100 } 1112 }
1101 1113
1102 // Actually open the URL. This is the last chance for a unit test to 1114 // Actually open the URL. This is the last chance for a unit test to
1103 // override. 1115 // override.
1104 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition { 1116 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition {
1105 browser_->OpenURL(url, GURL(), disposition, PageTransition::AUTO_BOOKMARK); 1117 browser_->OpenURL(url, GURL(), disposition, PageTransition::AUTO_BOOKMARK);
1106 } 1118 }
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 // to minimize touching the object passed in (likely a mock). 2772 // to minimize touching the object passed in (likely a mock).
2761 - (void)setButtonContextMenu:(id)menu { 2773 - (void)setButtonContextMenu:(id)menu {
2762 buttonContextMenu_ = menu; 2774 buttonContextMenu_ = menu;
2763 } 2775 }
2764 2776
2765 - (void)setIgnoreAnimations:(BOOL)ignore { 2777 - (void)setIgnoreAnimations:(BOOL)ignore {
2766 ignoreAnimations_ = ignore; 2778 ignoreAnimations_ = ignore;
2767 } 2779 }
2768 2780
2769 @end 2781 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_init.cc ('k') | chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698