OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura_shell/launcher/launcher_view.h" | 5 #include "ui/aura_shell/launcher/launcher_view.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura_shell/launcher/app_launcher_button.h" | 10 #include "ui/aura_shell/launcher/app_launcher_button.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 198 } |
199 | 199 |
200 LauncherView::~LauncherView() { | 200 LauncherView::~LauncherView() { |
201 model_->RemoveObserver(this); | 201 model_->RemoveObserver(this); |
202 } | 202 } |
203 | 203 |
204 void LauncherView::Init() { | 204 void LauncherView::Init() { |
205 model_->AddObserver(this); | 205 model_->AddObserver(this); |
206 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 206 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
207 new_browser_button_ = new views::ImageButton(this); | 207 new_browser_button_ = new views::ImageButton(this); |
208 int new_browser_button_image_id = | 208 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
209 Shell::GetInstance()->delegate()->GetResourceIDForNewBrowserWindow(); | 209 int new_browser_button_image_id = delegate ? |
| 210 delegate->GetResourceIDForNewBrowserWindow() : |
| 211 IDR_AURA_LAUNCHER_ICON_CHROME; |
210 new_browser_button_->SetImage( | 212 new_browser_button_->SetImage( |
211 views::CustomButton::BS_NORMAL, | 213 views::CustomButton::BS_NORMAL, |
212 rb.GetImageNamed(new_browser_button_image_id).ToSkBitmap()); | 214 rb.GetImageNamed(new_browser_button_image_id).ToSkBitmap()); |
213 ConfigureChildView(new_browser_button_); | 215 ConfigureChildView(new_browser_button_); |
214 AddChildView(new_browser_button_); | 216 AddChildView(new_browser_button_); |
215 | 217 |
216 const LauncherItems& items(model_->items()); | 218 const LauncherItems& items(model_->items()); |
217 for (LauncherItems::const_iterator i = items.begin(); i != items.end(); ++i) { | 219 for (LauncherItems::const_iterator i = items.begin(); i != items.end(); ++i) { |
218 views::View* child = CreateViewForItem(*i); | 220 views::View* child = CreateViewForItem(*i); |
219 child->SetPaintToLayer(true); | 221 child->SetPaintToLayer(true); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 } else { | 577 } else { |
576 int view_index = view_model_->GetIndexOfView(sender); | 578 int view_index = view_model_->GetIndexOfView(sender); |
577 // May be -1 while in the process of animating closed. | 579 // May be -1 while in the process of animating closed. |
578 if (view_index != -1) | 580 if (view_index != -1) |
579 delegate->LauncherItemClicked(model_->items()[view_index]); | 581 delegate->LauncherItemClicked(model_->items()[view_index]); |
580 } | 582 } |
581 } | 583 } |
582 | 584 |
583 } // namespace internal | 585 } // namespace internal |
584 } // namespace aura_shell | 586 } // namespace aura_shell |
OLD | NEW |