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

Side by Side Diff: chrome/browser/extensions/api/identity/web_auth_flow.cc

Issue 15892012: Identity API: defer loading component app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/component_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/identity/web_auth_flow.h" 5 #include "chrome/browser/extensions/api/identity/web_auth_flow.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/component_loader.h"
11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_navigator.h" 15 #include "chrome/browser/ui/browser_navigator.h"
13 #include "content/public/browser/load_notification_details.h" 16 #include "content/public/browser/load_notification_details.h"
14 #include "content/public/browser/navigation_controller.h" 17 #include "content/public/browser/navigation_controller.h"
15 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
16 #include "content/public/browser/notification_details.h" 19 #include "content/public/browser/notification_details.h"
17 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
18 #include "content/public/browser/notification_types.h" 21 #include "content/public/browser/notification_types.h"
19 #include "content/public/browser/resource_request_details.h" 22 #include "content/public/browser/resource_request_details.h"
20 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
21 #include "content/public/common/page_transition_types.h" 24 #include "content/public/common/page_transition_types.h"
22 #include "googleurl/src/gurl.h" 25 #include "googleurl/src/gurl.h"
26 #include "grit/browser_resources.h"
23 #include "ui/base/window_open_disposition.h" 27 #include "ui/base/window_open_disposition.h"
24 28
25 using content::LoadNotificationDetails; 29 using content::LoadNotificationDetails;
26 using content::NavigationController; 30 using content::NavigationController;
27 using content::RenderViewHost; 31 using content::RenderViewHost;
28 using content::ResourceRedirectDetails; 32 using content::ResourceRedirectDetails;
29 using content::WebContents; 33 using content::WebContents;
30 using content::WebContentsObserver; 34 using content::WebContentsObserver;
31 35
32 namespace extensions { 36 namespace extensions {
(...skipping 26 matching lines...) Expand all
59 if (contents_) { 63 if (contents_) {
60 // The popup owns the contents if it was displayed. 64 // The popup owns the contents if it was displayed.
61 if (popup_shown_) 65 if (popup_shown_)
62 contents_->Close(); 66 contents_->Close();
63 else 67 else
64 delete contents_; 68 delete contents_;
65 } 69 }
66 } 70 }
67 71
68 void WebAuthFlow::Start() { 72 void WebAuthFlow::Start() {
73 static bool is_component_loaded = false;
Matt Perry 2013/05/29 00:39:28 This isn't multi-profile safe.
Michael Courage 2013/05/29 00:49:37 Good point. Is it reasonable/cheap to just do this
Matt Perry 2013/05/29 00:53:38 This will actually cause the app to reload, which
Michael Courage 2013/05/29 01:49:53 ComponentLoader::Exists will do the trick, thanks.
74 if (!is_component_loaded) {
75 extensions::ExtensionSystem* extension_system =
76 extensions::ExtensionSystem::Get(profile_);
77 ExtensionService* extension_service = extension_system->extension_service();
78 extension_service->component_loader()->Add(
79 IDR_IDENTITY_API_SCOPE_APPROVAL_MANIFEST,
80 base::FilePath(FILE_PATH_LITERAL("identity_scope_approval_dialog")));
81 is_component_loaded = true;
82 }
83
69 contents_ = CreateWebContents(); 84 contents_ = CreateWebContents();
70 WebContentsObserver::Observe(contents_); 85 WebContentsObserver::Observe(contents_);
71 86
72 NavigationController* controller = &(contents_->GetController()); 87 NavigationController* controller = &(contents_->GetController());
73 88
74 // Register for appropriate notifications to intercept navigation to the 89 // Register for appropriate notifications to intercept navigation to the
75 // redirect URLs. 90 // redirect URLs.
76 registrar_.Add( 91 registrar_.Add(
77 this, 92 this,
78 content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, 93 content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 AfterUrlLoaded(); 186 AfterUrlLoaded();
172 } 187 }
173 188
174 void WebAuthFlow::WebContentsDestroyed(WebContents* web_contents) { 189 void WebAuthFlow::WebContentsDestroyed(WebContents* web_contents) {
175 contents_ = NULL; 190 contents_ = NULL;
176 if (delegate_) 191 if (delegate_)
177 delegate_->OnAuthFlowFailure(WebAuthFlow::WINDOW_CLOSED); 192 delegate_->OnAuthFlowFailure(WebAuthFlow::WINDOW_CLOSED);
178 } 193 }
179 194
180 } // namespace extensions 195 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/component_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698