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

Side by Side Diff: chrome/browser/extensions/api/notifications/notifications_api.cc

Issue 666153002: Standardize usage of virtual/override/final in chrome/browser/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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/notifications/notifications_api.h" 5 #include "chrome/browser/extensions/api/notifications/notifications_api.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 const std::string& extension_id, 78 const std::string& extension_id,
79 const std::string& id) 79 const std::string& id)
80 : api_function_(api_function), 80 : api_function_(api_function),
81 profile_(profile), 81 profile_(profile),
82 extension_id_(extension_id), 82 extension_id_(extension_id),
83 id_(id), 83 id_(id),
84 scoped_id_(CreateScopedIdentifier(extension_id, id)) { 84 scoped_id_(CreateScopedIdentifier(extension_id, id)) {
85 DCHECK(api_function_.get()); 85 DCHECK(api_function_.get());
86 } 86 }
87 87
88 virtual void Display() override { } 88 void Display() override {}
89 89
90 virtual void Error() override {} 90 void Error() override {}
91 91
92 virtual void Close(bool by_user) override { 92 void Close(bool by_user) override {
93 EventRouter::UserGestureState gesture = 93 EventRouter::UserGestureState gesture =
94 by_user ? EventRouter::USER_GESTURE_ENABLED 94 by_user ? EventRouter::USER_GESTURE_ENABLED
95 : EventRouter::USER_GESTURE_NOT_ENABLED; 95 : EventRouter::USER_GESTURE_NOT_ENABLED;
96 scoped_ptr<base::ListValue> args(CreateBaseEventArgs()); 96 scoped_ptr<base::ListValue> args(CreateBaseEventArgs());
97 args->Append(new base::FundamentalValue(by_user)); 97 args->Append(new base::FundamentalValue(by_user));
98 SendEvent(notifications::OnClosed::kEventName, gesture, args.Pass()); 98 SendEvent(notifications::OnClosed::kEventName, gesture, args.Pass());
99 } 99 }
100 100
101 virtual void Click() override { 101 void Click() override {
102 scoped_ptr<base::ListValue> args(CreateBaseEventArgs()); 102 scoped_ptr<base::ListValue> args(CreateBaseEventArgs());
103 SendEvent(notifications::OnClicked::kEventName, 103 SendEvent(notifications::OnClicked::kEventName,
104 EventRouter::USER_GESTURE_ENABLED, 104 EventRouter::USER_GESTURE_ENABLED,
105 args.Pass()); 105 args.Pass());
106 } 106 }
107 107
108 virtual bool HasClickedListener() override { 108 bool HasClickedListener() override {
109 return EventRouter::Get(profile_)->HasEventListener( 109 return EventRouter::Get(profile_)->HasEventListener(
110 notifications::OnClicked::kEventName); 110 notifications::OnClicked::kEventName);
111 } 111 }
112 112
113 virtual void ButtonClick(int index) override { 113 void ButtonClick(int index) override {
114 scoped_ptr<base::ListValue> args(CreateBaseEventArgs()); 114 scoped_ptr<base::ListValue> args(CreateBaseEventArgs());
115 args->Append(new base::FundamentalValue(index)); 115 args->Append(new base::FundamentalValue(index));
116 SendEvent(notifications::OnButtonClicked::kEventName, 116 SendEvent(notifications::OnButtonClicked::kEventName,
117 EventRouter::USER_GESTURE_ENABLED, 117 EventRouter::USER_GESTURE_ENABLED,
118 args.Pass()); 118 args.Pass());
119 } 119 }
120 120
121 virtual std::string id() const override { 121 std::string id() const override { return scoped_id_; }
122 return scoped_id_;
123 }
124 122
125 private: 123 private:
126 virtual ~NotificationsApiDelegate() {} 124 ~NotificationsApiDelegate() override {}
127 125
128 void SendEvent(const std::string& name, 126 void SendEvent(const std::string& name,
129 EventRouter::UserGestureState user_gesture, 127 EventRouter::UserGestureState user_gesture,
130 scoped_ptr<base::ListValue> args) { 128 scoped_ptr<base::ListValue> args) {
131 scoped_ptr<Event> event(new Event(name, args.Pass())); 129 scoped_ptr<Event> event(new Event(name, args.Pass()));
132 event->user_gesture = user_gesture; 130 event->user_gesture = user_gesture;
133 EventRouter::Get(profile_)->DispatchEventToExtension(extension_id_, 131 EventRouter::Get(profile_)->DispatchEventToExtension(extension_id_,
134 event.Pass()); 132 event.Pass());
135 } 133 }
136 134
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 ? api::notifications::PERMISSION_LEVEL_GRANTED 605 ? api::notifications::PERMISSION_LEVEL_GRANTED
608 : api::notifications::PERMISSION_LEVEL_DENIED; 606 : api::notifications::PERMISSION_LEVEL_DENIED;
609 607
610 SetResult(new base::StringValue(api::notifications::ToString(result))); 608 SetResult(new base::StringValue(api::notifications::ToString(result)));
611 SendResponse(true); 609 SendResponse(true);
612 610
613 return true; 611 return true;
614 } 612 }
615 613
616 } // namespace extensions 614 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698