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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_webstore_private_api.h" 5 #include "chrome/browser/extensions/extension_webstore_private_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/extensions/crx_installer.h" 14 #include "chrome/browser/extensions/crx_installer.h"
15 #include "chrome/browser/extensions/extension_function_dispatcher.h" 15 #include "chrome/browser/extensions/extension_function_dispatcher.h"
16 #include "chrome/browser/extensions/extension_install_dialog.h" 16 #include "chrome/browser/extensions/extension_install_dialog.h"
17 #include "chrome/browser/extensions/extension_prefs.h" 17 #include "chrome/browser/extensions/extension_prefs.h"
18 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/net/gaia/token_service.h" 19 #include "chrome/browser/net/gaia/token_service.h"
20 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/sync/profile_sync_service.h" 21 #include "chrome/browser/sync/profile_sync_service.h"
22 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/chrome_utility_messages.h" 24 #include "chrome/common/chrome_utility_messages.h"
24 #include "chrome/common/extensions/extension_constants.h" 25 #include "chrome/common/extensions/extension_constants.h"
25 #include "chrome/common/extensions/extension_error_utils.h" 26 #include "chrome/common/extensions/extension_error_utils.h"
26 #include "chrome/common/extensions/extension_l10n_util.h" 27 #include "chrome/common/extensions/extension_l10n_util.h"
27 #include "chrome/common/net/gaia/gaia_constants.h" 28 #include "chrome/common/net/gaia/gaia_constants.h"
28 #include "content/browser/tab_contents/tab_contents.h" 29 #include "content/browser/tab_contents/tab_contents.h"
29 #include "content/common/notification_details.h" 30 #include "content/common/notification_details.h"
30 #include "content/common/notification_source.h" 31 #include "content/common/notification_source.h"
31 #include "content/common/notification_type.h"
32 #include "grit/chromium_strings.h" 32 #include "grit/chromium_strings.h"
33 #include "grit/generated_resources.h" 33 #include "grit/generated_resources.h"
34 #include "net/base/escape.h" 34 #include "net/base/escape.h"
35 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
36 36
37 namespace { 37 namespace {
38 38
39 const char kIconDataKey[] = "iconData"; 39 const char kIconDataKey[] = "iconData";
40 const char kIdKey[] = "id"; 40 const char kIdKey[] = "id";
41 const char kLocalizedNameKey[] = "localizedName"; 41 const char kLocalizedNameKey[] = "localizedName";
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 if (!tab) 563 if (!tab)
564 return false; 564 return false;
565 565
566 // We return the result asynchronously, so we addref to keep ourself alive. 566 // We return the result asynchronously, so we addref to keep ourself alive.
567 // Matched with a Release in OnLoginSuccess() and OnLoginFailure(). 567 // Matched with a Release in OnLoginSuccess() and OnLoginFailure().
568 AddRef(); 568 AddRef();
569 569
570 // Start listening for notifications about the token. 570 // Start listening for notifications about the token.
571 TokenService* token_service = profile->GetTokenService(); 571 TokenService* token_service = profile->GetTokenService();
572 registrar_.Add(this, 572 registrar_.Add(this,
573 NotificationType::TOKEN_AVAILABLE, 573 chrome::TOKEN_AVAILABLE,
574 Source<TokenService>(token_service)); 574 Source<TokenService>(token_service));
575 registrar_.Add(this, 575 registrar_.Add(this,
576 NotificationType::TOKEN_REQUEST_FAILED, 576 chrome::TOKEN_REQUEST_FAILED,
577 Source<TokenService>(token_service)); 577 Source<TokenService>(token_service));
578 578
579 GetBrowserSignin(profile)->RequestSignin(tab, 579 GetBrowserSignin(profile)->RequestSignin(tab,
580 ASCIIToUTF16(preferred_email), 580 ASCIIToUTF16(preferred_email),
581 GetLoginMessage(), 581 GetLoginMessage(),
582 this); 582 this);
583 583
584 // The response will be sent asynchronously in OnLoginSuccess/OnLoginFailure. 584 // The response will be sent asynchronously in OnLoginSuccess/OnLoginFailure.
585 return true; 585 return true;
586 } 586 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 SendResponse(false); 623 SendResponse(false);
624 // Matches the AddRef in RunImpl(). 624 // Matches the AddRef in RunImpl().
625 Release(); 625 Release();
626 } 626 }
627 627
628 void PromptBrowserLoginFunction::Observe(NotificationType type, 628 void PromptBrowserLoginFunction::Observe(NotificationType type,
629 const NotificationSource& source, 629 const NotificationSource& source,
630 const NotificationDetails& details) { 630 const NotificationDetails& details) {
631 // Make sure this notification is for the service we are interested in. 631 // Make sure this notification is for the service we are interested in.
632 std::string service; 632 std::string service;
633 if (type == NotificationType::TOKEN_AVAILABLE) { 633 if (type == chrome::TOKEN_AVAILABLE) {
634 TokenService::TokenAvailableDetails* available = 634 TokenService::TokenAvailableDetails* available =
635 Details<TokenService::TokenAvailableDetails>(details).ptr(); 635 Details<TokenService::TokenAvailableDetails>(details).ptr();
636 service = available->service(); 636 service = available->service();
637 } else if (type == NotificationType::TOKEN_REQUEST_FAILED) { 637 } else if (type == chrome::TOKEN_REQUEST_FAILED) {
638 TokenService::TokenRequestFailedDetails* failed = 638 TokenService::TokenRequestFailedDetails* failed =
639 Details<TokenService::TokenRequestFailedDetails>(details).ptr(); 639 Details<TokenService::TokenRequestFailedDetails>(details).ptr();
640 service = failed->service(); 640 service = failed->service();
641 } else { 641 } else {
642 NOTREACHED(); 642 NOTREACHED();
643 } 643 }
644 644
645 if (service != GaiaConstants::kGaiaService) { 645 if (service != GaiaConstants::kGaiaService) {
646 return; 646 return;
647 } 647 }
648 648
649 DCHECK(waiting_for_token_); 649 DCHECK(waiting_for_token_);
650 650
651 result_.reset(CreateLoginResult(profile_->GetOriginalProfile())); 651 result_.reset(CreateLoginResult(profile_->GetOriginalProfile()));
652 SendResponse(true); 652 SendResponse(true);
653 653
654 // Matches the AddRef in RunImpl(). 654 // Matches the AddRef in RunImpl().
655 Release(); 655 Release();
656 } 656 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698