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

Side by Side Diff: ios/chrome/browser/ui/toolbar/toolbar_model_impl_ios.mm

Issue 2608733003: Check GetVisibleItem exists in GetFormattedURL (Closed)
Patch Set: Created 3 years, 11 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
« 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 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 "ios/chrome/browser/ui/toolbar/toolbar_model_impl_ios.h" 5 #include "ios/chrome/browser/ui/toolbar/toolbar_model_impl_ios.h"
6 6
7 #include "components/bookmarks/browser/bookmark_model.h" 7 #include "components/bookmarks/browser/bookmark_model.h"
8 #include "components/toolbar/toolbar_model_impl.h" 8 #include "components/toolbar/toolbar_model_impl.h"
9 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" 9 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 bool ToolbarModelImplIOS::ShouldDisplayHintText() { 79 bool ToolbarModelImplIOS::ShouldDisplayHintText() {
80 Tab* current_tab = delegate_->GetCurrentTab(); 80 Tab* current_tab = delegate_->GetCurrentTab();
81 return [current_tab.webController wantsLocationBarHintText]; 81 return [current_tab.webController wantsLocationBarHintText];
82 } 82 }
83 83
84 base::string16 ToolbarModelImplIOS::GetFormattedURL(size_t* prefix_end) const { 84 base::string16 ToolbarModelImplIOS::GetFormattedURL(size_t* prefix_end) const {
85 base::string16 formatted_url = toolbar_model_->GetFormattedURL(prefix_end); 85 base::string16 formatted_url = toolbar_model_->GetFormattedURL(prefix_end);
86 Tab* current_tab = delegate_->GetCurrentTab(); 86 Tab* current_tab = delegate_->GetCurrentTab();
87 if (!current_tab || !current_tab.webState ||
88 !current_tab.webState->GetNavigationManager() ||
89 !current_tab.webState->GetNavigationManager()->GetVisibleItem()) {
90 return formatted_url;
91 }
87 GURL url = 92 GURL url =
88 current_tab.webState->GetNavigationManager()->GetVisibleItem()->GetURL(); 93 current_tab.webState->GetNavigationManager()->GetVisibleItem()->GetURL();
89 if (reading_list::IsOfflineURL(url) && 94 if (reading_list::IsOfflineURL(url) &&
90 GetSecurityLevel(true /*ignore_editing*/) == 95 GetSecurityLevel(true /*ignore_editing*/) ==
91 security_state::SecurityLevel::NONE) { 96 security_state::SecurityLevel::NONE) {
92 size_t removed = 0; 97 size_t removed = 0;
93 formatted_url = 98 formatted_url =
94 reading_list::StripSchemeFromOnlineURL(formatted_url, &removed); 99 reading_list::StripSchemeFromOnlineURL(formatted_url, &removed);
95 if (prefix_end) { 100 if (prefix_end) {
96 *prefix_end -= removed; 101 *prefix_end -= removed;
(...skipping 19 matching lines...) Expand all
116 return toolbar_model_->GetSecureVerboseText(); 121 return toolbar_model_->GetSecureVerboseText();
117 } 122 }
118 123
119 base::string16 ToolbarModelImplIOS::GetEVCertName() const { 124 base::string16 ToolbarModelImplIOS::GetEVCertName() const {
120 return toolbar_model_->GetEVCertName(); 125 return toolbar_model_->GetEVCertName();
121 } 126 }
122 127
123 bool ToolbarModelImplIOS::ShouldDisplayURL() const { 128 bool ToolbarModelImplIOS::ShouldDisplayURL() const {
124 return toolbar_model_->ShouldDisplayURL(); 129 return toolbar_model_->ShouldDisplayURL();
125 } 130 }
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