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

Side by Side Diff: chrome/browser/extensions/api/app/app_api.cc

Issue 11365181: Remove GetExtensionService from Profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: replace missing extension_system include Created 8 years 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
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/extensions/api/app/app_api.h" 5 #include "chrome/browser/extensions/api/app/app_api.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/app_notification_manager.h" 9 #include "chrome/browser/extensions/app_notification_manager.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_system.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/extensions/extension_constants.h" 13 #include "chrome/common/extensions/extension_constants.h"
13 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
14 15
15 namespace { 16 namespace {
16 17
17 const char kBodyTextKey[] = "bodyText"; 18 const char kBodyTextKey[] = "bodyText";
18 const char kExtensionIdKey[] = "extensionId"; 19 const char kExtensionIdKey[] = "extensionId";
19 const char kLinkTextKey[] = "linkText"; 20 const char kLinkTextKey[] = "linkText";
20 const char kLinkUrlKey[] = "linkUrl"; 21 const char kLinkUrlKey[] = "linkUrl";
(...skipping 15 matching lines...) Expand all
36 } 37 }
37 38
38 DictionaryValue* details; 39 DictionaryValue* details;
39 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); 40 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details));
40 EXTENSION_FUNCTION_VALIDATE(details != NULL); 41 EXTENSION_FUNCTION_VALIDATE(details != NULL);
41 42
42 // TODO(asargent) remove this before the API leaves experimental. 43 // TODO(asargent) remove this before the API leaves experimental.
43 std::string id = extension_id(); 44 std::string id = extension_id();
44 if (details->HasKey(kExtensionIdKey)) { 45 if (details->HasKey(kExtensionIdKey)) {
45 EXTENSION_FUNCTION_VALIDATE(details->GetString(kExtensionIdKey, &id)); 46 EXTENSION_FUNCTION_VALIDATE(details->GetString(kExtensionIdKey, &id));
46 if (!profile()->GetExtensionService()->GetExtensionById(id, true)) { 47 if (!extensions::ExtensionSystem::Get(profile())->extension_service()->
48 GetExtensionById(id, true)) {
47 error_ = kInvalidExtensionIdError; 49 error_ = kInvalidExtensionIdError;
48 return false; 50 return false;
49 } 51 }
50 } 52 }
51 53
52 std::string title; 54 std::string title;
53 if (details->HasKey(kTitleKey)) 55 if (details->HasKey(kTitleKey))
54 EXTENSION_FUNCTION_VALIDATE(details->GetString(kTitleKey, &title)); 56 EXTENSION_FUNCTION_VALIDATE(details->GetString(kTitleKey, &title));
55 57
56 std::string body; 58 std::string body;
(...skipping 14 matching lines...) Expand all
71 if (!details->HasKey(kLinkTextKey)) { 73 if (!details->HasKey(kLinkTextKey)) {
72 error_ = kMissingLinkTextError; 74 error_ = kMissingLinkTextError;
73 return false; 75 return false;
74 } 76 }
75 std::string link_text; 77 std::string link_text;
76 EXTENSION_FUNCTION_VALIDATE(details->GetString(kLinkTextKey, 78 EXTENSION_FUNCTION_VALIDATE(details->GetString(kLinkTextKey,
77 &link_text)); 79 &link_text));
78 item->set_link_text(link_text); 80 item->set_link_text(link_text);
79 } 81 }
80 82
81 AppNotificationManager* manager = 83 AppNotificationManager* manager = extensions::ExtensionSystem::Get(
82 profile()->GetExtensionService()->app_notification_manager(); 84 profile())->extension_service()->app_notification_manager();
83 85
84 // TODO(beaudoin) We should probably report an error if Add returns false. 86 // TODO(beaudoin) We should probably report an error if Add returns false.
85 manager->Add(item.release()); 87 manager->Add(item.release());
86 88
87 return true; 89 return true;
88 } 90 }
89 91
90 bool AppClearAllNotificationsFunction::RunImpl() { 92 bool AppClearAllNotificationsFunction::RunImpl() {
91 if (!include_incognito() && profile_->IsOffTheRecord()) { 93 if (!include_incognito() && profile_->IsOffTheRecord()) {
92 error_ = extension_misc::kAppNotificationsIncognitoError; 94 error_ = extension_misc::kAppNotificationsIncognitoError;
93 return false; 95 return false;
94 } 96 }
95 97
96 std::string id = extension_id(); 98 std::string id = extension_id();
97 DictionaryValue* details = NULL; 99 DictionaryValue* details = NULL;
98 if (args_->GetDictionary(0, &details) && details->HasKey(kExtensionIdKey)) { 100 if (args_->GetDictionary(0, &details) && details->HasKey(kExtensionIdKey)) {
99 EXTENSION_FUNCTION_VALIDATE(details->GetString(kExtensionIdKey, &id)); 101 EXTENSION_FUNCTION_VALIDATE(details->GetString(kExtensionIdKey, &id));
100 if (!profile()->GetExtensionService()->GetExtensionById(id, true)) { 102 if (!extensions::ExtensionSystem::Get(profile())->extension_service()->
103 GetExtensionById(id, true)) {
101 error_ = kInvalidExtensionIdError; 104 error_ = kInvalidExtensionIdError;
102 return false; 105 return false;
103 } 106 }
104 } 107 }
105 108
106 AppNotificationManager* manager = 109 AppNotificationManager* manager = extensions::ExtensionSystem::Get(
107 profile()->GetExtensionService()->app_notification_manager(); 110 profile())->extension_service()->app_notification_manager();
108 manager->ClearAll(id); 111 manager->ClearAll(id);
109 return true; 112 return true;
110 } 113 }
111 114
112 } // namespace extensions 115 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/all_urls_apitest.cc ('k') | chrome/browser/extensions/api/content_settings/content_settings_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698