| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/location_bar/origin_chip_view.h" | 5 #include "chrome/browser/ui/views/location_bar/origin_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/metrics/histogram.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | |
| 13 #include "chrome/browser/extensions/extension_util.h" | 12 #include "chrome/browser/extensions/extension_util.h" |
| 14 #include "chrome/browser/favicon/favicon_tab_helper.h" | 13 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 17 #include "chrome/browser/safe_browsing/ui_manager.h" | 16 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 18 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
| 19 #include "chrome/browser/themes/theme_properties.h" | 18 #include "chrome/browser/themes/theme_properties.h" |
| 20 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/elide_url.h" | 20 #include "chrome/browser/ui/elide_url.h" |
| 22 #include "chrome/browser/ui/location_bar/origin_chip_info.h" | 21 #include "chrome/browser/ui/location_bar/origin_chip_info.h" |
| 23 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 22 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 24 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 23 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
| 25 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 24 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 26 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
| 27 #include "content/public/browser/user_metrics.h" | 26 #include "content/public/browser/user_metrics.h" |
| 28 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 29 #include "content/public/common/url_constants.h" | 28 #include "content/public/common/url_constants.h" |
| 30 #include "extensions/browser/extension_icon_image.h" | 29 #include "extensions/browser/extension_icon_image.h" |
| 31 #include "extensions/browser/extension_system.h" | 30 #include "extensions/browser/extension_registry.h" |
| 32 #include "extensions/common/constants.h" | 31 #include "extensions/common/constants.h" |
| 33 #include "extensions/common/manifest_handlers/icons_handler.h" | 32 #include "extensions/common/manifest_handlers/icons_handler.h" |
| 34 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
| 35 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
| 36 #include "ui/base/theme_provider.h" | 35 #include "ui/base/theme_provider.h" |
| 37 #include "ui/gfx/canvas.h" | 36 #include "ui/gfx/canvas.h" |
| 38 #include "ui/gfx/font_list.h" | 37 #include "ui/gfx/font_list.h" |
| 39 #include "ui/gfx/text_utils.h" | 38 #include "ui/gfx/text_utils.h" |
| 40 #include "ui/views/background.h" | 39 #include "ui/views/background.h" |
| 41 #include "ui/views/controls/button/label_button.h" | 40 #include "ui/views/controls/button/label_button.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 119 |
| 121 const int kEVImages[3][9] = { | 120 const int kEVImages[3][9] = { |
| 122 IMAGE_GRID(IDR_ORIGIN_CHIP_EV_NORMAL), | 121 IMAGE_GRID(IDR_ORIGIN_CHIP_EV_NORMAL), |
| 123 IMAGE_GRID(IDR_ORIGIN_CHIP_EV_HOVER), | 122 IMAGE_GRID(IDR_ORIGIN_CHIP_EV_HOVER), |
| 124 IMAGE_GRID(IDR_ORIGIN_CHIP_EV_PRESSED) | 123 IMAGE_GRID(IDR_ORIGIN_CHIP_EV_PRESSED) |
| 125 }; | 124 }; |
| 126 | 125 |
| 127 const extensions::Extension* GetExtension(const GURL& url, Profile* profile) { | 126 const extensions::Extension* GetExtension(const GURL& url, Profile* profile) { |
| 128 if (!url.SchemeIs(extensions::kExtensionScheme)) | 127 if (!url.SchemeIs(extensions::kExtensionScheme)) |
| 129 return NULL; | 128 return NULL; |
| 130 ExtensionService* service = | 129 extensions::ExtensionRegistry* registry = |
| 131 extensions::ExtensionSystem::Get(profile)->extension_service(); | 130 extensions::ExtensionRegistry::Get(profile); |
| 132 return service->extensions()->GetExtensionOrAppByURL(url); | 131 return registry->GetExtensionById(url.host(), |
| 132 extensions::ExtensionRegistry::ENABLED); |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace | 135 } // namespace |
| 136 | 136 |
| 137 OriginChipView::OriginChipView(LocationBarView* location_bar_view, | 137 OriginChipView::OriginChipView(LocationBarView* location_bar_view, |
| 138 Profile* profile, | 138 Profile* profile, |
| 139 const gfx::FontList& font_list) | 139 const gfx::FontList& font_list) |
| 140 : LabelButton(this, base::string16()), | 140 : LabelButton(this, base::string16()), |
| 141 location_bar_view_(location_bar_view), | 141 location_bar_view_(location_bar_view), |
| 142 profile_(profile), | 142 profile_(profile), |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 | 407 |
| 408 // Note: When OnSafeBrowsingHit would be called, OnSafeBrowsingMatch will | 408 // Note: When OnSafeBrowsingHit would be called, OnSafeBrowsingMatch will |
| 409 // have already been called. | 409 // have already been called. |
| 410 void OriginChipView::OnSafeBrowsingHit( | 410 void OriginChipView::OnSafeBrowsingHit( |
| 411 const SafeBrowsingUIManager::UnsafeResource& resource) {} | 411 const SafeBrowsingUIManager::UnsafeResource& resource) {} |
| 412 | 412 |
| 413 void OriginChipView::OnSafeBrowsingMatch( | 413 void OriginChipView::OnSafeBrowsingMatch( |
| 414 const SafeBrowsingUIManager::UnsafeResource& resource) { | 414 const SafeBrowsingUIManager::UnsafeResource& resource) { |
| 415 OnChanged(); | 415 OnChanged(); |
| 416 } | 416 } |
| OLD | NEW |