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

Side by Side Diff: chrome/browser/permissions/permission_request_manager.cc

Issue 2385063005: Make PermissionRequest::GetIconId return different types (Closed)
Patch Set: android Created 4 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 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/permissions/permission_request_manager.h" 5 #include "chrome/browser/permissions/permission_request_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/user_metrics_action.h" 10 #include "base/metrics/user_metrics_action.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/permissions/permission_request.h" 12 #include "chrome/browser/permissions/permission_request.h"
13 #include "chrome/browser/permissions/permission_uma_util.h" 13 #include "chrome/browser/permissions/permission_uma_util.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/navigation_details.h" 16 #include "content/public/browser/navigation_details.h"
17 #include "content/public/browser/user_metrics.h" 17 #include "content/public/browser/user_metrics.h"
18 #include "url/origin.h" 18 #include "url/origin.h"
19 19
20 namespace { 20 namespace {
21 21
22 class CancelledRequest : public PermissionRequest { 22 class CancelledRequest : public PermissionRequest {
23 public: 23 public:
24 explicit CancelledRequest(PermissionRequest* cancelled) 24 explicit CancelledRequest(PermissionRequest* cancelled)
25 : icon_(cancelled->GetIconId()), 25 : icon_(cancelled->GetIconId()),
26 message_fragment_(cancelled->GetMessageTextFragment()), 26 message_fragment_(cancelled->GetMessageTextFragment()),
27 origin_(cancelled->GetOrigin()) {} 27 origin_(cancelled->GetOrigin()) {}
28 ~CancelledRequest() override {} 28 ~CancelledRequest() override {}
29 29
30 int GetIconId() const override { return icon_; } 30 IconId GetIconId() const override { return icon_; }
31 base::string16 GetMessageTextFragment() const override { 31 base::string16 GetMessageTextFragment() const override {
32 return message_fragment_; 32 return message_fragment_;
33 } 33 }
34 GURL GetOrigin() const override { return origin_; } 34 GURL GetOrigin() const override { return origin_; }
35 35
36 // These are all no-ops since the placeholder is non-forwarding. 36 // These are all no-ops since the placeholder is non-forwarding.
37 void PermissionGranted() override {} 37 void PermissionGranted() override {}
38 void PermissionDenied() override {} 38 void PermissionDenied() override {}
39 void Cancelled() override {} 39 void Cancelled() override {}
40 40
41 void RequestFinished() override { delete this; } 41 void RequestFinished() override { delete this; }
42 42
43 private: 43 private:
44 int icon_; 44 IconId icon_;
45 base::string16 message_fragment_; 45 base::string16 message_fragment_;
46 GURL origin_; 46 GURL origin_;
47 }; 47 };
48 48
49 bool IsMessageTextEqual(PermissionRequest* a, 49 bool IsMessageTextEqual(PermissionRequest* a,
50 PermissionRequest* b) { 50 PermissionRequest* b) {
51 if (a == b) 51 if (a == b)
52 return true; 52 return true;
53 if (a->GetMessageTextFragment() == b->GetMessageTextFragment() && 53 if (a->GetMessageTextFragment() == b->GetMessageTextFragment() &&
54 a->GetOrigin() == b->GetOrigin()) { 54 a->GetOrigin() == b->GetOrigin()) {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 case DENY_ALL: 514 case DENY_ALL:
515 Deny(); 515 Deny();
516 break; 516 break;
517 case DISMISS: 517 case DISMISS:
518 Closing(); 518 Closing();
519 break; 519 break;
520 case NONE: 520 case NONE:
521 NOTREACHED(); 521 NOTREACHED();
522 } 522 }
523 } 523 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698