Chromium Code Reviews| 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); |
|
tapted
2014/07/10 04:29:34
Should this be in OnProfileChanged() to properly h
Matt Giuca
2014/07/10 07:37:03
Good catch! This is actually a pre-existing bug. S
| |
| 167 custom_page_web_contents_->GetController().LoadURL( | 168 custom_page_contents_->LoadContents(); |
| 168 custom_launcher_page_url, | |
| 169 content::Referrer(), | |
| 170 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | |
| 171 std::string()); | |
| 172 } | 169 } |
| 173 } | 170 } |
| 174 } | 171 } |
| 175 | 172 |
| 176 AppListViewDelegate::~AppListViewDelegate() { | 173 AppListViewDelegate::~AppListViewDelegate() { |
| 177 app_list::StartPageService* service = | 174 app_list::StartPageService* service = |
| 178 app_list::StartPageService::Get(profile_); | 175 app_list::StartPageService::Get(profile_); |
| 179 if (service) | 176 if (service) |
| 180 service->RemoveObserver(this); | 177 service->RemoveObserver(this); |
| 181 g_browser_process-> | 178 g_browser_process-> |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 | 471 |
| 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_->GetWebContents(); |
| 488 custom_page_web_contents_->GetBrowserContext()); | 485 views::WebView* web_view = |
| 486 new views::WebView(web_contents->GetBrowserContext()); | |
|
tapted
2014/07/10 04:29:34
is web_contents->GetBrowserContext() equivalent to
Matt Giuca
2014/07/10 07:37:03
Hmm, yeah they SHOULD be equivalent (but actually
| |
| 489 web_view->SetPreferredSize(size); | 487 web_view->SetPreferredSize(size); |
| 490 web_view->SetWebContents(custom_page_web_contents_.get()); | 488 web_view->SetWebContents(web_contents); |
| 491 return web_view; | 489 return web_view; |
| 492 } | 490 } |
| 493 #endif | 491 #endif |
| 494 | 492 |
| 495 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { | 493 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { |
| 496 app_list::StartPageService* service = | 494 app_list::StartPageService* service = |
| 497 app_list::StartPageService::Get(profile_); | 495 app_list::StartPageService::Get(profile_); |
| 498 return service && service->GetSpeechRecognitionContents(); | 496 return service && service->GetSpeechRecognitionContents(); |
| 499 } | 497 } |
| 500 | 498 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 | 531 |
| 534 void AppListViewDelegate::AddObserver( | 532 void AppListViewDelegate::AddObserver( |
| 535 app_list::AppListViewDelegateObserver* observer) { | 533 app_list::AppListViewDelegateObserver* observer) { |
| 536 observers_.AddObserver(observer); | 534 observers_.AddObserver(observer); |
| 537 } | 535 } |
| 538 | 536 |
| 539 void AppListViewDelegate::RemoveObserver( | 537 void AppListViewDelegate::RemoveObserver( |
| 540 app_list::AppListViewDelegateObserver* observer) { | 538 app_list::AppListViewDelegateObserver* observer) { |
| 541 observers_.RemoveObserver(observer); | 539 observers_.RemoveObserver(observer); |
| 542 } | 540 } |
| OLD | NEW |