| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/views/location_bar/location_icon_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 8 #include "chrome/browser/ssl/chrome_security_state_model_client.h" |
| 9 #include "chrome/browser/ui/view_ids.h" | 9 #include "chrome/browser/ui/view_ids.h" |
| 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 11 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" | 11 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" |
| 12 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
| 13 #include "content/public/browser/navigation_controller.h" | 13 #include "content/public/browser/navigation_controller.h" |
| 14 #include "content/public/browser/navigation_entry.h" | 14 #include "content/public/browser/navigation_entry.h" |
| 15 #include "content/public/browser/render_frame_host.h" |
| 15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 16 #include "grit/components_scaled_resources.h" | 17 #include "grit/components_scaled_resources.h" |
| 17 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/material_design/material_design_controller.h" | 20 #include "ui/base/material_design/material_design_controller.h" |
| 20 #include "ui/gfx/color_palette.h" | 21 #include "ui/gfx/color_palette.h" |
| 21 #include "ui/views/controls/label.h" | 22 #include "ui/views/controls/label.h" |
| 22 #include "ui/views/painter.h" | 23 #include "ui/views/painter.h" |
| 24 #include "url/origin.h" |
| 23 | 25 |
| 24 using content::NavigationController; | 26 using content::NavigationController; |
| 25 using content::NavigationEntry; | 27 using content::NavigationEntry; |
| 26 using content::WebContents; | 28 using content::WebContents; |
| 27 | 29 |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| 30 void ProcessEventInternal(LocationBarView* view) { | 32 void ProcessEventInternal(LocationBarView* view) { |
| 31 WebContents* contents = view->GetWebContents(); | 33 WebContents* contents = view->GetWebContents(); |
| 32 if (!contents) | 34 if (!contents) |
| 33 return; | 35 return; |
| 34 | 36 |
| 35 // Important to use GetVisibleEntry to match what's showing in the omnibox. | 37 // Important to use GetVisibleEntry to match what's showing in the omnibox. |
| 36 NavigationEntry* entry = contents->GetController().GetVisibleEntry(); | 38 NavigationEntry* entry = contents->GetController().GetVisibleEntry(); |
| 37 // The visible entry can be nullptr in the case of window.open(""). | 39 |
| 38 if (!entry) | 40 // Show the origin if it's not unique, and otherwise fall back to the URL. |
| 39 return; | 41 // |
| 42 // TODO(palmer): Should we show the "this is a secure Chromium page" |
| 43 // OIB when origin is unique and there is no last committed origin? |
| 44 url::Origin origin = entry |
| 45 ? entry->GetOrigin() |
| 46 : contents->GetMainFrame()->GetLastCommittedOrigin(); |
| 47 GURL url(origin.Serialize()); |
| 48 if (entry && origin.unique()) { |
| 49 url = GURL(contents->GetMainFrame()->GetLastCommittedOrigin().Serialize()); |
| 50 } |
| 40 | 51 |
| 41 ChromeSecurityStateModelClient* model_client = | 52 ChromeSecurityStateModelClient* model_client = |
| 42 ChromeSecurityStateModelClient::FromWebContents(contents); | 53 ChromeSecurityStateModelClient::FromWebContents(contents); |
| 43 DCHECK(model_client); | 54 DCHECK(model_client); |
| 44 | 55 |
| 45 view->delegate()->ShowWebsiteSettings(contents, entry->GetURL(), | 56 // TODO(palmer): Change ShowWebsiteSettings to take an Origin, rather than a |
| 57 // GURL. |
| 58 view->delegate()->ShowWebsiteSettings(contents, url, |
| 46 model_client->GetSecurityInfo()); | 59 model_client->GetSecurityInfo()); |
| 47 } | 60 } |
| 48 | 61 |
| 49 } // namespace | 62 } // namespace |
| 50 | 63 |
| 51 LocationIconView::LocationIconView(const gfx::FontList& font_list, | 64 LocationIconView::LocationIconView(const gfx::FontList& font_list, |
| 52 SkColor parent_background_color, | 65 SkColor parent_background_color, |
| 53 LocationBarView* location_bar) | 66 LocationBarView* location_bar) |
| 54 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_INVALID, | 67 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_INVALID, |
| 55 font_list, | 68 font_list, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 return size; | 184 return size; |
| 172 } | 185 } |
| 173 | 186 |
| 174 void LocationIconView::SetBackground(bool should_show_ev) { | 187 void LocationIconView::SetBackground(bool should_show_ev) { |
| 175 static const int kEvBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); | 188 static const int kEvBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); |
| 176 if (should_show_ev) | 189 if (should_show_ev) |
| 177 SetBackgroundImageGrid(kEvBackgroundImages); | 190 SetBackgroundImageGrid(kEvBackgroundImages); |
| 178 else | 191 else |
| 179 UnsetBackgroundImageGrid(); | 192 UnsetBackgroundImageGrid(); |
| 180 } | 193 } |
| OLD | NEW |