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 "apps/custom_launcher_page_contents.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
34 #include "chrome/common/extensions/extension_constants.h" | 34 #include "chrome/common/extensions/extension_constants.h" |
35 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
36 #include "components/signin/core/browser/signin_manager.h" | 36 #include "components/signin/core/browser/signin_manager.h" |
37 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
38 #include "content/public/browser/page_navigator.h" | 38 #include "content/public/browser/page_navigator.h" |
39 #include "content/public/browser/user_metrics.h" | 39 #include "content/public/browser/user_metrics.h" |
40 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
41 #include "extensions/browser/extension_registry.h" | 41 #include "extensions/browser/extension_registry.h" |
42 #include "extensions/common/constants.h" | 42 #include "extensions/common/constants.h" |
43 #include "extensions/common/extension_set.h" | |
44 #include "extensions/common/manifest.h" | |
45 #include "extensions/common/manifest_constants.h" | |
43 #include "grit/theme_resources.h" | 46 #include "grit/theme_resources.h" |
44 #include "ui/app_list/app_list_switches.h" | 47 #include "ui/app_list/app_list_switches.h" |
45 #include "ui/app_list/app_list_view_delegate_observer.h" | 48 #include "ui/app_list/app_list_view_delegate_observer.h" |
46 #include "ui/app_list/search_box_model.h" | 49 #include "ui/app_list/search_box_model.h" |
47 #include "ui/app_list/speech_ui_model.h" | 50 #include "ui/app_list/speech_ui_model.h" |
48 #include "ui/base/resource/resource_bundle.h" | 51 #include "ui/base/resource/resource_bundle.h" |
49 #include "ui/views/controls/webview/webview.h" | 52 #include "ui/views/controls/webview/webview.h" |
50 | 53 |
51 #if defined(TOOLKIT_VIEWS) | 54 #if defined(TOOLKIT_VIEWS) |
52 #include "ui/views/controls/webview/webview.h" | 55 #include "ui/views/controls/webview/webview.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 user.email = profile_info.GetUserNameOfProfileAtIndex(i); | 102 user.email = profile_info.GetUserNameOfProfileAtIndex(i); |
100 user.profile_path = profile_info.GetPathOfProfileAtIndex(i); | 103 user.profile_path = profile_info.GetPathOfProfileAtIndex(i); |
101 user.active = active_profile_path == user.profile_path; | 104 user.active = active_profile_path == user.profile_path; |
102 users->push_back(user); | 105 users->push_back(user); |
103 } | 106 } |
104 } | 107 } |
105 | 108 |
106 // Gets a list of URLs of the custom launcher pages to show in the launcher. | 109 // Gets a list of URLs of the custom launcher pages to show in the launcher. |
107 // Returns a URL for each installed launcher page. If --custom-launcher-page is | 110 // Returns a URL for each installed launcher page. If --custom-launcher-page is |
108 // specified and valid, also includes that URL. | 111 // specified and valid, also includes that URL. |
109 void GetCustomLauncherPageUrls(std::vector<GURL>* urls) { | 112 void GetCustomLauncherPageUrls(content::BrowserContext* browser_context, |
113 std::vector<GURL>* urls) { | |
110 // First, check the command line. | 114 // First, check the command line. |
111 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 115 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
112 if (app_list::switches::IsExperimentalAppListEnabled() && | 116 if (app_list::switches::IsExperimentalAppListEnabled() && |
113 command_line->HasSwitch(switches::kCustomLauncherPage)) { | 117 command_line->HasSwitch(switches::kCustomLauncherPage)) { |
114 GURL custom_launcher_page_url( | 118 GURL custom_launcher_page_url( |
115 command_line->GetSwitchValueASCII(switches::kCustomLauncherPage)); | 119 command_line->GetSwitchValueASCII(switches::kCustomLauncherPage)); |
116 | |
117 if (custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) { | 120 if (custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) { |
118 urls->push_back(custom_launcher_page_url); | 121 urls->push_back(custom_launcher_page_url); |
119 } else { | 122 } else { |
120 LOG(ERROR) << "Invalid custom launcher page URL: " | 123 LOG(ERROR) << "Invalid custom launcher page URL: " |
121 << custom_launcher_page_url.possibly_invalid_spec(); | 124 << custom_launcher_page_url.possibly_invalid_spec(); |
122 } | 125 } |
123 } | 126 } |
124 | 127 |
125 // TODO(mgiuca): Search the list of installed extensions and add any with a | 128 // Search the list of installed extensions for ones with 'launcher_page'. |
126 // 'launcher_page' attribute in its manifest. | 129 extensions::ExtensionRegistry* extension_registry = |
130 extensions::ExtensionRegistry::Get(browser_context); | |
131 const extensions::ExtensionSet& enabled_extensions = | |
132 extension_registry->enabled_extensions(); | |
133 for (extensions::ExtensionSet::const_iterator it = enabled_extensions.begin(); | |
134 it != enabled_extensions.end(); | |
135 ++it) { | |
136 const extensions::Extension* extension = it->get(); | |
137 const extensions::Manifest* manifest = extension->manifest(); | |
138 if (!manifest->HasKey(extensions::manifest_keys::kLauncherPage)) | |
139 continue; | |
140 std::string launcher_page_page; | |
141 if (!manifest->GetString(extensions::manifest_keys::kLauncherPagePage, | |
142 &launcher_page_page)) { | |
143 LOG(ERROR) << "Extension " << extension->id() << ": " | |
144 << extensions::manifest_keys::kLauncherPage << " has no " | |
145 << extensions::manifest_keys::kLauncherPagePage | |
146 << ". Ignoring launcher page."; | |
Matt Giuca
2014/08/15 04:17:09
This makes a pretty comical error message now:
"la
Matt Giuca
2014/08/15 04:20:00
Done.
| |
147 continue; | |
148 } | |
149 urls->push_back(extension->GetResourceURL(launcher_page_page)); | |
150 } | |
127 } | 151 } |
128 | 152 |
129 } // namespace | 153 } // namespace |
130 | 154 |
131 AppListViewDelegate::AppListViewDelegate(Profile* profile, | 155 AppListViewDelegate::AppListViewDelegate(Profile* profile, |
132 AppListControllerDelegate* controller) | 156 AppListControllerDelegate* controller) |
133 : controller_(controller), | 157 : controller_(controller), |
134 profile_(profile), | 158 profile_(profile), |
135 model_(NULL), | 159 model_(NULL), |
136 scoped_observer_(this) { | 160 scoped_observer_(this) { |
(...skipping 29 matching lines...) Expand all Loading... | |
166 *ui::ResourceBundle::GetSharedInstance(). | 190 *ui::ResourceBundle::GetSharedInstance(). |
167 GetImageSkiaNamed(IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH)); | 191 GetImageSkiaNamed(IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH)); |
168 #endif | 192 #endif |
169 | 193 |
170 OnProfileChanged(); // sets model_ | 194 OnProfileChanged(); // sets model_ |
171 if (service) | 195 if (service) |
172 service->AddObserver(this); | 196 service->AddObserver(this); |
173 | 197 |
174 // Set up the custom launcher pages. | 198 // Set up the custom launcher pages. |
175 std::vector<GURL> custom_launcher_page_urls; | 199 std::vector<GURL> custom_launcher_page_urls; |
176 GetCustomLauncherPageUrls(&custom_launcher_page_urls); | 200 GetCustomLauncherPageUrls(profile, &custom_launcher_page_urls); |
177 for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin(); | 201 for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin(); |
178 it != custom_launcher_page_urls.end(); | 202 it != custom_launcher_page_urls.end(); |
179 ++it) { | 203 ++it) { |
180 std::string extension_id = it->host(); | 204 std::string extension_id = it->host(); |
181 apps::CustomLauncherPageContents* page_contents = | 205 apps::CustomLauncherPageContents* page_contents = |
182 new apps::CustomLauncherPageContents( | 206 new apps::CustomLauncherPageContents( |
183 scoped_ptr<apps::AppDelegate>(new ChromeAppDelegate), extension_id); | 207 scoped_ptr<apps::AppDelegate>(new ChromeAppDelegate), extension_id); |
184 page_contents->Initialize(profile, *it); | 208 page_contents->Initialize(profile, *it); |
185 custom_page_contents_.push_back(page_contents); | 209 custom_page_contents_.push_back(page_contents); |
186 } | 210 } |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 | 580 |
557 void AppListViewDelegate::AddObserver( | 581 void AppListViewDelegate::AddObserver( |
558 app_list::AppListViewDelegateObserver* observer) { | 582 app_list::AppListViewDelegateObserver* observer) { |
559 observers_.AddObserver(observer); | 583 observers_.AddObserver(observer); |
560 } | 584 } |
561 | 585 |
562 void AppListViewDelegate::RemoveObserver( | 586 void AppListViewDelegate::RemoveObserver( |
563 app_list::AppListViewDelegateObserver* observer) { | 587 app_list::AppListViewDelegateObserver* observer) { |
564 observers_.RemoveObserver(observer); | 588 observers_.RemoveObserver(observer); |
565 } | 589 } |
OLD | NEW |