| 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/frame/web_app_left_header_view_ash.h" | 5 #include "chrome/browser/ui/views/frame/web_app_left_header_view_ash.h" |
| 6 | 6 |
| 7 #include "ash/frame/caption_buttons/frame_caption_button.h" | 7 #include "ash/frame/caption_buttons/frame_caption_button.h" |
| 8 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 8 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 10 #include "chrome/browser/ssl/chrome_security_state_model_client.h" |
| 11 #include "chrome/browser/ui/browser_commands.h" | 11 #include "chrome/browser/ui/browser_commands.h" |
| 12 #include "chrome/browser/ui/views/frame/browser_view.h" | 12 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 13 #include "components/toolbar/toolbar_model.h" | 13 #include "components/toolbar/toolbar_model.h" |
| 14 #include "content/public/browser/navigation_entry.h" | 14 #include "content/public/browser/navigation_entry.h" |
| 15 #include "grit/ash_resources.h" | 15 #include "grit/ash_resources.h" |
| 16 #include "ui/gfx/vector_icons_public.h" |
| 16 #include "ui/views/layout/box_layout.h" | 17 #include "ui/views/layout/box_layout.h" |
| 17 | 18 |
| 18 // static | 19 // static |
| 19 const char WebAppLeftHeaderView::kViewClassName[] = "WebAppLeftHeaderView"; | 20 const char WebAppLeftHeaderView::kViewClassName[] = "WebAppLeftHeaderView"; |
| 20 | 21 |
| 21 WebAppLeftHeaderView::WebAppLeftHeaderView(BrowserView* browser_view) | 22 WebAppLeftHeaderView::WebAppLeftHeaderView(BrowserView* browser_view) |
| 22 : browser_view_(browser_view) { | 23 : browser_view_(browser_view) { |
| 23 SetLayoutManager( | 24 SetLayoutManager( |
| 24 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 25 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 25 | 26 |
| 26 back_button_ = | 27 back_button_ = |
| 27 new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_BACK); | 28 new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_BACK); |
| 28 back_button_->SetImage(ash::CAPTION_BUTTON_ICON_BACK, | 29 back_button_->SetImage(ash::CAPTION_BUTTON_ICON_BACK, |
| 29 ash::FrameCaptionButton::ANIMATE_NO, | 30 ash::FrameCaptionButton::ANIMATE_NO, |
| 30 IDR_AURA_WINDOW_CONTROL_ICON_BACK); | 31 gfx::VectorIconId::WINDOW_CONTROL_BACK); |
| 31 AddChildView(back_button_); | 32 AddChildView(back_button_); |
| 32 | 33 |
| 33 location_icon_ = | 34 location_icon_ = |
| 34 new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_LOCATION); | 35 new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_LOCATION); |
| 35 AddChildView(location_icon_); | 36 AddChildView(location_icon_); |
| 36 | 37 |
| 37 Update(); | 38 Update(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 WebAppLeftHeaderView::~WebAppLeftHeaderView() { | 41 WebAppLeftHeaderView::~WebAppLeftHeaderView() { |
| 41 } | 42 } |
| 42 | 43 |
| 43 void WebAppLeftHeaderView::Update() { | 44 void WebAppLeftHeaderView::Update() { |
| 44 int icon_resource = browser_view_->browser()->toolbar_model()->GetIcon(); | 45 location_icon_->SetImage( |
| 45 location_icon_->SetImage(ash::CAPTION_BUTTON_ICON_LOCATION, | 46 ash::CAPTION_BUTTON_ICON_LOCATION, ash::FrameCaptionButton::ANIMATE_NO, |
| 46 ash::FrameCaptionButton::ANIMATE_NO, | 47 browser_view_->browser()->toolbar_model()->GetVectorIcon()); |
| 47 icon_resource); | |
| 48 | 48 |
| 49 back_button_->SetState( | 49 back_button_->SetState( |
| 50 chrome::IsCommandEnabled(browser_view_->browser(), IDC_BACK) | 50 chrome::IsCommandEnabled(browser_view_->browser(), IDC_BACK) |
| 51 ? views::Button::STATE_NORMAL | 51 ? views::Button::STATE_NORMAL |
| 52 : views::Button::STATE_DISABLED); | 52 : views::Button::STATE_DISABLED); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void WebAppLeftHeaderView::SetPaintAsActive(bool active) { | 55 void WebAppLeftHeaderView::SetPaintAsActive(bool active) { |
| 56 // TODO(benwells): Check that the disabled and inactive states should be | 56 // TODO(benwells): Check that the disabled and inactive states should be |
| 57 // drawn in the same way. | 57 // drawn in the same way. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 return; | 90 return; |
| 91 | 91 |
| 92 ChromeSecurityStateModelClient* security_model_client = | 92 ChromeSecurityStateModelClient* security_model_client = |
| 93 ChromeSecurityStateModelClient::FromWebContents(tab); | 93 ChromeSecurityStateModelClient::FromWebContents(tab); |
| 94 DCHECK(security_model_client); | 94 DCHECK(security_model_client); |
| 95 | 95 |
| 96 chrome::ShowWebsiteSettings(browser_view_->browser(), tab, | 96 chrome::ShowWebsiteSettings(browser_view_->browser(), tab, |
| 97 nav_entry->GetURL(), | 97 nav_entry->GetURL(), |
| 98 security_model_client->GetSecurityInfo()); | 98 security_model_client->GetSecurityInfo()); |
| 99 } | 99 } |
| OLD | NEW |