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

Unified Diff: chrome/browser/ui/webui/chromeos/drive_internals_ui.cc

Issue 10808116: gdata: Add authentication status section to chrome:drive-internals (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/chromeos/drive_internals.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
diff --git a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
index 3706c2e861686d41838c780f88e06e5dc047c7ac..77af00063b77597733305d19568c0a78935088f3 100644
--- a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
@@ -4,16 +4,66 @@
#include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h"
+#include "base/bind.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/chromeos/gdata/gdata_auth_service.h"
+#include "chrome/browser/chromeos/gdata/gdata_documents_service.h"
+#include "chrome/browser/chromeos/gdata/gdata_system_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_message_handler.h"
#include "grit/browser_resources.h"
namespace chromeos {
+// Class to handle messages from chrome://drive-internals.
+class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
achuithb 2012/07/24 23:53:20 Why not put this in anonymous scope?
satorux1 2012/07/25 00:32:23 Done.
+ public:
+ DriveInternalsWebUIHandler()
+ : weak_ptr_factory_(this) {
+ }
+
+ ~DriveInternalsWebUIHandler() {
achuithb 2012/07/24 23:53:20 Should this be virtual?
satorux1 2012/07/25 00:32:23 Done.
+ }
+
+ // WebUIMessageHandler override.
+ virtual void RegisterMessages() OVERRIDE {
achuithb 2012/07/24 23:53:20 This can be private, I believe.
satorux1 2012/07/25 00:32:23 Done.
+ web_ui()->RegisterMessageCallback(
+ "pageLoaded",
+ base::Bind(&DriveInternalsWebUIHandler::OnPageLoaded,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
+
+ private:
+ // Called when the page is first loaded.
+ void OnPageLoaded(const base::ListValue* args) {
+ Profile* profile = Profile::FromWebUI(web_ui());
+ gdata::GDataSystemService* system_service =
+ gdata::GDataSystemServiceFactory::GetForProfile(profile);
+ DCHECK(system_service);
achuithb 2012/07/24 23:53:20 Is it possible to launch this page in guest/incogn
satorux1 2012/07/25 00:32:23 Good point. Will |system_service| be NULL in the g
+ gdata::DocumentsServiceInterface* documents_service =
+ system_service->docs_service();
+ DCHECK(documents_service);
+
+ // Update the auth status section.
+ DictionaryValue auth_status;
+ auth_status.SetBoolean("has-fresh-token",
+ documents_service->IsFullyAuthenticated());
+ auth_status.SetBoolean("has-auth-token",
+ documents_service->IsPartiallyAuthenticated());
+ web_ui()->CallJavascriptFunction("UpdateAuthStatus", auth_status);
+ }
+
+ base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_;
+ DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler);
+};
+
DriveInternalsUI::DriveInternalsUI(content::WebUI* web_ui)
: WebUIController(web_ui) {
+ web_ui->AddMessageHandler(new DriveInternalsWebUIHandler());
+
ChromeWebUIDataSource* source =
new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost);
source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS);
« no previous file with comments | « chrome/browser/resources/chromeos/drive_internals.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698