OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/app_list/app_list_view_delegate.h" | 5 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
| 9 #include "apps/custom_launcher_page_contents.h" |
9 #include "base/callback.h" | 10 #include "base/callback.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/metrics/user_metrics.h" | 13 #include "base/metrics/user_metrics.h" |
13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/profiles/profile_info_cache.h" | 17 #include "chrome/browser/profiles/profile_info_cache.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/search/hotword_service.h" | 19 #include "chrome/browser/search/hotword_service.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // arbitrary extensions may be able to specify their own custom pages. | 156 // arbitrary extensions may be able to specify their own custom pages. |
156 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 157 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
157 if (app_list::switches::IsExperimentalAppListEnabled() && | 158 if (app_list::switches::IsExperimentalAppListEnabled() && |
158 command_line->HasSwitch(switches::kCustomLauncherPage)) { | 159 command_line->HasSwitch(switches::kCustomLauncherPage)) { |
159 GURL custom_launcher_page_url( | 160 GURL custom_launcher_page_url( |
160 command_line->GetSwitchValueASCII(switches::kCustomLauncherPage)); | 161 command_line->GetSwitchValueASCII(switches::kCustomLauncherPage)); |
161 if (!custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) { | 162 if (!custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) { |
162 LOG(ERROR) << "Invalid custom launcher page URL: " | 163 LOG(ERROR) << "Invalid custom launcher page URL: " |
163 << custom_launcher_page_url.possibly_invalid_spec(); | 164 << custom_launcher_page_url.possibly_invalid_spec(); |
164 } else { | 165 } else { |
165 content::WebContents::CreateParams params(profile_); | 166 custom_page_contents_.reset(new apps::CustomLauncherPageContents()); |
166 custom_page_web_contents_.reset(content::WebContents::Create(params)); | 167 custom_page_contents_->Initialize(profile, custom_launcher_page_url); |
167 custom_page_web_contents_->GetController().LoadURL( | |
168 custom_launcher_page_url, | |
169 content::Referrer(), | |
170 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | |
171 std::string()); | |
172 } | 168 } |
173 } | 169 } |
174 } | 170 } |
175 | 171 |
176 AppListViewDelegate::~AppListViewDelegate() { | 172 AppListViewDelegate::~AppListViewDelegate() { |
177 app_list::StartPageService* service = | 173 app_list::StartPageService* service = |
178 app_list::StartPageService::Get(profile_); | 174 app_list::StartPageService::Get(profile_); |
179 if (service) | 175 if (service) |
180 service->RemoveObserver(this); | 176 service->RemoveObserver(this); |
181 g_browser_process-> | 177 g_browser_process-> |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 const gfx::Size& size) { | 461 const gfx::Size& size) { |
466 app_list::StartPageService* service = | 462 app_list::StartPageService* service = |
467 app_list::StartPageService::Get(profile_); | 463 app_list::StartPageService::Get(profile_); |
468 if (!service) | 464 if (!service) |
469 return NULL; | 465 return NULL; |
470 | 466 |
471 content::WebContents* web_contents = service->GetStartPageContents(); | 467 content::WebContents* web_contents = service->GetStartPageContents(); |
472 if (!web_contents) | 468 if (!web_contents) |
473 return NULL; | 469 return NULL; |
474 | 470 |
| 471 DCHECK_EQ(profile_, web_contents->GetBrowserContext()); |
475 views::WebView* web_view = new views::WebView( | 472 views::WebView* web_view = new views::WebView( |
476 web_contents->GetBrowserContext()); | 473 web_contents->GetBrowserContext()); |
477 web_view->SetPreferredSize(size); | 474 web_view->SetPreferredSize(size); |
478 web_view->SetWebContents(web_contents); | 475 web_view->SetWebContents(web_contents); |
479 return web_view; | 476 return web_view; |
480 } | 477 } |
481 | 478 |
482 views::View* AppListViewDelegate::CreateCustomPageWebView( | 479 views::View* AppListViewDelegate::CreateCustomPageWebView( |
483 const gfx::Size& size) { | 480 const gfx::Size& size) { |
484 if (!custom_page_web_contents_) | 481 if (!custom_page_contents_) |
485 return NULL; | 482 return NULL; |
486 | 483 |
487 views::WebView* web_view = new views::WebView( | 484 content::WebContents* web_contents = custom_page_contents_->web_contents(); |
488 custom_page_web_contents_->GetBrowserContext()); | 485 // TODO(mgiuca): DCHECK_EQ(profile_, web_contents->GetBrowserContext()) after |
| 486 // http://crbug.com/392763 resolved. |
| 487 views::WebView* web_view = |
| 488 new views::WebView(web_contents->GetBrowserContext()); |
489 web_view->SetPreferredSize(size); | 489 web_view->SetPreferredSize(size); |
490 web_view->SetWebContents(custom_page_web_contents_.get()); | 490 web_view->SetWebContents(web_contents); |
491 return web_view; | 491 return web_view; |
492 } | 492 } |
493 #endif | 493 #endif |
494 | 494 |
495 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { | 495 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { |
496 app_list::StartPageService* service = | 496 app_list::StartPageService* service = |
497 app_list::StartPageService::Get(profile_); | 497 app_list::StartPageService::Get(profile_); |
498 return service && service->GetSpeechRecognitionContents(); | 498 return service && service->GetSpeechRecognitionContents(); |
499 } | 499 } |
500 | 500 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 | 533 |
534 void AppListViewDelegate::AddObserver( | 534 void AppListViewDelegate::AddObserver( |
535 app_list::AppListViewDelegateObserver* observer) { | 535 app_list::AppListViewDelegateObserver* observer) { |
536 observers_.AddObserver(observer); | 536 observers_.AddObserver(observer); |
537 } | 537 } |
538 | 538 |
539 void AppListViewDelegate::RemoveObserver( | 539 void AppListViewDelegate::RemoveObserver( |
540 app_list::AppListViewDelegateObserver* observer) { | 540 app_list::AppListViewDelegateObserver* observer) { |
541 observers_.RemoveObserver(observer); | 541 observers_.RemoveObserver(observer); |
542 } | 542 } |
OLD | NEW |