Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/views/toolbar/site_chip_view.h" | 5 #include "chrome/browser/ui/views/toolbar/site_chip_view.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/metrics/histogram.h" | |
| 8 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/extensions/extension_icon_image.h" | 13 #include "chrome/browser/extensions/extension_icon_image.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/extension_system.h" | 15 #include "chrome/browser/extensions/extension_system.h" |
| 15 #include "chrome/browser/favicon/favicon_tab_helper.h" | 16 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/safe_browsing/client_side_detection_host.h" | 18 #include "chrome/browser/safe_browsing/client_side_detection_host.h" |
| 18 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 19 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 19 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" | 20 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" |
| 20 #include "chrome/browser/safe_browsing/ui_manager.h" | 21 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 21 #include "chrome/browser/search/search.h" | 22 #include "chrome/browser/search/search.h" |
| 22 #include "chrome/browser/themes/theme_properties.h" | 23 #include "chrome/browser/themes/theme_properties.h" |
| 23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 25 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 25 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 26 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
| 26 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 27 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 27 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 28 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 28 #include "chrome/common/extensions/extension_constants.h" | 29 #include "chrome/common/extensions/extension_constants.h" |
| 29 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | 30 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
| 30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
| 33 #include "content/public/browser/user_metrics.h" | |
| 32 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 33 #include "content/public/common/url_constants.h" | 35 #include "content/public/common/url_constants.h" |
| 34 #include "extensions/common/constants.h" | 36 #include "extensions/common/constants.h" |
| 35 #include "grit/component_strings.h" | 37 #include "grit/component_strings.h" |
| 36 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
| 37 #include "grit/theme_resources.h" | 39 #include "grit/theme_resources.h" |
| 38 #include "net/base/net_util.h" | 40 #include "net/base/net_util.h" |
| 39 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
| 40 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
| 41 #include "ui/base/theme_provider.h" | 43 #include "ui/base/theme_provider.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 if (icon_view_) | 96 if (icon_view_) |
| 95 icon_view_->SetImage(&icon_image_->image_skia()); | 97 icon_view_->SetImage(&icon_image_->image_skia()); |
| 96 } | 98 } |
| 97 | 99 |
| 98 | 100 |
| 99 // SiteChipView --------------------------------------------------------------- | 101 // SiteChipView --------------------------------------------------------------- |
| 100 | 102 |
| 101 namespace { | 103 namespace { |
| 102 | 104 |
| 103 const int kEdgeThickness = 5; | 105 const int kEdgeThickness = 5; |
| 104 const int k16x16IconLeadingSpacing = 3; | 106 const int k16x16IconLeadingSpacing = 1; |
| 105 const int k16x16IconTrailingSpacing = 3; | 107 const int k16x16IconTrailingSpacing = 2; |
|
Greg Billock
2013/12/12 20:36:37
This repairs a bad merge I must have made at some
| |
| 106 const int kIconTextSpacing = 3; | 108 const int kIconTextSpacing = 3; |
| 107 const int kTrailingLabelMargin = 0; | 109 const int kTrailingLabelMargin = 0; |
| 108 | 110 |
| 109 // Detect client-side or SB malware/phishing hits. | 111 // Detect client-side or SB malware/phishing hits. |
| 110 bool IsMalware(const GURL& url, content::WebContents* tab) { | 112 bool IsMalware(const GURL& url, content::WebContents* tab) { |
| 111 if (tab->GetURL() != url) | 113 if (tab->GetURL() != url) |
| 112 return false; | 114 return false; |
| 113 | 115 |
| 114 safe_browsing::SafeBrowsingTabObserver* sb_observer = | 116 safe_browsing::SafeBrowsingTabObserver* sb_observer = |
| 115 safe_browsing::SafeBrowsingTabObserver::FromWebContents(tab); | 117 safe_browsing::SafeBrowsingTabObserver::FromWebContents(tab); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 if (painter_) | 435 if (painter_) |
| 434 views::Painter::PaintPainterAt(canvas, painter_, rect); | 436 views::Painter::PaintPainterAt(canvas, painter_, rect); |
| 435 | 437 |
| 436 ToolbarButton::OnPaint(canvas); | 438 ToolbarButton::OnPaint(canvas); |
| 437 } | 439 } |
| 438 | 440 |
| 439 // TODO(gbillock): Make the LocationBarView or OmniboxView the listener for | 441 // TODO(gbillock): Make the LocationBarView or OmniboxView the listener for |
| 440 // this button. | 442 // this button. |
| 441 void SiteChipView::ButtonPressed(views::Button* sender, | 443 void SiteChipView::ButtonPressed(views::Button* sender, |
| 442 const ui::Event& event) { | 444 const ui::Event& event) { |
| 445 UMA_HISTOGRAM_COUNTS("SiteChip.Pressed", 1); | |
|
msw
2013/12/12 21:09:54
Is this worthwhile if you'll have the SiteChipPres
Greg Billock
2013/12/12 21:55:31
I'm not sure. I thought the user actions just go i
| |
| 446 content::RecordAction(content::UserMetricsAction("SiteChipPress")); | |
|
msw
2013/12/12 21:09:54
According to the guide: https://wiki.corp.google.c
Greg Billock
2013/12/12 21:55:31
Thanks. I haven't used these user actions before.
| |
| 443 toolbar_view_->location_bar()->GetOmniboxView()->SetFocus(); | 447 toolbar_view_->location_bar()->GetOmniboxView()->SetFocus(); |
| 444 toolbar_view_->location_bar()->GetOmniboxView()->SelectAll(true); | |
| 445 toolbar_view_->location_bar()->GetOmniboxView()->model()-> | 448 toolbar_view_->location_bar()->GetOmniboxView()->model()-> |
| 446 SetCaretVisibility(true); | 449 SetCaretVisibility(true); |
| 450 toolbar_view_->location_bar()->GetOmniboxView()->ShowURL(); | |
| 447 } | 451 } |
| 448 | 452 |
| 449 void SiteChipView::WriteDragDataForView(View* sender, | 453 void SiteChipView::WriteDragDataForView(View* sender, |
| 450 const gfx::Point& press_pt, | 454 const gfx::Point& press_pt, |
| 451 OSExchangeData* data) { | 455 OSExchangeData* data) { |
| 452 // TODO(gbillock): Consolidate this with the identical logic in | 456 // TODO(gbillock): Consolidate this with the identical logic in |
| 453 // LocationBarView. | 457 // LocationBarView. |
| 454 content::WebContents* web_contents = toolbar_view_->GetWebContents(); | 458 content::WebContents* web_contents = toolbar_view_->GetWebContents(); |
| 455 FaviconTabHelper* favicon_tab_helper = | 459 FaviconTabHelper* favicon_tab_helper = |
| 456 FaviconTabHelper::FromWebContents(web_contents); | 460 FaviconTabHelper::FromWebContents(web_contents); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 476 // Note: When OnSafeBrowsingHit would be called, OnSafeBrowsingMatch will | 480 // Note: When OnSafeBrowsingHit would be called, OnSafeBrowsingMatch will |
| 477 // have already been called. | 481 // have already been called. |
| 478 void SiteChipView::OnSafeBrowsingHit( | 482 void SiteChipView::OnSafeBrowsingHit( |
| 479 const SafeBrowsingUIManager::UnsafeResource& resource) {} | 483 const SafeBrowsingUIManager::UnsafeResource& resource) {} |
| 480 | 484 |
| 481 void SiteChipView::OnSafeBrowsingMatch( | 485 void SiteChipView::OnSafeBrowsingMatch( |
| 482 const SafeBrowsingUIManager::UnsafeResource& resource) { | 486 const SafeBrowsingUIManager::UnsafeResource& resource) { |
| 483 OnChanged(); | 487 OnChanged(); |
| 484 } | 488 } |
| 485 | 489 |
| OLD | NEW |