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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_model_impl.cc

Issue 266263002: [OriginChip] Add an option to display only on search result pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to comments Created 6 years, 7 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 | « chrome/browser/ui/omnibox/omnibox_view.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/ui/toolbar/toolbar_model_impl.h" 5 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 !pending_entry->GetExtraData(kInterstitialShownKey, &unused)) 175 !pending_entry->GetExtraData(kInterstitialShownKey, &unused))
176 pending_entry->SetExtraData(kInterstitialShownKey, base::string16()); 176 pending_entry->SetExtraData(kInterstitialShownKey, base::string16());
177 const content::PageTransition transition_type = 177 const content::PageTransition transition_type =
178 pending_entry->GetTransitionType(); 178 pending_entry->GetTransitionType();
179 if ((transition_type & content::PAGE_TRANSITION_TYPED) != 0 && 179 if ((transition_type & content::PAGE_TRANSITION_TYPED) != 0 &&
180 !pending_entry->GetExtraData(kInterstitialShownKey, &unused)) 180 !pending_entry->GetExtraData(kInterstitialShownKey, &unused))
181 return false; 181 return false;
182 } 182 }
183 } 183 }
184 184
185 bool should_display_origin_chip = 185 if (!delegate_->InTabbedBrowser() || !ShouldDisplayURL() ||
186 chrome::ShouldDisplayOriginChip() || chrome::ShouldDisplayOriginChipV2(); 186 !url_replacement_enabled())
187 return should_display_origin_chip && delegate_->InTabbedBrowser() && 187 return false;
188 ShouldDisplayURL() && url_replacement_enabled(); 188
189 if (chrome::ShouldDisplayOriginChip())
190 return true;
191
192 const chrome::OriginChipV2Condition chip_condition =
193 chrome::GetOriginChipV2Condition();
194 return (chip_condition != chrome::ORIGIN_CHIP_V2_DISABLED) &&
195 ((chip_condition != chrome::ORIGIN_CHIP_V2_ON_SRP) ||
196 WouldPerformSearchTermReplacement(false));
189 } 197 }
190 198
191 bool ToolbarModelImpl::WouldPerformSearchTermReplacement( 199 bool ToolbarModelImpl::WouldPerformSearchTermReplacement(
192 bool ignore_editing) const { 200 bool ignore_editing) const {
193 return !GetSearchTerms(ignore_editing).empty(); 201 return !GetSearchTerms(ignore_editing).empty();
194 } 202 }
195 203
196 bool ToolbarModelImpl::ShouldDisplayURL() const { 204 bool ToolbarModelImpl::ShouldDisplayURL() const {
197 // Note: The order here is important. 205 // Note: The order here is important.
198 // - The WebUI test must come before the extension scheme test because there 206 // - The WebUI test must come before the extension scheme test because there
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 if (entry && 340 if (entry &&
333 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL())) 341 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL()))
334 return search_terms; 342 return search_terms;
335 343
336 // Otherwise, extract search terms for HTTPS pages that do not have a security 344 // Otherwise, extract search terms for HTTPS pages that do not have a security
337 // error. 345 // error.
338 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing); 346 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing);
339 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ? 347 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ?
340 base::string16() : search_terms; 348 base::string16() : search_terms;
341 } 349 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_view.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698