| 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 "mojo/examples/window_manager/debug_panel.h" | 5 #include "mojo/examples/window_manager/debug_panel.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "mojo/services/public/cpp/view_manager/view.h" | 9 #include "mojo/services/public/cpp/view_manager/view.h" |
| 10 #include "mojo/views/native_widget_view_manager.h" | 10 #include "mojo/views/native_widget_view_manager.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 : delegate_(delegate), | 28 : delegate_(delegate), |
| 29 view_(view), | 29 view_(view), |
| 30 navigation_target_label_(new views::Label( | 30 navigation_target_label_(new views::Label( |
| 31 base::ASCIIToUTF16("Navigation target:"))), | 31 base::ASCIIToUTF16("Navigation target:"))), |
| 32 navigation_target_new_(new views::RadioButton( | 32 navigation_target_new_(new views::RadioButton( |
| 33 base::ASCIIToUTF16("New window"), kNavigationTargetGroupId)), | 33 base::ASCIIToUTF16("New window"), kNavigationTargetGroupId)), |
| 34 navigation_target_source_(new views::RadioButton( | 34 navigation_target_source_(new views::RadioButton( |
| 35 base::ASCIIToUTF16("Source window"), kNavigationTargetGroupId)), | 35 base::ASCIIToUTF16("Source window"), kNavigationTargetGroupId)), |
| 36 navigation_target_default_(new views::RadioButton( | 36 navigation_target_default_(new views::RadioButton( |
| 37 base::ASCIIToUTF16("Default"), kNavigationTargetGroupId)), | 37 base::ASCIIToUTF16("Default"), kNavigationTargetGroupId)), |
| 38 next_color_(0), | |
| 39 colored_square_(new views::BlueButton( | 38 colored_square_(new views::BlueButton( |
| 40 this, base::ASCIIToUTF16("Local nav test"))), | 39 this, base::ASCIIToUTF16("Local nav test"))), |
| 41 close_last_(new views::BlueButton( | 40 close_last_(new views::BlueButton( |
| 42 this, base::ASCIIToUTF16("Close last window"))), | 41 this, base::ASCIIToUTF16("Close last window"))), |
| 43 cross_app_(new views::BlueButton( | 42 cross_app_(new views::BlueButton( |
| 44 this, base::ASCIIToUTF16("Cross-app nav test"))) { | 43 this, base::ASCIIToUTF16("Cross-app nav test"))) { |
| 45 navigation_target_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 44 navigation_target_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 46 navigation_target_default_->SetChecked(true); | 45 navigation_target_default_->SetChecked(true); |
| 47 | 46 |
| 48 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView(); | 47 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 }; | 109 }; |
| 111 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(buttons); ++i) { | 110 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(buttons); ++i) { |
| 112 buttons[i]->SetBounds(kControlBorderInset, y, w, | 111 buttons[i]->SetBounds(kControlBorderInset, y, w, |
| 113 buttons[i]->GetPreferredSize().height()); | 112 buttons[i]->GetPreferredSize().height()); |
| 114 y += buttons[i]->height(); | 113 y += buttons[i]->height(); |
| 115 } | 114 } |
| 116 } | 115 } |
| 117 | 116 |
| 118 void DebugPanel::ButtonPressed(views::Button* sender, const ui::Event& event) { | 117 void DebugPanel::ButtonPressed(views::Button* sender, const ui::Event& event) { |
| 119 if (sender == colored_square_) { | 118 if (sender == colored_square_) { |
| 120 Navigate(base::StringPrintf("mojo://mojo_embedded_app/%x", | 119 Navigate("mojo://mojo_embedded_app/"); |
| 121 kColors[next_color_ % arraysize(kColors)])); | |
| 122 next_color_++; | 120 next_color_++; |
| 123 } else if (sender == close_last_) { | 121 } else if (sender == close_last_) { |
| 124 delegate_->CloseTopWindow(); | 122 delegate_->CloseTopWindow(); |
| 125 } else if (sender == cross_app_) { | 123 } else if (sender == cross_app_) { |
| 126 Navigate("http://www.aaronboodman.com/z_dropbox/test.html"); | 124 Navigate("http://www.aaronboodman.com/z_dropbox/test.html"); |
| 127 } | 125 } |
| 128 } | 126 } |
| 129 | 127 |
| 130 void DebugPanel::Navigate(const std::string& url) { | 128 void DebugPanel::Navigate(const std::string& url) { |
| 131 NavigationDetailsPtr details(NavigationDetails::New()); | 129 NavigationDetailsPtr details(NavigationDetails::New()); |
| 132 details->request->url = url; | 130 details->request->url = url; |
| 133 delegate_->RequestNavigate(view_->id(), TARGET_NEW_NODE, details.Pass()); | 131 delegate_->RequestNavigate(view_->id(), TARGET_NEW_NODE, details.Pass()); |
| 134 } | 132 } |
| 135 | 133 |
| 136 } // namespace examples | 134 } // namespace examples |
| 137 } // namespace mojo | 135 } // namespace mojo |
| OLD | NEW |