Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: chrome/browser/extensions/bookmark_app_helper.cc

Issue 308003005: app_list: Drive app integration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for comemnts in #5 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/extensions/bookmark_app_helper.h" 5 #include "chrome/browser/extensions/bookmark_app_helper.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 : web_app_info_(web_app_info), 174 : web_app_info_(web_app_info),
175 crx_installer_(extensions::CrxInstaller::CreateSilent(service)) { 175 crx_installer_(extensions::CrxInstaller::CreateSilent(service)) {
176 registrar_.Add(this, 176 registrar_.Add(this,
177 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 177 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
178 content::Source<CrxInstaller>(crx_installer_.get())); 178 content::Source<CrxInstaller>(crx_installer_.get()));
179 179
180 registrar_.Add(this, 180 registrar_.Add(this,
181 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, 181 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR,
182 content::Source<CrxInstaller>(crx_installer_.get())); 182 content::Source<CrxInstaller>(crx_installer_.get()));
183 183
184 crx_installer_->set_creation_flags(Extension::FROM_BOOKMARK);
184 crx_installer_->set_error_on_unsupported_requirements(true); 185 crx_installer_->set_error_on_unsupported_requirements(true);
185 186
186 if (!contents) 187 if (!contents)
187 return; 188 return;
188 189
189 // Add urls from the WebApplicationInfo. 190 // Add urls from the WebApplicationInfo.
190 std::vector<GURL> web_app_info_icon_urls; 191 std::vector<GURL> web_app_info_icon_urls;
191 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it = 192 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it =
192 web_app_info_.icons.begin(); 193 web_app_info_.icons.begin();
193 it != web_app_info_.icons.end(); 194 it != web_app_info_.icons.end();
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 default: 346 default:
346 NOTREACHED(); 347 NOTREACHED();
347 break; 348 break;
348 } 349 }
349 } 350 }
350 351
351 void CreateOrUpdateBookmarkApp(ExtensionService* service, 352 void CreateOrUpdateBookmarkApp(ExtensionService* service,
352 WebApplicationInfo& web_app_info) { 353 WebApplicationInfo& web_app_info) {
353 scoped_refptr<extensions::CrxInstaller> installer( 354 scoped_refptr<extensions::CrxInstaller> installer(
354 extensions::CrxInstaller::CreateSilent(service)); 355 extensions::CrxInstaller::CreateSilent(service));
356 installer->set_creation_flags(Extension::FROM_BOOKMARK);
355 installer->set_error_on_unsupported_requirements(true); 357 installer->set_error_on_unsupported_requirements(true);
356 installer->InstallWebApp(web_app_info); 358 installer->InstallWebApp(web_app_info);
357 } 359 }
358 360
359 void GetWebApplicationInfoFromApp( 361 void GetWebApplicationInfoFromApp(
360 content::BrowserContext* browser_context, 362 content::BrowserContext* browser_context,
361 const extensions::Extension* extension, 363 const extensions::Extension* extension,
362 const base::Callback<void(const WebApplicationInfo&)> callback) { 364 const base::Callback<void(const WebApplicationInfo&)> callback) {
363 if (!extension->from_bookmark()) { 365 if (!extension->from_bookmark()) {
364 callback.Run(WebApplicationInfo()); 366 callback.Run(WebApplicationInfo());
(...skipping 24 matching lines...) Expand all
389 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); 391 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback));
390 } 392 }
391 393
392 bool IsValidBookmarkAppUrl(const GURL& url) { 394 bool IsValidBookmarkAppUrl(const GURL& url) {
393 URLPattern origin_only_pattern(Extension::kValidWebExtentSchemes); 395 URLPattern origin_only_pattern(Extension::kValidWebExtentSchemes);
394 origin_only_pattern.SetMatchAllURLs(true); 396 origin_only_pattern.SetMatchAllURLs(true);
395 return url.is_valid() && origin_only_pattern.MatchesURL(url); 397 return url.is_valid() && origin_only_pattern.MatchesURL(url);
396 } 398 }
397 399
398 } // namespace extensions 400 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698