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

Side by Side Diff: extensions/components/javascript_dialog_extensions_client/javascript_dialog_extension_client_impl.cc

Issue 1658913002: Make extensions use a correct same-origin check. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments. Created 4 years, 10 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 "extensions/components/javascript_dialog_extensions_client/javascript_d ialog_extension_client_impl.h" 5 #include "extensions/components/javascript_dialog_extensions_client/javascript_d ialog_extension_client_impl.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "components/app_modal/javascript_dialog_extensions_client.h" 8 #include "components/app_modal/javascript_dialog_extensions_client.h"
9 #include "components/app_modal/javascript_dialog_manager.h" 9 #include "components/app_modal/javascript_dialog_manager.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
11 #include "extensions/browser/process_manager.h" 11 #include "extensions/browser/process_manager.h"
12 #include "extensions/common/extension.h" 12 #include "extensions/common/extension.h"
13 #include "ui/gfx/native_widget_types.h" 13 #include "ui/gfx/native_widget_types.h"
14 #include "url/origin.h"
14 15
15 namespace javascript_dialog_extensions_client { 16 namespace javascript_dialog_extensions_client {
16 namespace { 17 namespace {
17 18
18 using extensions::Extension; 19 using extensions::Extension;
19 20
20 // Returns the ProcessManager for the browser context from |web_contents|. 21 // Returns the ProcessManager for the browser context from |web_contents|.
21 extensions::ProcessManager* GetProcessManager( 22 extensions::ProcessManager* GetProcessManager(
22 content::WebContents* web_contents) { 23 content::WebContents* web_contents) {
23 return extensions::ProcessManager::Get(web_contents->GetBrowserContext()); 24 return extensions::ProcessManager::Get(web_contents->GetBrowserContext());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 56
56 DCHECK(web_contents); 57 DCHECK(web_contents);
57 extensions::ProcessManager* pm = GetProcessManager(web_contents); 58 extensions::ProcessManager* pm = GetProcessManager(web_contents);
58 if (pm) 59 if (pm)
59 pm->DecrementLazyKeepaliveCount(extension); 60 pm->DecrementLazyKeepaliveCount(extension);
60 } 61 }
61 bool GetExtensionName(content::WebContents* web_contents, 62 bool GetExtensionName(content::WebContents* web_contents,
62 const GURL& origin_url, 63 const GURL& origin_url,
63 std::string* name_out) override { 64 std::string* name_out) override {
64 const Extension* extension = GetExtensionForWebContents(web_contents); 65 const Extension* extension = GetExtensionForWebContents(web_contents);
65 if (extension && 66 if (extension && url::IsSameOriginWith(
66 web_contents->GetLastCommittedURL().GetOrigin() == origin_url) { 67 origin_url, web_contents->GetLastCommittedURL())) {
67 *name_out = extension->name(); 68 *name_out = extension->name();
68 return true; 69 return true;
69 } 70 }
70 return false; 71 return false;
71 } 72 }
72 73
73 private: 74 private:
74 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogExtensionsClientImpl); 75 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogExtensionsClientImpl);
75 }; 76 };
76 77
77 } // namespace 78 } // namespace
78 79
79 void InstallClient() { 80 void InstallClient() {
80 app_modal::JavaScriptDialogManager::GetInstance()-> 81 app_modal::JavaScriptDialogManager::GetInstance()->
81 SetExtensionsClient( 82 SetExtensionsClient(
82 make_scoped_ptr(new JavaScriptDialogExtensionsClientImpl)); 83 make_scoped_ptr(new JavaScriptDialogExtensionsClientImpl));
83 } 84 }
84 85
85 } // namespace javascript_dialog_extensions_client 86 } // namespace javascript_dialog_extensions_client
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698