Chromium Code Reviews

Side by Side Diff: chrome/browser/ui/app_list/app_list_view_delegate.cc

Issue 475543004: Added 'launcher_page' field to extension manifest.json format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Formatting. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
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...)
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...)
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 120
117 if (custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) { 121 if (custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) {
118 urls->push_back(custom_launcher_page_url); 122 urls->push_back(custom_launcher_page_url);
119 } else { 123 } else {
124 // TODO(mgiuca): Add a proper manifest parser to catch this error properly
125 // and display it on the extensions page.
120 LOG(ERROR) << "Invalid custom launcher page URL: " 126 LOG(ERROR) << "Invalid custom launcher page URL: "
121 << custom_launcher_page_url.possibly_invalid_spec(); 127 << custom_launcher_page_url.possibly_invalid_spec();
122 } 128 }
123 } 129 }
124 130
125 // TODO(mgiuca): Search the list of installed extensions and add any with a 131 // Search the list of installed extensions for ones with 'launcher_page'.
126 // 'launcher_page' attribute in its manifest. 132 extensions::ExtensionRegistry* extension_registry =
133 extensions::ExtensionRegistry::Get(browser_context);
134 const extensions::ExtensionSet& enabled_extensions =
135 extension_registry->enabled_extensions();
136 for (extensions::ExtensionSet::const_iterator it = enabled_extensions.begin();
137 it != enabled_extensions.end();
138 ++it) {
139 const extensions::Extension* extension = it->get();
140 const extensions::Manifest* manifest = extension->manifest();
141 if (!manifest->HasKey(extensions::manifest_keys::kLauncherPage))
142 continue;
143 std::string launcher_page_page;
144 if (!manifest->GetString(extensions::manifest_keys::kLauncherPagePage,
145 &launcher_page_page)) {
146 LOG(ERROR) << "Extension " << extension->id() << ": "
147 << extensions::manifest_keys::kLauncherPage
148 << " has no 'page' attribute; will be ignored.";
149 continue;
150 }
151 urls->push_back(extension->GetResourceURL(launcher_page_page));
152 }
127 } 153 }
128 154
129 } // namespace 155 } // namespace
130 156
131 AppListViewDelegate::AppListViewDelegate(Profile* profile, 157 AppListViewDelegate::AppListViewDelegate(Profile* profile,
132 AppListControllerDelegate* controller) 158 AppListControllerDelegate* controller)
133 : controller_(controller), 159 : controller_(controller),
134 profile_(profile), 160 profile_(profile),
135 model_(NULL), 161 model_(NULL),
136 scoped_observer_(this) { 162 scoped_observer_(this) {
(...skipping 29 matching lines...)
166 *ui::ResourceBundle::GetSharedInstance(). 192 *ui::ResourceBundle::GetSharedInstance().
167 GetImageSkiaNamed(IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH)); 193 GetImageSkiaNamed(IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH));
168 #endif 194 #endif
169 195
170 OnProfileChanged(); // sets model_ 196 OnProfileChanged(); // sets model_
171 if (service) 197 if (service)
172 service->AddObserver(this); 198 service->AddObserver(this);
173 199
174 // Set up the custom launcher pages. 200 // Set up the custom launcher pages.
175 std::vector<GURL> custom_launcher_page_urls; 201 std::vector<GURL> custom_launcher_page_urls;
176 GetCustomLauncherPageUrls(&custom_launcher_page_urls); 202 GetCustomLauncherPageUrls(profile, &custom_launcher_page_urls);
177 for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin(); 203 for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin();
178 it != custom_launcher_page_urls.end(); 204 it != custom_launcher_page_urls.end();
179 ++it) { 205 ++it) {
180 std::string extension_id = it->host(); 206 std::string extension_id = it->host();
181 apps::CustomLauncherPageContents* page_contents = 207 apps::CustomLauncherPageContents* page_contents =
182 new apps::CustomLauncherPageContents( 208 new apps::CustomLauncherPageContents(
183 scoped_ptr<apps::AppDelegate>(new ChromeAppDelegate), extension_id); 209 scoped_ptr<apps::AppDelegate>(new ChromeAppDelegate), extension_id);
184 page_contents->Initialize(profile, *it); 210 page_contents->Initialize(profile, *it);
185 custom_page_contents_.push_back(page_contents); 211 custom_page_contents_.push_back(page_contents);
186 } 212 }
(...skipping 369 matching lines...)
556 582
557 void AppListViewDelegate::AddObserver( 583 void AppListViewDelegate::AddObserver(
558 app_list::AppListViewDelegateObserver* observer) { 584 app_list::AppListViewDelegateObserver* observer) {
559 observers_.AddObserver(observer); 585 observers_.AddObserver(observer);
560 } 586 }
561 587
562 void AppListViewDelegate::RemoveObserver( 588 void AppListViewDelegate::RemoveObserver(
563 app_list::AppListViewDelegateObserver* observer) { 589 app_list::AppListViewDelegateObserver* observer) {
564 observers_.RemoveObserver(observer); 590 observers_.RemoveObserver(observer);
565 } 591 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/custom_launcher_page_browsertest_views.cc ('k') | chrome/common/extensions/api/_manifest_features.json » ('j') | no next file with comments »

Powered by Google App Engine