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

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

Issue 425303002: Move extension notifications to extensions/browser/notification_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (extension-notifications) rebase Created 6 years, 4 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"
11 #include "chrome/browser/extensions/crx_installer.h" 10 #include "chrome/browser/extensions/crx_installer.h"
12 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/favicon_downloader.h" 12 #include "chrome/browser/extensions/favicon_downloader.h"
14 #include "chrome/browser/extensions/tab_helper.h" 13 #include "chrome/browser/extensions/tab_helper.h"
15 #include "chrome/common/extensions/extension_constants.h" 14 #include "chrome/common/extensions/extension_constants.h"
16 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 15 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
17 #include "content/public/browser/notification_service.h" 16 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
19 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
20 #include "extensions/browser/image_loader.h" 19 #include "extensions/browser/image_loader.h"
20 #include "extensions/browser/notification_types.h"
21 #include "extensions/common/constants.h" 21 #include "extensions/common/constants.h"
22 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
23 #include "extensions/common/manifest_handlers/icons_handler.h" 23 #include "extensions/common/manifest_handlers/icons_handler.h"
24 #include "extensions/common/url_pattern.h" 24 #include "extensions/common/url_pattern.h"
25 #include "grit/platform_locale_settings.h" 25 #include "grit/platform_locale_settings.h"
26 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 26 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
27 #include "skia/ext/image_operations.h" 27 #include "skia/ext/image_operations.h"
28 #include "skia/ext/platform_canvas.h" 28 #include "skia/ext/platform_canvas.h"
29 #include "third_party/skia/include/core/SkBitmap.h" 29 #include "third_party/skia/include/core/SkBitmap.h"
30 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 gfx::Size(output_size, output_size)); 167 gfx::Size(output_size, output_size));
168 icon_image.bitmap()->deepCopyTo(&(*bitmaps)[output_size]); 168 icon_image.bitmap()->deepCopyTo(&(*bitmaps)[output_size]);
169 } 169 }
170 170
171 BookmarkAppHelper::BookmarkAppHelper(ExtensionService* service, 171 BookmarkAppHelper::BookmarkAppHelper(ExtensionService* service,
172 WebApplicationInfo web_app_info, 172 WebApplicationInfo web_app_info,
173 content::WebContents* contents) 173 content::WebContents* contents)
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 extensions::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 extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR,
182 content::Source<CrxInstaller>(crx_installer_.get())); 182 content::Source<CrxInstaller>(crx_installer_.get()));
183 183
184 crx_installer_->set_error_on_unsupported_requirements(true); 184 crx_installer_->set_error_on_unsupported_requirements(true);
185 185
186 if (!contents) 186 if (!contents)
187 return; 187 return;
188 188
189 // Add urls from the WebApplicationInfo. 189 // Add urls from the WebApplicationInfo.
190 std::vector<GURL> web_app_info_icon_urls; 190 std::vector<GURL> web_app_info_icon_urls;
191 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it = 191 for (std::vector<WebApplicationInfo::IconInfo>::const_iterator it =
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 323
324 // Install the app. 324 // Install the app.
325 crx_installer_->InstallWebApp(web_app_info_); 325 crx_installer_->InstallWebApp(web_app_info_);
326 favicon_downloader_.reset(); 326 favicon_downloader_.reset();
327 } 327 }
328 328
329 void BookmarkAppHelper::Observe(int type, 329 void BookmarkAppHelper::Observe(int type,
330 const content::NotificationSource& source, 330 const content::NotificationSource& source,
331 const content::NotificationDetails& details) { 331 const content::NotificationDetails& details) {
332 switch (type) { 332 switch (type) {
333 case chrome::NOTIFICATION_CRX_INSTALLER_DONE: { 333 case extensions::NOTIFICATION_CRX_INSTALLER_DONE: {
334 const Extension* extension = 334 const Extension* extension =
335 content::Details<const Extension>(details).ptr(); 335 content::Details<const Extension>(details).ptr();
336 DCHECK(extension); 336 DCHECK(extension);
337 DCHECK_EQ(AppLaunchInfo::GetLaunchWebURL(extension), 337 DCHECK_EQ(AppLaunchInfo::GetLaunchWebURL(extension),
338 web_app_info_.app_url); 338 web_app_info_.app_url);
339 callback_.Run(extension, web_app_info_); 339 callback_.Run(extension, web_app_info_);
340 break; 340 break;
341 } 341 }
342 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: 342 case extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR:
343 callback_.Run(NULL, web_app_info_); 343 callback_.Run(NULL, web_app_info_);
344 break; 344 break;
345 default: 345 default:
346 NOTREACHED(); 346 NOTREACHED();
347 break; 347 break;
348 } 348 }
349 } 349 }
350 350
351 void CreateOrUpdateBookmarkApp(ExtensionService* service, 351 void CreateOrUpdateBookmarkApp(ExtensionService* service,
352 WebApplicationInfo& web_app_info) { 352 WebApplicationInfo& web_app_info) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); 389 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback));
390 } 390 }
391 391
392 bool IsValidBookmarkAppUrl(const GURL& url) { 392 bool IsValidBookmarkAppUrl(const GURL& url) {
393 URLPattern origin_only_pattern(Extension::kValidWebExtentSchemes); 393 URLPattern origin_only_pattern(Extension::kValidWebExtentSchemes);
394 origin_only_pattern.SetMatchAllURLs(true); 394 origin_only_pattern.SetMatchAllURLs(true);
395 return url.is_valid() && origin_only_pattern.MatchesURL(url); 395 return url.is_valid() && origin_only_pattern.MatchesURL(url);
396 } 396 }
397 397
398 } // namespace extensions 398 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698