| 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/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| 11 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 11 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
| 12 #include "chrome/browser/ui/views/frame/browser_view.h" | 12 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 13 #include "content/public/browser/navigation_entry.h" | 13 #include "content/public/browser/navigation_entry.h" |
| 14 #include "grit/ash_resources.h" | 14 #include "grit/ash_resources.h" |
| 15 #include "ui/views/layout/box_layout.h" | 15 #include "ui/views/layout/box_layout.h" |
| 16 | 16 |
| 17 // static | 17 // static |
| 18 const char WebAppLeftHeaderView::kViewClassName[] = "WebAppLeftHeaderView"; | 18 const char WebAppLeftHeaderView::kViewClassName[] = "WebAppLeftHeaderView"; |
| 19 | 19 |
| 20 WebAppLeftHeaderView::WebAppLeftHeaderView(BrowserView* browser_view) | 20 WebAppLeftHeaderView::WebAppLeftHeaderView(BrowserView* browser_view) |
| 21 : browser_view_(browser_view) { | 21 : browser_view_(browser_view) { |
| 22 SetLayoutManager( | 22 SetLayoutManager( |
| 23 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 23 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 24 | 24 |
| 25 back_button_ = | 25 back_button_ = |
| 26 new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_BACK); | 26 new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_BACK); |
| 27 back_button_->SetImages( | 27 back_button_->SetImages( |
| 28 ash::CAPTION_BUTTON_ICON_BACK, ash::FrameCaptionButton::ANIMATE_NO, | 28 ash::CAPTION_BUTTON_ICON_BACK, ash::FrameCaptionButton::ANIMATE_NO, |
| 29 IDR_AURA_WINDOW_CONTROL_ICON_BACK, IDR_AURA_WINDOW_CONTROL_ICON_BACK_I, | 29 IDR_AURA_WINDOW_CONTROL_ICON_BACK, IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, |
| 30 IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, | |
| 31 IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); | 30 IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); |
| 32 AddChildView(back_button_); | 31 AddChildView(back_button_); |
| 33 | 32 |
| 34 location_icon_ = | 33 location_icon_ = |
| 35 new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_LOCATION); | 34 new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_LOCATION); |
| 36 AddChildView(location_icon_); | 35 AddChildView(location_icon_); |
| 37 | 36 |
| 38 Update(); | 37 Update(); |
| 39 } | 38 } |
| 40 | 39 |
| 41 WebAppLeftHeaderView::~WebAppLeftHeaderView() { | 40 WebAppLeftHeaderView::~WebAppLeftHeaderView() { |
| 42 } | 41 } |
| 43 | 42 |
| 44 void WebAppLeftHeaderView::Update() { | 43 void WebAppLeftHeaderView::Update() { |
| 45 int icon_resource = browser_view_->browser()->toolbar_model()->GetIcon(); | 44 int icon_resource = browser_view_->browser()->toolbar_model()->GetIcon(); |
| 46 location_icon_->SetImages( | 45 location_icon_->SetImages(ash::CAPTION_BUTTON_ICON_LOCATION, |
| 47 ash::CAPTION_BUTTON_ICON_LOCATION, ash::FrameCaptionButton::ANIMATE_NO, | 46 ash::FrameCaptionButton::ANIMATE_NO, icon_resource, |
| 48 icon_resource, icon_resource, IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, | 47 IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, |
| 49 IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); | 48 IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); |
| 50 | 49 |
| 51 back_button_->SetState( | 50 back_button_->SetState( |
| 52 chrome::IsCommandEnabled(browser_view_->browser(), IDC_BACK) | 51 chrome::IsCommandEnabled(browser_view_->browser(), IDC_BACK) |
| 53 ? views::Button::STATE_NORMAL | 52 ? views::Button::STATE_NORMAL |
| 54 : views::Button::STATE_DISABLED); | 53 : views::Button::STATE_DISABLED); |
| 55 } | 54 } |
| 56 | 55 |
| 57 void WebAppLeftHeaderView::SetPaintAsActive(bool active) { | 56 void WebAppLeftHeaderView::SetPaintAsActive(bool active) { |
| 58 // TODO(benwells): Check that the disabled and inactive states should be | 57 // TODO(benwells): Check that the disabled and inactive states should be |
| 59 // drawn in the same way. | 58 // drawn in the same way. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 87 | 86 |
| 88 // Important to use GetVisibleEntry to match what's showing in the title area. | 87 // Important to use GetVisibleEntry to match what's showing in the title area. |
| 89 content::NavigationEntry* nav_entry = tab->GetController().GetVisibleEntry(); | 88 content::NavigationEntry* nav_entry = tab->GetController().GetVisibleEntry(); |
| 90 // The visible entry can be NULL in the case of window.open(""). | 89 // The visible entry can be NULL in the case of window.open(""). |
| 91 if (!nav_entry) | 90 if (!nav_entry) |
| 92 return; | 91 return; |
| 93 | 92 |
| 94 chrome::ShowWebsiteSettings(browser_view_->browser(), tab, | 93 chrome::ShowWebsiteSettings(browser_view_->browser(), tab, |
| 95 nav_entry->GetURL(), nav_entry->GetSSL()); | 94 nav_entry->GetURL(), nav_entry->GetSSL()); |
| 96 } | 95 } |
| OLD | NEW |