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

Side by Side Diff: chrome/browser/page_info_model.cc

Issue 3519016: Enable the new page info bubble by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/page_info_model.h" 5 #include "chrome/browser/page_info_model.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, 175 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
176 subject_name, 176 subject_name,
177 base::IntToString16(ssl.security_bits()))); 177 base::IntToString16(ssl.security_bits())));
178 if (ssl.displayed_insecure_content() || ssl.ran_insecure_content()) { 178 if (ssl.displayed_insecure_content() || ssl.ran_insecure_content()) {
179 // The old SSL dialog only had good and bad state, so for the old 179 // The old SSL dialog only had good and bad state, so for the old
180 // implementation we raise an error on finding mixed content. The new 180 // implementation we raise an error on finding mixed content. The new
181 // SSL info bubble has a warning state for displaying insecure content, 181 // SSL info bubble has a warning state for displaying insecure content,
182 // so we check. The command line check will go away once we eliminate 182 // so we check. The command line check will go away once we eliminate
183 // the old dialogs. 183 // the old dialogs.
184 const CommandLine* command_line(CommandLine::ForCurrentProcess()); 184 const CommandLine* command_line(CommandLine::ForCurrentProcess());
185 if (command_line->HasSwitch(switches::kEnableNewPageInfoBubble) && 185 if (!command_line->HasSwitch(switches::kDisableNewPageInfoBubble) &&
186 !ssl.ran_insecure_content()) { 186 !ssl.ran_insecure_content()) {
187 icon_id = ICON_STATE_WARNING_MINOR; 187 icon_id = ICON_STATE_WARNING_MINOR;
188 } else { 188 } else {
189 icon_id = ICON_STATE_ERROR; 189 icon_id = ICON_STATE_ERROR;
190 } 190 }
191 description.assign(l10n_util::GetStringFUTF16( 191 description.assign(l10n_util::GetStringFUTF16(
192 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, 192 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
193 description, 193 description,
194 l10n_util::GetStringUTF16(ssl.ran_insecure_content() ? 194 l10n_util::GetStringUTF16(ssl.ran_insecure_content() ?
195 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR : 195 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR :
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 PageInfoModel::SectionInfo PageInfoModel::GetSectionInfo(int index) { 278 PageInfoModel::SectionInfo PageInfoModel::GetSectionInfo(int index) {
279 DCHECK(index < static_cast<int>(sections_.size())); 279 DCHECK(index < static_cast<int>(sections_.size()));
280 return sections_[index]; 280 return sections_[index];
281 } 281 }
282 282
283 gfx::NativeImage PageInfoModel::GetIconImage(SectionStateIcon icon_id) { 283 gfx::NativeImage PageInfoModel::GetIconImage(SectionStateIcon icon_id) {
284 if (icon_id == ICON_NONE) 284 if (icon_id == ICON_NONE)
285 return NULL; 285 return NULL;
286 // TODO(rsesek): Remove once the window is replaced with the bubble. 286 // TODO(rsesek): Remove once the window is replaced with the bubble.
287 const CommandLine* command_line(CommandLine::ForCurrentProcess()); 287 const CommandLine* command_line(CommandLine::ForCurrentProcess());
288 if (!command_line->HasSwitch(switches::kEnableNewPageInfoBubble) && 288 if (command_line->HasSwitch(switches::kDisableNewPageInfoBubble) &&
289 icon_id != ICON_STATE_OK) { 289 icon_id != ICON_STATE_OK) {
290 return icons_[ICON_STATE_WARNING_MAJOR]; 290 return icons_[ICON_STATE_WARNING_MAJOR];
291 } 291 }
292 // The buble uses new, various icons. 292 // The bubble uses new, various icons.
293 return icons_[icon_id]; 293 return icons_[icon_id];
294 } 294 }
295 295
296 void PageInfoModel::OnGotVisitCountToHost(HistoryService::Handle handle, 296 void PageInfoModel::OnGotVisitCountToHost(HistoryService::Handle handle,
297 bool found_visits, 297 bool found_visits,
298 int count, 298 int count,
299 base::Time first_visit) { 299 base::Time first_visit) {
300 if (!found_visits) { 300 if (!found_visits) {
301 // This indicates an error, such as the page wasn't http/https; do nothing. 301 // This indicates an error, such as the page wasn't http/https; do nothing.
302 return; 302 return;
303 } 303 }
304 304
305 bool visited_before_today = false; 305 bool visited_before_today = false;
306 if (count) { 306 if (count) {
307 base::Time today = base::Time::Now().LocalMidnight(); 307 base::Time today = base::Time::Now().LocalMidnight();
308 base::Time first_visit_midnight = first_visit.LocalMidnight(); 308 base::Time first_visit_midnight = first_visit.LocalMidnight();
309 visited_before_today = (first_visit_midnight < today); 309 visited_before_today = (first_visit_midnight < today);
310 } 310 }
311 311
312 // We only show the Site Information heading for the new dialogs. 312 // We only show the Site Information heading for the new dialogs.
313 string16 title; 313 string16 title;
314 const CommandLine* command_line(CommandLine::ForCurrentProcess()); 314 const CommandLine* command_line(CommandLine::ForCurrentProcess());
315 bool as_bubble = command_line->HasSwitch(switches::kEnableNewPageInfoBubble); 315 bool as_bubble = !command_line->HasSwitch(
316 switches::kDisableNewPageInfoBubble);
316 if (as_bubble) 317 if (as_bubble)
317 title = l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE); 318 title = l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE);
318 319
319 if (!visited_before_today) { 320 if (!visited_before_today) {
320 sections_.push_back(SectionInfo( 321 sections_.push_back(SectionInfo(
321 ICON_STATE_WARNING_MAJOR, 322 ICON_STATE_WARNING_MAJOR,
322 l10n_util::GetStringUTF16( 323 l10n_util::GetStringUTF16(
323 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), 324 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE),
324 title, 325 title,
325 l10n_util::GetStringUTF16( 326 l10n_util::GetStringUTF16(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 gfx::NativeImage PageInfoModel::GetBitmapNamed(int resource_id) { 363 gfx::NativeImage PageInfoModel::GetBitmapNamed(int resource_id) {
363 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 364 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
364 gfx::NativeImage image = rb.GetNativeImageNamed(resource_id); 365 gfx::NativeImage image = rb.GetNativeImageNamed(resource_id);
365 #if defined(OS_MACOSX) 366 #if defined(OS_MACOSX)
366 // Unlike other platforms, the Mac ResourceBundle does not keep a shared image 367 // Unlike other platforms, the Mac ResourceBundle does not keep a shared image
367 // cache. These are released in the dtor. 368 // cache. These are released in the dtor.
368 mac_util::NSObjectRetain(image); 369 mac_util::NSObjectRetain(image);
369 #endif 370 #endif
370 return image; 371 return image;
371 } 372 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698