OLD | NEW |
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/ui/website_settings/permission_bubble_manager.h" | 5 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/user_metrics_action.h" | 8 #include "base/metrics/user_metrics_action.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" | 10 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" |
11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/navigation_details.h" | 13 #include "content/public/browser/navigation_details.h" |
14 #include "content/public/browser/user_metrics.h" | 14 #include "content/public/browser/user_metrics.h" |
| 15 #include "url/origin.h" |
15 | 16 |
16 #if !defined(OS_ANDROID) | 17 #if !defined(OS_ANDROID) |
17 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
18 #endif | 19 #endif |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 class CancelledRequest : public PermissionBubbleRequest { | 23 class CancelledRequest : public PermissionBubbleRequest { |
23 public: | 24 public: |
24 explicit CancelledRequest(PermissionBubbleRequest* cancelled) | 25 explicit CancelledRequest(PermissionBubbleRequest* cancelled) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 void PermissionBubbleManager::AddRequest(PermissionBubbleRequest* request) { | 99 void PermissionBubbleManager::AddRequest(PermissionBubbleRequest* request) { |
99 content::RecordAction(base::UserMetricsAction("PermissionBubbleRequest")); | 100 content::RecordAction(base::UserMetricsAction("PermissionBubbleRequest")); |
100 // TODO(gbillock): is there a race between an early request on a | 101 // TODO(gbillock): is there a race between an early request on a |
101 // newly-navigated page and the to-be-cleaned-up requests on the previous | 102 // newly-navigated page and the to-be-cleaned-up requests on the previous |
102 // page? We should maybe listen to DidStartNavigationToPendingEntry (and | 103 // page? We should maybe listen to DidStartNavigationToPendingEntry (and |
103 // any other renderer-side nav initiations?). Double-check this for | 104 // any other renderer-side nav initiations?). Double-check this for |
104 // correct behavior on interstitials -- we probably want to basically queue | 105 // correct behavior on interstitials -- we probably want to basically queue |
105 // any request for which GetVisibleURL != GetLastCommittedURL. | 106 // any request for which GetVisibleURL != GetLastCommittedURL. |
106 request_url_ = web_contents()->GetLastCommittedURL(); | 107 request_url_ = web_contents()->GetLastCommittedURL(); |
107 bool is_main_frame = | 108 bool is_main_frame = |
108 request->GetRequestingHostname().GetOrigin() == request_url_.GetOrigin(); | 109 url::Origin(request_url_) |
| 110 .IsSameOriginWith(url::Origin(request->GetRequestingHostname())); |
109 | 111 |
110 // Don't re-add an existing request or one with a duplicate text request. | 112 // Don't re-add an existing request or one with a duplicate text request. |
111 bool same_object = false; | 113 bool same_object = false; |
112 if (ExistingRequest(request, requests_, &same_object) || | 114 if (ExistingRequest(request, requests_, &same_object) || |
113 ExistingRequest(request, queued_requests_, &same_object) || | 115 ExistingRequest(request, queued_requests_, &same_object) || |
114 ExistingRequest(request, queued_frame_requests_, &same_object)) { | 116 ExistingRequest(request, queued_frame_requests_, &same_object)) { |
115 if (!same_object) | 117 if (!same_object) |
116 request->RequestFinished(); | 118 request->RequestFinished(); |
117 return; | 119 return; |
118 } | 120 } |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 case DENY_ALL: | 447 case DENY_ALL: |
446 Deny(); | 448 Deny(); |
447 break; | 449 break; |
448 case DISMISS: | 450 case DISMISS: |
449 Closing(); | 451 Closing(); |
450 break; | 452 break; |
451 case NONE: | 453 case NONE: |
452 NOTREACHED(); | 454 NOTREACHED(); |
453 } | 455 } |
454 } | 456 } |
OLD | NEW |