| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mandoline/ui/desktop_ui/toolbar_view.h" | |
| 6 | |
| 7 #include "base/strings/string16.h" | |
| 8 #include "base/strings/utf_string_conversions.h" | |
| 9 #include "mandoline/ui/desktop_ui/browser_window.h" | |
| 10 #include "ui/views/layout/box_layout.h" | |
| 11 | |
| 12 namespace mandoline { | |
| 13 | |
| 14 ToolbarView::ToolbarView(BrowserWindow* browser_window) | |
| 15 : browser_window_(browser_window), | |
| 16 layout_(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 5)), | |
| 17 back_button_(new views::LabelButton(this, base::ASCIIToUTF16("Back"))), | |
| 18 forward_button_( | |
| 19 new views::LabelButton(this, base::ASCIIToUTF16("Forward"))), | |
| 20 omnibox_launcher_( | |
| 21 new views::LabelButton(this, base::ASCIIToUTF16("Open Omnibox"))) { | |
| 22 SetLayoutManager(layout_); | |
| 23 | |
| 24 AddChildView(back_button_); | |
| 25 AddChildView(forward_button_); | |
| 26 AddChildView(omnibox_launcher_); | |
| 27 | |
| 28 layout_->SetDefaultFlex(0); | |
| 29 layout_->SetFlexForView(omnibox_launcher_, 1); | |
| 30 } | |
| 31 | |
| 32 ToolbarView::~ToolbarView() {} | |
| 33 | |
| 34 void ToolbarView::SetOmniboxText(const base::string16& text) { | |
| 35 omnibox_launcher_->SetText(text); | |
| 36 } | |
| 37 | |
| 38 void ToolbarView::SetBackForwardEnabled(bool back_enabled, | |
| 39 bool forward_enabled) { | |
| 40 back_button_->SetEnabled(back_enabled); | |
| 41 forward_button_->SetEnabled(forward_enabled); | |
| 42 } | |
| 43 | |
| 44 void ToolbarView::ButtonPressed(views::Button* sender, const ui::Event& event) { | |
| 45 if (sender == omnibox_launcher_) | |
| 46 browser_window_->ShowOmnibox(); | |
| 47 else if (sender == back_button_) | |
| 48 browser_window_->GoBack(); | |
| 49 else if (sender == forward_button_) | |
| 50 browser_window_->GoForward(); | |
| 51 else | |
| 52 NOTREACHED(); | |
| 53 } | |
| 54 | |
| 55 } // namespace mandoline | |
| OLD | NEW |