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 "ui/app_list/views/start_page_view.h" | 5 #include "ui/app_list/views/start_page_view.h" |
6 | 6 |
7 #include "content/public/browser/web_contents.h" | 7 #include "content/public/browser/web_contents.h" |
8 #include "ui/app_list/app_list_constants.h" | 8 #include "ui/app_list/app_list_constants.h" |
9 #include "ui/app_list/views/app_list_main_view.h" | 9 #include "ui/app_list/views/app_list_main_view.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 StartPageView::StartPageView(AppListMainView* app_list_main_view, | 66 StartPageView::StartPageView(AppListMainView* app_list_main_view, |
67 content::WebContents* start_page_web_contents) | 67 content::WebContents* start_page_web_contents) |
68 : app_list_main_view_(app_list_main_view), | 68 : app_list_main_view_(app_list_main_view), |
69 instant_container_(new views::View) { | 69 instant_container_(new views::View) { |
70 AddChildView(instant_container_); | 70 AddChildView(instant_container_); |
71 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 71 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
72 instant_container_->SetLayoutManager(new views::BoxLayout( | 72 instant_container_->SetLayoutManager(new views::BoxLayout( |
73 views::BoxLayout::kVertical, 0, kTopMargin, kInstantContainerSpacing)); | 73 views::BoxLayout::kVertical, 0, kTopMargin, kInstantContainerSpacing)); |
74 | 74 |
75 views::WebView* web_view = | 75 views::WebView* web_view = new views::WebView( |
76 new views::WebView(start_page_web_contents->GetBrowserContext()); | 76 start_page_web_contents ? start_page_web_contents->GetBrowserContext() |
| 77 : NULL); |
77 web_view->SetPreferredSize(gfx::Size(kWebViewWidth, kWebViewHeight)); | 78 web_view->SetPreferredSize(gfx::Size(kWebViewWidth, kWebViewHeight)); |
78 web_view->SetWebContents(start_page_web_contents); | 79 web_view->SetWebContents(start_page_web_contents); |
79 | 80 |
80 instant_container_->AddChildView(web_view); | 81 instant_container_->AddChildView(web_view); |
81 instant_container_->AddChildView(new BarPlaceholderButton(this)); | 82 instant_container_->AddChildView(new BarPlaceholderButton(this)); |
82 } | 83 } |
83 | 84 |
84 StartPageView::~StartPageView() { | 85 StartPageView::~StartPageView() { |
85 } | 86 } |
86 | 87 |
87 void StartPageView::Reset() { | 88 void StartPageView::Reset() { |
88 instant_container_->SetVisible(true); | 89 instant_container_->SetVisible(true); |
89 } | 90 } |
90 | 91 |
91 void StartPageView::ButtonPressed(views::Button* sender, | 92 void StartPageView::ButtonPressed(views::Button* sender, |
92 const ui::Event& event) { | 93 const ui::Event& event) { |
93 app_list_main_view_->OnStartPageSearchButtonPressed(); | 94 app_list_main_view_->OnStartPageSearchButtonPressed(); |
94 instant_container_->SetVisible(false); | 95 instant_container_->SetVisible(false); |
95 } | 96 } |
96 | 97 |
97 } // namespace app_list | 98 } // namespace app_list |
OLD | NEW |